Compare commits
1 Commits
8c089dc7a6
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 8f721ce544 |
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -26,13 +27,21 @@ namespace ScimitarStandardTemplate
|
|||||||
public List<spotMeasurement> spotMeasurements = new List<spotMeasurement>();
|
public List<spotMeasurement> spotMeasurements = new List<spotMeasurement>();
|
||||||
public List<curveTrace> curveTraces = new List<curveTrace>();
|
public List<curveTrace> curveTraces = new List<curveTrace>();
|
||||||
public XmlDocument xmlDocument = new XmlDocument();
|
public XmlDocument xmlDocument = new XmlDocument();
|
||||||
|
public int SpotsCount { get; set; }
|
||||||
|
public int CurveTracesCount { get; set; }
|
||||||
|
public string DirectoryPath { get; set; }
|
||||||
|
public string FilenameWithoutExtension { get; set; }
|
||||||
|
|
||||||
|
public List<spotMeasurement> spotsToAdd = new List<spotMeasurement>();
|
||||||
|
public List<curveTrace> curveTracesToAdd = new List<curveTrace>();
|
||||||
|
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
AddStandardSpots();
|
AddStandardSpots();
|
||||||
AddStandardCurveTraces();
|
AddStandardCurveTraces();
|
||||||
Serialize();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
private void LoadXmlDocument (string path)
|
private void LoadXmlDocument (string path)
|
||||||
@@ -46,21 +55,193 @@ namespace ScimitarStandardTemplate
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void Serialize()
|
|
||||||
|
private void AddToDocument()
|
||||||
{
|
{
|
||||||
XmlSerializer x = new XmlSerializer(spotMeasurements[0].GetType());
|
SerializeCurveTraces();
|
||||||
x.Serialize(Console.Out, spotMeasurements[0]);
|
SerializeSpots();
|
||||||
//x = new XmlSerializer(curveTraces[0].GetType());
|
SaveDocument();
|
||||||
//x.Serialize(Console.Out, curveTraces[0]);
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveDocument()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
xmlDocument.Save(DirectoryPath + "Generated_" + FilenameWithoutExtension + ".xml");
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GetSpotsToAdd()
|
||||||
|
{
|
||||||
|
var spotNodes = xmlDocument.GetElementsByTagName("spotMeasurement");
|
||||||
|
|
||||||
|
List<string> spotMeasurementsNamesInDoc = new List<string>();
|
||||||
|
foreach (XmlElement spot in spotNodes)
|
||||||
|
{
|
||||||
|
string spotName = spot.Attributes.GetNamedItem("name").Value;
|
||||||
|
spotMeasurementsNamesInDoc.Add(spotName);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (spotMeasurement spotMeasurement in spotMeasurements)
|
||||||
|
{
|
||||||
|
if (!spotMeasurementsNamesInDoc.Contains(spotMeasurement.name))
|
||||||
|
{
|
||||||
|
spotsToAdd.Add(spotMeasurement);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("bla");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GetCurveTracesToAdd()
|
||||||
|
{
|
||||||
|
var curveNodes = xmlDocument.GetElementsByTagName("curveTrace");
|
||||||
|
|
||||||
|
List<string> curveTracesNamesInDoc = new List<string>();
|
||||||
|
foreach (XmlElement curve in curveNodes)
|
||||||
|
{
|
||||||
|
string curveName = curve.Attributes.GetNamedItem("name").Value;
|
||||||
|
curveTracesNamesInDoc.Add(curveName);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (curveTrace curveTrace in curveTraces)
|
||||||
|
{
|
||||||
|
if (!curveTracesNamesInDoc.Contains(curveTrace.name))
|
||||||
|
{
|
||||||
|
curveTracesToAdd.Add(curveTrace);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GetNumberOfSpots()
|
||||||
|
{
|
||||||
|
var rootNode = xmlDocument.GetElementsByTagName("spots")[0];
|
||||||
|
var stringCount = rootNode.Attributes.GetNamedItem("count").Value;
|
||||||
|
this.SpotsCount = Int16.Parse(stringCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GetNumberOfCurveTraces()
|
||||||
|
{
|
||||||
|
var rootNode = xmlDocument.GetElementsByTagName("curveTraces")[0];
|
||||||
|
var stringCurveTracesCount = rootNode.Attributes.GetNamedItem("count").Value;
|
||||||
|
this.CurveTracesCount = Int16.Parse(stringCurveTracesCount);
|
||||||
|
}
|
||||||
|
private void SerializeSpots()
|
||||||
|
{
|
||||||
|
if(spotsToAdd.Count > 0)
|
||||||
|
{
|
||||||
|
XmlSerializer x = new XmlSerializer(spotsToAdd[0].GetType());
|
||||||
|
var rootNode = xmlDocument.GetElementsByTagName("spots")[0];
|
||||||
|
int totalCount = spotsToAdd.Count + SpotsCount;
|
||||||
|
rootNode.Attributes.GetNamedItem("count").Value = totalCount.ToString();
|
||||||
|
var nav = rootNode.CreateNavigator();
|
||||||
|
var emptyNamepsaces = new XmlSerializerNamespaces(new[] {XmlQualifiedName.Empty});
|
||||||
|
|
||||||
|
using (var writer = nav.AppendChild())
|
||||||
|
{
|
||||||
|
var serializer = new XmlSerializer(spotsToAdd[0].GetType());
|
||||||
|
writer.WriteWhitespace("");
|
||||||
|
|
||||||
|
foreach (var spot in spotsToAdd)
|
||||||
|
{
|
||||||
|
serializer.Serialize(writer, spot, emptyNamepsaces);
|
||||||
|
}
|
||||||
|
|
||||||
|
writer.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SerializeCurveTraces()
|
||||||
|
{
|
||||||
|
if (curveTracesToAdd.Count > 0)
|
||||||
|
{
|
||||||
|
XmlSerializer x = new XmlSerializer(spotsToAdd[0].GetType());
|
||||||
|
var rootNode = xmlDocument.GetElementsByTagName("curveTraces")[0];
|
||||||
|
int totalCount = curveTracesToAdd.Count + CurveTracesCount;
|
||||||
|
rootNode.Attributes.GetNamedItem("count").Value = totalCount.ToString();
|
||||||
|
|
||||||
|
var nav = rootNode.CreateNavigator();
|
||||||
|
var emptyNamepsaces = new XmlSerializerNamespaces(new[] { XmlQualifiedName.Empty });
|
||||||
|
|
||||||
|
using (var writer = nav.AppendChild())
|
||||||
|
{
|
||||||
|
var serializer = new XmlSerializer(curveTracesToAdd[0].GetType());
|
||||||
|
writer.WriteWhitespace("");
|
||||||
|
|
||||||
|
foreach (var curve in curveTracesToAdd)
|
||||||
|
{
|
||||||
|
serializer.Serialize(writer, curve, emptyNamepsaces);
|
||||||
|
}
|
||||||
|
|
||||||
|
writer.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void AddStandardCurveTraces()
|
private void AddStandardCurveTraces()
|
||||||
{
|
{
|
||||||
var curveTrace1 = new curveTrace()
|
var curveTrace1 = new curveTrace()
|
||||||
|
{
|
||||||
|
name = "-10uA..+10uA;Steps:51;Limit:2V",
|
||||||
|
settlingTime = "0.01",
|
||||||
|
supplyName = "MKx-style (30V/5A)",
|
||||||
|
limit = "2",
|
||||||
|
forceType = "Current",
|
||||||
|
percentageOfLineCycle = "_10_",
|
||||||
|
compareAlgorithm = "Percentage",
|
||||||
|
maxVoltage = "10",
|
||||||
|
minVoltage = "10",
|
||||||
|
maxCurrent = "10",
|
||||||
|
minCurrent = "10",
|
||||||
|
voltageAutoRange = "false",
|
||||||
|
currentAutoRange = "false",
|
||||||
|
start = "-0.00001",
|
||||||
|
stop = "0.00001",
|
||||||
|
stepCount = "51",
|
||||||
|
initialSettlingTime = "0.01",
|
||||||
|
stepSettlingTIme = "0.002",
|
||||||
|
selfChecks = "OpenCircuit, ShortToGround"
|
||||||
|
};
|
||||||
|
|
||||||
|
var curveTrace2 = new curveTrace()
|
||||||
|
{
|
||||||
|
name = "-100uA..+100uA;Steps:51;Limit:2V",
|
||||||
|
settlingTime = "0.01",
|
||||||
|
supplyName = "MKx-style (30V/5A)",
|
||||||
|
limit = "2",
|
||||||
|
forceType = "Current",
|
||||||
|
percentageOfLineCycle = "_10_",
|
||||||
|
compareAlgorithm = "Percentage",
|
||||||
|
maxVoltage = "10",
|
||||||
|
minVoltage = "10",
|
||||||
|
maxCurrent = "10",
|
||||||
|
minCurrent = "10",
|
||||||
|
voltageAutoRange = "false",
|
||||||
|
currentAutoRange = "false",
|
||||||
|
start = "-0.0001",
|
||||||
|
stop = "0.0001",
|
||||||
|
stepCount = "51",
|
||||||
|
initialSettlingTime = "0.01",
|
||||||
|
stepSettlingTIme = "0.002",
|
||||||
|
selfChecks = "OpenCircuit, ShortToGround"
|
||||||
|
};
|
||||||
|
|
||||||
|
var curveTrace3 = new curveTrace()
|
||||||
{
|
{
|
||||||
name = "-1mA..+1mA;Steps:51;Limit:2V",
|
name = "-1mA..+1mA;Steps:51;Limit:2V",
|
||||||
desc = "",
|
|
||||||
settlingTime = "0.01",
|
settlingTime = "0.01",
|
||||||
supplyName = "MKx-style (30V/5A)",
|
supplyName = "MKx-style (30V/5A)",
|
||||||
limit = "2",
|
limit = "2",
|
||||||
@@ -80,8 +261,9 @@ namespace ScimitarStandardTemplate
|
|||||||
stepSettlingTIme = "0.002",
|
stepSettlingTIme = "0.002",
|
||||||
selfChecks = "OpenCircuit, ShortToGround"
|
selfChecks = "OpenCircuit, ShortToGround"
|
||||||
};
|
};
|
||||||
|
|
||||||
this.curveTraces.Add(curveTrace1);
|
this.curveTraces.Add(curveTrace1);
|
||||||
|
this.curveTraces.Add(curveTrace2);
|
||||||
|
this.curveTraces.Add(curveTrace3);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +272,6 @@ namespace ScimitarStandardTemplate
|
|||||||
var spotMeasurement1 = new spotMeasurement()
|
var spotMeasurement1 = new spotMeasurement()
|
||||||
{
|
{
|
||||||
name = "-10uA; Limit: 2V",
|
name = "-10uA; Limit: 2V",
|
||||||
desc = "",
|
|
||||||
settlingTime = "0.003",
|
settlingTime = "0.003",
|
||||||
supplyName = "MKx-style (30V/5A)",
|
supplyName = "MKx-style (30V/5A)",
|
||||||
limit = "2",
|
limit = "2",
|
||||||
@@ -110,7 +291,6 @@ namespace ScimitarStandardTemplate
|
|||||||
var spotMeasurement2 = new spotMeasurement()
|
var spotMeasurement2 = new spotMeasurement()
|
||||||
{
|
{
|
||||||
name = "+10uA; Limit: 2V",
|
name = "+10uA; Limit: 2V",
|
||||||
desc = "",
|
|
||||||
settlingTime = "0.003",
|
settlingTime = "0.003",
|
||||||
supplyName = "MKx-style (30V/5A)",
|
supplyName = "MKx-style (30V/5A)",
|
||||||
limit = "2",
|
limit = "2",
|
||||||
@@ -130,7 +310,6 @@ namespace ScimitarStandardTemplate
|
|||||||
var spotMeasurement3 = new spotMeasurement()
|
var spotMeasurement3 = new spotMeasurement()
|
||||||
{
|
{
|
||||||
name = "-1mA; Limit: 2V (SHORT/R)",
|
name = "-1mA; Limit: 2V (SHORT/R)",
|
||||||
desc = "",
|
|
||||||
settlingTime = "0.003",
|
settlingTime = "0.003",
|
||||||
supplyName = "MKx-style (30V/5A)",
|
supplyName = "MKx-style (30V/5A)",
|
||||||
limit = "2",
|
limit = "2",
|
||||||
@@ -148,13 +327,21 @@ namespace ScimitarStandardTemplate
|
|||||||
};
|
};
|
||||||
|
|
||||||
spotMeasurements.Add(spotMeasurement1);
|
spotMeasurements.Add(spotMeasurement1);
|
||||||
//spotMeasurements.Add(spotMeasurement2);
|
spotMeasurements.Add(spotMeasurement2);
|
||||||
//spotMeasurements.Add(spotMeasurement3);
|
spotMeasurements.Add(spotMeasurement3);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BrowseButton_Click(object sender, RoutedEventArgs e)
|
private void BrowseButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
OpenFileBrowser();
|
OpenFileBrowser();
|
||||||
|
|
||||||
|
LoadXmlDocument(FileName);
|
||||||
|
GetNumberOfSpots();
|
||||||
|
GetNumberOfCurveTraces();
|
||||||
|
GetSpotsToAdd();
|
||||||
|
GetCurveTracesToAdd();
|
||||||
|
AddToDocument();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OpenFileBrowser ()
|
private void OpenFileBrowser ()
|
||||||
@@ -163,8 +350,8 @@ namespace ScimitarStandardTemplate
|
|||||||
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
|
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
|
||||||
|
|
||||||
// Set filter for file extension and default file extension
|
// Set filter for file extension and default file extension
|
||||||
dlg.DefaultExt = ".txt";
|
dlg.DefaultExt = ".xml";
|
||||||
dlg.Filter = "Text documents (.txt)|*.txt";
|
dlg.Filter = "xml documents (.xml)|*.xml";
|
||||||
|
|
||||||
// Display OpenFileDialog by calling ShowDialog method
|
// Display OpenFileDialog by calling ShowDialog method
|
||||||
Nullable<bool> result = dlg.ShowDialog();
|
Nullable<bool> result = dlg.ShowDialog();
|
||||||
@@ -175,6 +362,9 @@ namespace ScimitarStandardTemplate
|
|||||||
// Open document
|
// Open document
|
||||||
string filename = dlg.FileName;
|
string filename = dlg.FileName;
|
||||||
this.FileName = filename;
|
this.FileName = filename;
|
||||||
|
this.DirectoryPath = System.IO.Path.GetDirectoryName(dlg.FileName);
|
||||||
|
this.FilenameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(dlg.FileName);
|
||||||
|
Console.WriteLine(FilenameWithoutExtension);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ namespace ScimitarStandardTemplate
|
|||||||
|
|
||||||
public ParametricOperation()
|
public ParametricOperation()
|
||||||
{
|
{
|
||||||
|
this.desc = "Automatic Generated";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,12 +14,16 @@ namespace ScimitarStandardTemplate
|
|||||||
|
|
||||||
[XmlElement("spot")]
|
[XmlElement("spot")]
|
||||||
public spot[] spots { get; set; }
|
public spot[] spots { get; set; }
|
||||||
//public int[] nee;
|
|
||||||
|
|
||||||
public spotMeasurement()
|
public spotMeasurement()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Add()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class spot
|
public class spot
|
||||||
|
|||||||
Reference in New Issue
Block a user