Stopping TBF program optimized, ModelessActivityForm used, rtpListenerThread.Join(.) in Camera shortened to 200 ms, ver. 2.17.680

This commit is contained in:
Milan Hanajik
2017-09-29 08:19:59 +02:00
parent 9fa025caa4
commit ed3fc330ab
9 changed files with 81 additions and 293 deletions
@@ -231,6 +231,9 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
}
else
{
rtpUdpLocalPort = RtpUdpPortBase + 2 * cameraIdx;
StartRtpListener(NetAdapter.IPAddress, rtpUdpLocalPort);
UiBridge.Bridge.OnCameraInfo(this.cameraIdx, string.Format("{0} s/n {1} was not detected", Name, CameraCfg.HardwareAddress));
log.FatalFormat("'{0}' with address {1} not detected", Name, CameraCfg.HardwareAddress);
}
@@ -248,7 +251,7 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
}
if (scpThread != null) scpThread.Join(500);
if (rtpListenerThread != null) rtpListenerThread.Join(1000);
if (rtpListenerThread != null) rtpListenerThread.Join(200);
if (rtpUdpClient != null)
{
-69
View File
@@ -1,69 +0,0 @@
///
/// Copyright (c) 2013-2015 Sensus Metering Systems
///
namespace TBF.Forms
{
partial class ClosingProgram
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.Location = new System.Drawing.Point(60, 68);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(305, 24);
this.label1.TabIndex = 0;
this.label1.Text = "Closing the Test Bench Framework";
//
// ClosingProgram
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.PeachPuff;
this.ClientSize = new System.Drawing.Size(487, 161);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "ClosingProgram";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Closing the Test Bench Framework";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
}
}
@@ -1,42 +0,0 @@
///
/// Copyright (c) 2013-2017 Sensus Metering Systems
///
using System;
using System.Drawing;
using System.Windows.Forms;
using TBF.Resources;
namespace TBF.Forms
{
public partial class ClosingProgram : Form
{
Timer timer;
public ClosingProgram()
{
InitializeComponent();
label1.Text = Strings.Closing_Test_Bench_Framework;
float textWidth = Graphics.FromImage(new Bitmap(1, 1)).MeasureString(label1.Text, label1.Font).Width;
Width = (int)textWidth + 120; /// Form width calculated from the text width
timer = new Timer();
timer.Interval = 1000;
timer.Tick += new EventHandler(timer_Tick);
timer.Start();
}
void timer_Tick(object sender, EventArgs args)
{
if (!TBF.BenchControl.StateMachine.Running)
{
timer.Stop();
timer.Dispose();
DialogResult = DialogResult.OK;
Close();
}
}
}
}
@@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -27,6 +27,7 @@ namespace TBF.Forms
public string FontFamily;
public int FontSize;
public FontStyle FontStyle;
public bool StartActivityHandler;
/// <summary>
@@ -61,13 +62,17 @@ namespace TBF.Forms
float textWidth = Graphics.FromImage(new Bitmap(1, 1)).MeasureString(label1.Text, label1.Font).Width;
float textHeight = Graphics.FromImage(new Bitmap(1, 1)).MeasureString(label1.Text, label1.Font).Height;
Width = (int)textWidth + 120; /// Form width calculated from the text width
Height += (int)textHeight; /// Form width calculated from the text width
Bridge.ActivityHandler += delegate(object sndr, ActivityEventArgs args)
{
if (InvokeRequired) { Invoke(new EventHandler<ActivityEventArgs>(OnActivity), sndr, args); }
else OnActivity(sndr, args);
};
if (StartActivityHandler)
{
Height += (int)textHeight; /// Form height calculated from the text width
Bridge.ActivityHandler += delegate(object sndr, ActivityEventArgs args)
{
if (InvokeRequired) { Invoke(new EventHandler<ActivityEventArgs>(OnActivity), sndr, args); }
else OnActivity(sndr, args);
};
}
}
void OnActivity(object sender, ActivityEventArgs args)
+35 -35
View File
@@ -28,41 +28,41 @@
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.activityStatusLabel = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(64, 29);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(0, 13);
this.label1.TabIndex = 0;
//
// activityStatusLabel
//
this.activityStatusLabel.AutoSize = true;
this.activityStatusLabel.Location = new System.Drawing.Point(64, 85);
this.activityStatusLabel.Name = "activityStatusLabel";
this.activityStatusLabel.Size = new System.Drawing.Size(0, 13);
this.activityStatusLabel.TabIndex = 1;
//
// ModelessActivityForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.OliveDrab;
this.ClientSize = new System.Drawing.Size(284, 113);
this.Controls.Add(this.activityStatusLabel);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.MinimizeBox = false;
this.Name = "ModelessActivityForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Load += new System.EventHandler(this.ModelessForm_Load);
this.ResumeLayout(false);
this.PerformLayout();
this.label1 = new System.Windows.Forms.Label();
this.activityStatusLabel = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(64, 29);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(0, 13);
this.label1.TabIndex = 0;
//
// activityStatusLabel
//
this.activityStatusLabel.AutoSize = true;
this.activityStatusLabel.Location = new System.Drawing.Point(64, 85);
this.activityStatusLabel.Name = "activityStatusLabel";
this.activityStatusLabel.Size = new System.Drawing.Size(0, 13);
this.activityStatusLabel.TabIndex = 1;
//
// ModelessActivityForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.OliveDrab;
this.ClientSize = new System.Drawing.Size(569, 113);
this.Controls.Add(this.activityStatusLabel);
this.Controls.Add(this.label1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.MinimizeBox = false;
this.Name = "ModelessActivityForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Load += new System.EventHandler(this.ModelessForm_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
+29 -9
View File
@@ -163,13 +163,14 @@ namespace TBF
if (Config.Data.CurrentBench.IsRealBench && !benchInitializationFailed)
{
var form = new TBF.Forms.ModelessActivityForm()
{
Message = Strings.Starting_system,
FontFamily = "Arial",
FontSize = 24,
FontStyle = FontStyle.Regular,
BackgroundColor = Color.OliveDrab /// or Color.YellowGreen
};
{
Message = Strings.Starting_system,
FontFamily = "Arial",
FontSize = 24,
FontStyle = FontStyle.Regular,
BackgroundColor = Color.OliveDrab, /// or Color.YellowGreen
StartActivityHandler = true,
};
Thread formThread = new Thread(() => form.ShowDialog());
formThread.Start();
@@ -528,10 +529,29 @@ namespace TBF
MessageBoxButtons.YesNo,
MessageBoxIcon.Question))
{
/// Show 'Closing_Test_Bench_Framework' modeless window in separate thread
var form = new TBF.Forms.ModelessActivityForm()
{
Message = Strings.Closing_Test_Bench_Framework,
FontFamily = "Arial",
FontSize = 24,
FontStyle = FontStyle.Regular,
BackgroundColor = Color.PeachPuff,
StartActivityHandler = false,
};
Thread formThread = new Thread(() => form.ShowDialog());
formThread.Start();
/// Stop the system
BenchControl.StateMachine.Stop();
BenchControl.StateMachine.StopDevices();
BenchControl.StateMachine.StopDevices();
UiBridge.Bridge.OnEmergencyStopChanged(this, UiBridge.EmergencyStopEventArgs.State.CloseForm);
new Forms.ClosingProgram().ShowDialog();
/// Close 'Closing_Test_Bench_Framework' modeless window
form.CloseForm(null, new EventArgs());
formThread.Join();
/// Close the main window
DialogResult = DialogResult.OK;
Close();
return;
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("2.17.679.1")]
[assembly: AssemblyFileVersion("2.17.679.1")]
[assembly: AssemblyVersion("2.17.680.1")]
[assembly: AssemblyFileVersion("2.17.680.1")]
-9
View File
@@ -1395,12 +1395,6 @@
<Compile Include="Boxes\FloatBox.cs" />
<Compile Include="Boxes\IBox.cs" />
<Compile Include="Boxes\IntBox.cs" />
<Compile Include="Forms\ClosingProgram.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\ClosingProgram.Designer.cs">
<DependentUpon>ClosingProgram.cs</DependentUpon>
</Compile>
<Compile Include="Forms\EmergencyStopForm.cs">
<SubType>Form</SubType>
</Compile>
@@ -2272,9 +2266,6 @@
<EmbeddedResource Include="Forms\AboutDlg.ru.resx">
<DependentUpon>AboutDlg.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\ClosingProgram.resx">
<DependentUpon>ClosingProgram.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\DatabaseSettingsDlg.resx">
<DependentUpon>DatabaseSettingsDlg.cs</DependentUpon>
</EmbeddedResource>