Add project files.

This commit is contained in:
2024-07-12 17:56:05 +02:00
parent a0f6754140
commit 8be1092ec4
15 changed files with 759 additions and 0 deletions

View File

@@ -0,0 +1,182 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Xml;
using System.Xml.Serialization;
namespace ScimitarStandardTemplate
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public string FileName { get; set; }
public List<spotMeasurement> spotMeasurements = new List<spotMeasurement>();
public List<curveTrace> curveTraces = new List<curveTrace>();
public XmlDocument xmlDocument = new XmlDocument();
public MainWindow()
{
InitializeComponent();
AddStandardSpots();
AddStandardCurveTraces();
Serialize();
}
private void LoadXmlDocument (string path)
{
try
{
this.xmlDocument.Load(path);
}
catch (Exception)
{
throw;
}
}
private void Serialize()
{
XmlSerializer x = new XmlSerializer(spotMeasurements[0].GetType());
x.Serialize(Console.Out, spotMeasurements[0]);
//x = new XmlSerializer(curveTraces[0].GetType());
//x.Serialize(Console.Out, curveTraces[0]);
}
private void AddStandardCurveTraces()
{
var curveTrace1 = new curveTrace()
{
name = "-1mA..+1mA;Steps:51;Limit:2V",
desc = "",
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.001",
stop = "0.001",
stepCount = "51",
initialSettlingTime = "0.01",
stepSettlingTIme = "0.002",
selfChecks = "OpenCircuit, ShortToGround"
};
this.curveTraces.Add(curveTrace1);
}
private void AddStandardSpots ()
{
var spotMeasurement1 = new spotMeasurement()
{
name = "-10uA; Limit: 2V",
desc = "",
settlingTime = "0.003",
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",
spotCount = "1",
spots = new spot[] { new spot { stress = "-0.00001", minimum = "-1.9", maximum = "-0.1" } }
};
var spotMeasurement2 = new spotMeasurement()
{
name = "+10uA; Limit: 2V",
desc = "",
settlingTime = "0.003",
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",
spotCount = "1",
spots = new spot[] { new spot { stress = "0.00001", minimum = "0.1", maximum = "1.9" } }
};
var spotMeasurement3 = new spotMeasurement()
{
name = "-1mA; Limit: 2V (SHORT/R)",
desc = "",
settlingTime = "0.003",
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",
spotCount = "1",
spots = new spot[] { new spot { stress = "-0.001", minimum = "-0.200", maximum = "0.200" } }
};
spotMeasurements.Add(spotMeasurement1);
//spotMeasurements.Add(spotMeasurement2);
//spotMeasurements.Add(spotMeasurement3);
}
private void BrowseButton_Click(object sender, RoutedEventArgs e)
{
OpenFileBrowser();
}
private void OpenFileBrowser ()
{
// Create OpenFileDialog
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
// Set filter for file extension and default file extension
dlg.DefaultExt = ".txt";
dlg.Filter = "Text documents (.txt)|*.txt";
// Display OpenFileDialog by calling ShowDialog method
Nullable<bool> result = dlg.ShowDialog();
// Get the selected file name and display in a TextBox
if (result == true)
{
// Open document
string filename = dlg.FileName;
this.FileName = filename;
}
}
}
}