Fix gestione chiusura thread discovery x setup e active
This commit is contained in:
@@ -74,6 +74,16 @@ namespace Thermo.Active.Thermocamera
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// chiusura metodi legati a ThermoCam (discovery e connessione)
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
TCamLive.stopDiscovery();
|
||||
TCamLive.DisconnectCamera();
|
||||
TCamLive.DisposeCamera();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce lettura di tutti i punti richiesti (es centroidi riscaldi)
|
||||
/// </summary>
|
||||
|
||||
@@ -385,6 +385,11 @@ public static class ThreadsFunctions
|
||||
{
|
||||
ncAdapter.Dispose();
|
||||
}
|
||||
finally
|
||||
{
|
||||
// chiudo thermocam
|
||||
TCCom.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public static void ManageLibraryError(CmsError libraryError)
|
||||
|
||||
Generated
+32
-4
@@ -83,6 +83,8 @@
|
||||
this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.timerUI = new System.Windows.Forms.Timer(this.components);
|
||||
this.lblMs = new System.Windows.Forms.Label();
|
||||
this.btnExportConfig = new System.Windows.Forms.Button();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.statusStrip1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pBoxA)).BeginInit();
|
||||
@@ -97,6 +99,7 @@
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
|
||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.fileToolStripMenuItem,
|
||||
this.cameraToolStripMenuItem});
|
||||
@@ -144,6 +147,7 @@
|
||||
//
|
||||
// statusStrip1
|
||||
//
|
||||
this.statusStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
|
||||
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.toolStripConnectionStatus,
|
||||
this.progBar,
|
||||
@@ -186,6 +190,7 @@
|
||||
this.panelCmd.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.panelCmd.BackColor = System.Drawing.SystemColors.ControlDark;
|
||||
this.panelCmd.Controls.Add(this.btnExportConfig);
|
||||
this.panelCmd.Controls.Add(this.groupBox5);
|
||||
this.panelCmd.Controls.Add(this.groupBox4);
|
||||
this.panelCmd.Controls.Add(this.groupBox3);
|
||||
@@ -199,6 +204,7 @@
|
||||
//
|
||||
// groupBox5
|
||||
//
|
||||
this.groupBox5.Controls.Add(this.lblMs);
|
||||
this.groupBox5.Controls.Add(this.txtSPeriod);
|
||||
this.groupBox5.Controls.Add(this.chkSaveAll);
|
||||
this.groupBox5.Controls.Add(this.chkLive);
|
||||
@@ -211,11 +217,11 @@
|
||||
//
|
||||
// txtSPeriod
|
||||
//
|
||||
this.txtSPeriod.Location = new System.Drawing.Point(120, 37);
|
||||
this.txtSPeriod.Location = new System.Drawing.Point(99, 18);
|
||||
this.txtSPeriod.Name = "txtSPeriod";
|
||||
this.txtSPeriod.Size = new System.Drawing.Size(49, 20);
|
||||
this.txtSPeriod.TabIndex = 21;
|
||||
this.txtSPeriod.Text = "100";
|
||||
this.txtSPeriod.Text = "200";
|
||||
this.txtSPeriod.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
|
||||
//
|
||||
// chkSaveAll
|
||||
@@ -223,9 +229,9 @@
|
||||
this.chkSaveAll.AutoSize = true;
|
||||
this.chkSaveAll.Location = new System.Drawing.Point(8, 39);
|
||||
this.chkSaveAll.Name = "chkSaveAll";
|
||||
this.chkSaveAll.Size = new System.Drawing.Size(96, 17);
|
||||
this.chkSaveAll.Size = new System.Drawing.Size(51, 17);
|
||||
this.chkSaveAll.TabIndex = 20;
|
||||
this.chkSaveAll.Text = "Save every ms";
|
||||
this.chkSaveAll.Text = "Save";
|
||||
this.chkSaveAll.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// chkLive
|
||||
@@ -625,6 +631,26 @@
|
||||
//
|
||||
this.timerUI.Tick += new System.EventHandler(this.timerUI_Tick);
|
||||
//
|
||||
// lblMs
|
||||
//
|
||||
this.lblMs.AutoSize = true;
|
||||
this.lblMs.Location = new System.Drawing.Point(149, 21);
|
||||
this.lblMs.Name = "lblMs";
|
||||
this.lblMs.Size = new System.Drawing.Size(20, 13);
|
||||
this.lblMs.TabIndex = 22;
|
||||
this.lblMs.Text = "ms";
|
||||
//
|
||||
// btnExportConfig
|
||||
//
|
||||
this.btnExportConfig.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.btnExportConfig.Location = new System.Drawing.Point(8, 491);
|
||||
this.btnExportConfig.Name = "btnExportConfig";
|
||||
this.btnExportConfig.Size = new System.Drawing.Size(177, 64);
|
||||
this.btnExportConfig.TabIndex = 20;
|
||||
this.btnExportConfig.Text = "Export Config";
|
||||
this.btnExportConfig.UseVisualStyleBackColor = true;
|
||||
this.btnExportConfig.Click += new System.EventHandler(this.btnExportConfig_Click);
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
@@ -725,6 +751,8 @@
|
||||
private System.Windows.Forms.Button btnDeleteOlder;
|
||||
private System.Windows.Forms.TextBox txtMaxHours;
|
||||
private System.Windows.Forms.Timer timerUI;
|
||||
private System.Windows.Forms.Button btnExportConfig;
|
||||
private System.Windows.Forms.Label lblMs;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -201,6 +201,12 @@ namespace Thermo.Cam.Setup
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public object ConfigurationManager { get; private set; }
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void btnDeleteOlder_Click(object sender, EventArgs e)
|
||||
@@ -210,6 +216,20 @@ namespace Thermo.Cam.Setup
|
||||
TCamCtrl.cleanDataDir(maxHours);
|
||||
}
|
||||
|
||||
private void btnExportConfig_Click(object sender, EventArgs e)
|
||||
{
|
||||
// effettua esportazione config in area ThermoActive
|
||||
string ThermoConfPath = System.Configuration.ConfigurationManager.AppSettings["ThermoConfPath"];
|
||||
if (!Directory.Exists(ThermoConfPath))
|
||||
{
|
||||
Directory.CreateDirectory(ThermoConfPath);
|
||||
}
|
||||
// salvo conf corrente
|
||||
TCamCtrl.saveConf();
|
||||
// salvo in folder target
|
||||
TCamCtrl.saveConf(ThermoConfPath);
|
||||
}
|
||||
|
||||
private void btnLoad_Click(object sender, EventArgs e)
|
||||
{
|
||||
// "" --> carica ultima scattata (altrimenti nome)
|
||||
@@ -350,7 +370,11 @@ namespace Thermo.Cam.Setup
|
||||
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
timerUI.Stop();
|
||||
TCamCtrl.stopDiscovery();
|
||||
TCamCtrl.DisconnectCamera();
|
||||
TCamCtrl.DisposeCamera();
|
||||
//this.Dispose(true);
|
||||
//this.Close();
|
||||
}
|
||||
|
||||
private void MainForm_Load(object sender, EventArgs e)
|
||||
@@ -584,7 +608,7 @@ namespace Thermo.Cam.Setup
|
||||
}
|
||||
}
|
||||
// avanzo prog bar
|
||||
progBar.Increment(3);
|
||||
progBar.Increment(5);
|
||||
if (progBar.Value >= progBar.Maximum)
|
||||
{
|
||||
progBar.Value = 0;
|
||||
|
||||
@@ -65,6 +65,7 @@
|
||||
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
|
||||
+15
-10
@@ -1,12 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" /></startup>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
<appSettings>
|
||||
<add key="ThermoConfPath" value="C:\CMS\ThermoActive\ThermoActive\Config\" />
|
||||
</appSettings>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
|
||||
</startup>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
+40
-11
@@ -443,20 +443,21 @@ namespace Thermo.Cam.Utils
|
||||
|
||||
public void discoveryCamera()
|
||||
{
|
||||
try {
|
||||
// se no connesso così prosegue...
|
||||
if (!IRCam.ThermoCamera.IsConnected)
|
||||
try
|
||||
{
|
||||
DiscoThread.CameraAddress = currConf.CameraAddress;
|
||||
DiscoThread.CameraName = currConf.CameraName;
|
||||
if (DiscoThread.doAutoConnect)
|
||||
// se no connesso così prosegue...
|
||||
if (!IRCam.ThermoCamera.IsConnected)
|
||||
{
|
||||
// avvio
|
||||
DiscoThread.Start();
|
||||
DiscoThread.CameraAddress = currConf.CameraAddress;
|
||||
DiscoThread.CameraName = currConf.CameraName;
|
||||
if (DiscoThread.doAutoConnect)
|
||||
{
|
||||
// avvio
|
||||
DiscoThread.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception exc)
|
||||
catch (Exception exc)
|
||||
{
|
||||
Console.WriteLine($"EXCEPTION discoveryCamera: {Environment.NewLine}{exc}");
|
||||
}
|
||||
@@ -769,7 +770,7 @@ namespace Thermo.Cam.Utils
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Salva su file il file di conf corrente
|
||||
/// Salva il file di conf corrente (in path default)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool saveConf()
|
||||
@@ -786,6 +787,34 @@ namespace Thermo.Cam.Utils
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Salva su file nella dir richiesta il file di conf corrente
|
||||
/// </summary>
|
||||
/// <param name="destPath">directory destinazione x conf</param>
|
||||
/// <returns></returns>
|
||||
public bool saveConf(string destPath)
|
||||
{
|
||||
bool answ = false;
|
||||
try
|
||||
{
|
||||
string rawData = JsonConvert.SerializeObject(currConf, Formatting.Indented);
|
||||
File.WriteAllText($"{destPath}\\{confFileName}", rawData);
|
||||
answ = true;
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// fermo discovery camera
|
||||
/// </summary>
|
||||
public void stopDiscovery()
|
||||
{
|
||||
// fermo camera discovery
|
||||
DiscoThread.Stop();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Acquisisce immagine da FLIR Cam
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user