GTB: temp.calibration - GMH shoul be read on the same thread as the UI
This commit is contained in:
@@ -27,42 +27,42 @@ namespace TempFlansh
|
||||
////}
|
||||
while (true)
|
||||
{
|
||||
Console.WriteLine(helper.ReadCurrentDisplayValue().ToString());
|
||||
|
||||
//using (NamedPipeServerStream pipeServer = new NamedPipeServerStream("TempPipe", PipeDirection.Out))
|
||||
//{
|
||||
// Console.WriteLine("NamedPipeServerStream object created.");
|
||||
|
||||
using (NamedPipeServerStream pipeServer = new NamedPipeServerStream("TempPipe", PipeDirection.Out))
|
||||
{
|
||||
Console.WriteLine("NamedPipeServerStream object created.");
|
||||
// // Wait for a client to connect
|
||||
// Console.Write("Waiting for client connection...");
|
||||
// pipeServer.WaitForConnection();
|
||||
// Console.Write("Open Comport");
|
||||
// Console.WriteLine("Client connected.");
|
||||
|
||||
// Wait for a client to connect
|
||||
Console.Write("Waiting for client connection...");
|
||||
pipeServer.WaitForConnection();
|
||||
Console.Write("Open Comport");
|
||||
Console.WriteLine("Client connected.");
|
||||
// try
|
||||
// {
|
||||
// // Read user input and send that to the client process.
|
||||
// using (StreamWriter sw = new StreamWriter(pipeServer))
|
||||
// {
|
||||
// sw.AutoFlush = true;
|
||||
|
||||
try
|
||||
{
|
||||
// Read user input and send that to the client process.
|
||||
using (StreamWriter sw = new StreamWriter(pipeServer))
|
||||
{
|
||||
sw.AutoFlush = true;
|
||||
// while (pipeServer.IsConnected)
|
||||
// {
|
||||
// //sw.WriteLine("19.0");
|
||||
// sw.WriteLine(helper.ReadCurrentDisplayValue().ToString());
|
||||
// Console.WriteLine(helper.ReadCurrentDisplayValue().ToString());
|
||||
// Thread.Sleep(500);
|
||||
// }
|
||||
|
||||
while (pipeServer.IsConnected)
|
||||
{
|
||||
//sw.WriteLine("19.0");
|
||||
sw.WriteLine(helper.ReadCurrentDisplayValue().ToString());
|
||||
Console.WriteLine(helper.ReadCurrentDisplayValue().ToString());
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// Catch the IOException that is raised if the pipe is broken
|
||||
// or disconnected.
|
||||
catch (IOException e)
|
||||
{
|
||||
Console.WriteLine("ERROR: {0}", e.Message);
|
||||
}
|
||||
}
|
||||
// }
|
||||
// }
|
||||
// // Catch the IOException that is raised if the pipe is broken
|
||||
// // or disconnected.
|
||||
// catch (IOException e)
|
||||
// {
|
||||
// Console.WriteLine("ERROR: {0}", e.Message);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
//Application.EnableVisualStyles();
|
||||
|
||||
@@ -1,45 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<section name="Xylem.Common.Ui.GenesisToolBox.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||
<section name="Xylem.Common.Ui.GenesisToolBox.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
|
||||
</startup>
|
||||
<userSettings>
|
||||
<Xylem.Common.Ui.GenesisToolBox.Properties.Settings>
|
||||
<setting name="InitialBinaryPath" serializeAs="String">
|
||||
<value />
|
||||
<value/>
|
||||
</setting>
|
||||
<setting name="InitialPackageFile" serializeAs="String">
|
||||
<value />
|
||||
<value/>
|
||||
</setting>
|
||||
</Xylem.Common.Ui.GenesisToolBox.Properties.Settings>
|
||||
</userSettings>
|
||||
<appSettings>
|
||||
<add key="AdminName" value="My Name" />
|
||||
<add key="AdminEMail" value="MyEMailAddress" />
|
||||
<add key="ClientSettingsProvider.ServiceUri" value="" />
|
||||
<add key="AdminName" value="My Name"/>
|
||||
<add key="AdminEMail" value="MyEMailAddress"/>
|
||||
<add key="ClientSettingsProvider.ServiceUri" value=""/>
|
||||
</appSettings>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0"/>
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<system.web>
|
||||
<membership defaultProvider="ClientAuthenticationMembershipProvider">
|
||||
<providers>
|
||||
<add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
|
||||
<add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri=""/>
|
||||
</providers>
|
||||
</membership>
|
||||
<roleManager defaultProvider="ClientRoleProvider" enabled="true">
|
||||
<providers>
|
||||
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
|
||||
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400"/>
|
||||
</providers>
|
||||
</roleManager>
|
||||
</system.web>
|
||||
|
||||
@@ -107,7 +107,7 @@
|
||||
|
||||
var a = GetLutsText(currentGenesis.PcbId);
|
||||
currentGenesis.InitMeasurement();
|
||||
Invoke(new Action(() =>
|
||||
InvokeOnUIThread(new Action(() =>
|
||||
{
|
||||
|
||||
txtLuts.Text = a;
|
||||
@@ -143,7 +143,7 @@
|
||||
{
|
||||
var a = GetLutsText(currentGenesis.PcbId);
|
||||
|
||||
Invoke(new Action(() =>
|
||||
InvokeOnUIThread(new Action(() =>
|
||||
{
|
||||
txtLuts.Text = a;
|
||||
if (lutIsMissing)
|
||||
@@ -685,7 +685,7 @@
|
||||
this.currentGenesis = null;
|
||||
}
|
||||
|
||||
this.Invoke(new Action(() =>
|
||||
this.InvokeOnUIThread(new Action(() =>
|
||||
{
|
||||
this.txtLuts.Text = string.Empty;
|
||||
this.txtLuts.BackColor = Color.White;
|
||||
@@ -823,7 +823,8 @@
|
||||
text = text.Substring(0, Math.Min(5000, text?.Length ?? 0));
|
||||
|
||||
this.automaticContentBox.ResetText();
|
||||
this.automaticContentBox.AppendText(text);
|
||||
this.automaticContentBox.AppendText(text);
|
||||
this.automaticContentBox.ScrollBars = RichTextBoxScrollBars.None;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -899,5 +900,8 @@
|
||||
|
||||
Appsettings.SaveSettings();
|
||||
}
|
||||
|
||||
public void InvokeOnUIThread(Action action)
|
||||
=> this.Invoke(action);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
double GetAverageTOF();
|
||||
|
||||
void StartRecording();
|
||||
|
||||
void InvokeOnUIThread(Action action);
|
||||
}
|
||||
|
||||
partial class AutomaticTemperatureCalibration
|
||||
@@ -60,6 +62,7 @@
|
||||
};
|
||||
this.startTimer.Elapsed += this.StartMessuring;
|
||||
|
||||
this.StartMessuring(null, null);
|
||||
this.startTimer.Start();
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -96,14 +99,17 @@
|
||||
{
|
||||
try
|
||||
{
|
||||
var temp = this.temperatureSource.GetTemperature();
|
||||
var avgTOF = this.tempMeterForm.GetAverageTOF();
|
||||
var messurement = $"{this.pcbId};{DateTime.Now:yyyy-MM-dd HH:mm:ss:fff};{temp:0.00};{avgTOF:0.0000000000}";
|
||||
this.tempMeterForm.InvokeOnUIThread(() =>
|
||||
{
|
||||
var temp = this.temperatureSource.GetTemperature();
|
||||
var avgTOF = this.tempMeterForm.GetAverageTOF();
|
||||
var messurement = $"{this.pcbId};{DateTime.Now:yyyy-MM-dd HH:mm:ss:fff};{temp:0.00};{avgTOF:0.0000000000}";
|
||||
|
||||
File.AppendAllText(this.messurementsFile, $"{messurement}{Environment.NewLine}");
|
||||
File.AppendAllText(this.messurementsFile, $"{messurement}{Environment.NewLine}");
|
||||
|
||||
this.tempMeterForm.AddMessage(messurement);
|
||||
this.tempMeterForm.StartRecording();
|
||||
this.tempMeterForm.AddMessage(messurement);
|
||||
this.tempMeterForm.StartRecording();
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -13,23 +13,32 @@
|
||||
|
||||
[DllImport("GMH3x32E.dll")]
|
||||
unsafe public static extern Int16 GMH_Transmit(Int16 ini16DeviceAddress, Int16 ini16TransmitCode, Int16* refi16ptrPriority, double* refdblptrFloatValue, Int32* refi32ptrIntegerValue);
|
||||
|
||||
public TemperatureSource()
|
||||
=> UniversalOpenCom(Appsettings.GMHPort, 4800, 8, 0, 0);
|
||||
|
||||
public TemperatureSource()
|
||||
{
|
||||
UniversalOpenCom(Appsettings.GMHPort, 4800, 8, 0, 0);
|
||||
}
|
||||
|
||||
public double GetTemperature()
|
||||
{
|
||||
var result = default(short);
|
||||
var priority = default(short);
|
||||
var temperature = double.MinValue;
|
||||
var value = default(int);
|
||||
|
||||
unsafe
|
||||
try
|
||||
{
|
||||
result = GMH_Transmit(1, 0, &priority, &temperature, &value);
|
||||
}
|
||||
var result = default(short);
|
||||
var priority = default(short);
|
||||
var temperature = double.MinValue;
|
||||
var value = default(int);
|
||||
|
||||
return temperature;
|
||||
unsafe
|
||||
{
|
||||
result = GMH_Transmit(1, 0, &priority, &temperature, &value);
|
||||
}
|
||||
|
||||
return temperature;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
||||
Reference in New Issue
Block a user