Fixed Step-Server & Client closing error + Siemens Nc bug fixes + Machine-Info data exchange fix

This commit is contained in:
CMS3762\carminatini
2018-01-29 17:10:30 +01:00
parent 3e8874090e
commit ecaff5fb7f
16 changed files with 253 additions and 136 deletions
+1 -10
View File
@@ -96,15 +96,7 @@ namespace CMS_Client.Browser_Tools
return;
//Invoke method if is needed or call the method in STD mode
if (mainForm.InvokeRequired)
mainForm.Invoke((MethodInvoker)delegate () {
mainForm.Close();
});
else
{
mainForm.Close();
}
mainForm.Close();
}
#endregion
@@ -161,7 +153,6 @@ namespace CMS_Client.Browser_Tools
public void forceStepFocus(object sender, CfrV8HandlerExecuteEventArgs e)
{
Debug.WriteLine("Forced");
NcWindow.ForceStepFocus();
}
+2
View File
@@ -62,6 +62,8 @@ namespace CMS_Client
//Run the Main-Browser Form
Application.Run(new MainForm());
CfxRuntime.Shutdown();
NcWindow.ShowTaskBar();
+71 -52
View File
@@ -117,10 +117,7 @@ namespace CMS_Client.View
//Invoke method if is needed or call the method in STD mode
if (!this.IsDisposed)
{
CfxRuntime.Shutdown();
//Close the NC HMI && Stop Following Nc
if (Config.VendorHmiConfig.Enabled)
{
@@ -373,16 +370,19 @@ namespace CMS_Client.View
private void ShowWindow()
{
//Invoke method if is needed or call the method in STD mode
if (this.InvokeRequired)
this.Invoke((MethodInvoker)delegate () {
if (!this.IsDisposed)
{
if (this.InvokeRequired)
this.Invoke((MethodInvoker)delegate ()
{
this.WindowState = FormWindowState.Maximized;
this.Opacity = 1.0;
});
else
{
this.WindowState = FormWindowState.Maximized;
this.Opacity = 1.0;
});
else
{
this.WindowState = FormWindowState.Maximized;
this.Opacity = 1.0;
}
}
}
@@ -392,14 +392,19 @@ namespace CMS_Client.View
private void HideLoadingWindow()
{
//Invoke method if is needed or call the method in STD mode
if (this.InvokeRequired)
this.Invoke((MethodInvoker)delegate () {
LdFrm.Hide();
});
else
if (!this.IsDisposed)
{
LdFrm.Hide();
if (this.InvokeRequired)
this.Invoke((MethodInvoker)delegate ()
{
LdFrm.Hide();
});
else
{
LdFrm.Hide();
}
}
}
@@ -409,17 +414,21 @@ namespace CMS_Client.View
private void ShowLoading(String Message)
{
//Invoke method if is needed or call the method in STD mode
if (this.InvokeRequired)
this.Invoke((MethodInvoker)delegate () {
if (!this.IsDisposed)
{
if (this.InvokeRequired)
this.Invoke((MethodInvoker)delegate ()
{
//Set Message Status
LdFrm.Show(Message);
LdFrm.Focus();
});
else
{
//Set Message Status
LdFrm.Show(Message);
LdFrm.Focus();
});
else
{
//Set Message Status
LdFrm.Show(Message);
}
}
}
@@ -449,11 +458,13 @@ namespace CMS_Client.View
//Invoke method if is needed or call the method in STD mode
if (this.InvokeRequired)
this.Invoke((MethodInvoker)delegate () { this.Text = Title; });
else
this.Text = Title;
if (!this.IsDisposed)
{
if (this.InvokeRequired)
this.Invoke((MethodInvoker)delegate () { this.Text = Title; });
else
this.Text = Title;
}
}
@@ -464,23 +475,27 @@ namespace CMS_Client.View
return;
//Invoke method if is needed or call the method in STD mode
if (this.InvokeRequired)
this.Invoke((MethodInvoker)delegate () {
if(!this.IsDisposed)
{
if (this.InvokeRequired)
this.Invoke((MethodInvoker)delegate () {
this.Owner = null;
this.NcFrm.Owner = this;
this.NcFrm.TopMost = true;
this.NcFrm.TopMost = false;
});
else
{
this.Owner = null;
this.NcFrm.Owner = this;
this.NcFrm.TopMost = true;
this.NcFrm.TopMost = false;
});
else
{
this.Owner = null;
this.NcFrm.Owner = this;
this.NcFrm.TopMost = true;
this.NcFrm.TopMost = false;
}
}
}
//Hide NC Method
@@ -490,18 +505,22 @@ namespace CMS_Client.View
return;
//Invoke method if is needed or call the method in STD mode
if (this.InvokeRequired)
this.Invoke((MethodInvoker)delegate () {
if (!this.IsDisposed)
{
if (this.InvokeRequired)
this.Invoke((MethodInvoker)delegate ()
{
this.NcFrm.Owner = null;
this.TopMost = true;
this.TopMost = false;
});
else
{
this.NcFrm.Owner = null;
this.TopMost = true;
this.TopMost = false;
});
else
{
this.NcFrm.Owner = null;
this.TopMost = true;
this.TopMost = false;
}
}
}
Binary file not shown.
+1 -1
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<ncConfig>
<ncVendor>DEMO</ncVendor> <!-- NO_NC/DEMO/FANUC/SIEMENS/OSAI -->
<ncVendor>SIEMENS</ncVendor> <!-- NO_NC/DEMO/FANUC/SIEMENS/OSAI -->
<showNcHMI>true</showNcHMI>
<ncIpAddress>localhost</ncIpAddress>
<ncPort>8080</ncPort>
+14 -4
View File
@@ -17,7 +17,7 @@ public static class ThreadsFunctions
private static long ReadNcGenericInfoTimer = 0, ReadNcGenericInfoTimes = 0;
private static long ReadAxesTimer = 0, ReadAxesTimes = 0;
private static long ReadPowerOnTimer = 0, ReadPowerOnTimes = 0;
private static Thread ConnThread;
#region Nc Threads
public static void ReadAlarms()
@@ -221,14 +221,21 @@ public static class ThreadsFunctions
reconnectionIsRunning = true;
// Start reconnection thread
Thread t = new Thread(() =>
ConnThread = new Thread(() =>
WillReconnect()
);
t.Start();
ConnThread.Start();
}
}
public static void AbortNcConnection()
{
if (ConnThread != null && ConnThread.IsAlive)
ConnThread.Abort();
}
public static void ManageLibraryError(CmsError cmsError)
{
switch (cmsError.errorCode)
@@ -254,9 +261,12 @@ public static class ThreadsFunctions
case CMS_ERROR_CODES.NC_LANGUAGE_ERROR:
break;
case CMS_ERROR_CODES.SIEMENS_ENVIRONMENT_NOT_FOUND:
case CMS_ERROR_CODES.SIEMENS_HMI_NOT_RUNNING:
Manage(ERROR_LEVEL.FATAL, cmsError.message);
break;
case CMS_ERROR_CODES.SIEMENS_HMI_NOT_RUNNING:
Manage(ERROR_LEVEL.WARNING, cmsError.message);
TryNcConnection(); // If not connected try reconnection
break;
}
}
+14 -1
View File
@@ -32,7 +32,7 @@ namespace Step.Core
public static void Start()
{
ThreadsFunctions.TryNcConnection();
ThreadsFunctions.TryNcConnection();
}
public static void StartWorkers()
@@ -77,6 +77,19 @@ namespace Step.Core
RunningThreadStatus.Add("TryNcConnection", "---");
MessageServices.Current.Publish(SEND_THREADS_STATUS, null, RunningThreadStatus);
}
public static void Close()
{
//Abort Nc Read Threads
RunningThreadsList.ForEach(thread =>
{
thread.Abort();
});
//Abort Connect Thread
ThreadsFunctions.AbortNcConnection();
}
}
}
+43 -5
View File
@@ -61,6 +61,7 @@ namespace Step.UI
this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.stopServerButton = new MetroFramework.Controls.MetroButton();
this.TestJSButton = new MetroFramework.Controls.MetroButton();
this.TXTstatus = new MetroFramework.Controls.MetroTextBox();
this.NotifyIconMenu.SuspendLayout();
this.metroTabControl1.SuspendLayout();
this.NCInfo.SuspendLayout();
@@ -106,10 +107,10 @@ namespace Step.UI
//
this.metroTabControl1.Controls.Add(this.NCInfo);
this.metroTabControl1.Controls.Add(this.ThreadsInfo);
this.metroTabControl1.Location = new System.Drawing.Point(12, 50);
this.metroTabControl1.Location = new System.Drawing.Point(12, 56);
this.metroTabControl1.Name = "metroTabControl1";
this.metroTabControl1.SelectedIndex = 0;
this.metroTabControl1.Size = new System.Drawing.Size(328, 329);
this.metroTabControl1.Size = new System.Drawing.Size(328, 323);
this.metroTabControl1.TabIndex = 7;
this.metroTabControl1.UseSelectable = true;
//
@@ -137,7 +138,7 @@ namespace Step.UI
this.NCInfo.HorizontalScrollbarSize = 10;
this.NCInfo.Location = new System.Drawing.Point(4, 38);
this.NCInfo.Name = "NCInfo";
this.NCInfo.Size = new System.Drawing.Size(320, 287);
this.NCInfo.Size = new System.Drawing.Size(320, 281);
this.NCInfo.TabIndex = 0;
this.NCInfo.Text = "NC Info";
this.NCInfo.VerticalScrollbarBarColor = true;
@@ -556,11 +557,48 @@ namespace Step.UI
this.TestJSButton.UseSelectable = true;
this.TestJSButton.Click += new System.EventHandler(this.TestJSButton_Click);
//
// TXTstatus
//
this.TXTstatus.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
//
//
//
this.TXTstatus.CustomButton.Image = null;
this.TXTstatus.CustomButton.Location = new System.Drawing.Point(334, 1);
this.TXTstatus.CustomButton.Name = "";
this.TXTstatus.CustomButton.Size = new System.Drawing.Size(21, 21);
this.TXTstatus.CustomButton.Style = MetroFramework.MetroColorStyle.Blue;
this.TXTstatus.CustomButton.TabIndex = 1;
this.TXTstatus.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light;
this.TXTstatus.CustomButton.UseSelectable = true;
this.TXTstatus.CustomButton.Visible = false;
this.TXTstatus.Enabled = false;
this.TXTstatus.Lines = new string[] {
"..."};
this.TXTstatus.Location = new System.Drawing.Point(-1, 434);
this.TXTstatus.MaxLength = 32767;
this.TXTstatus.Name = "TXTstatus";
this.TXTstatus.PasswordChar = '\0';
this.TXTstatus.ReadOnly = true;
this.TXTstatus.ScrollBars = System.Windows.Forms.ScrollBars.None;
this.TXTstatus.SelectedText = "";
this.TXTstatus.SelectionLength = 0;
this.TXTstatus.SelectionStart = 0;
this.TXTstatus.ShortcutsEnabled = true;
this.TXTstatus.Size = new System.Drawing.Size(356, 23);
this.TXTstatus.TabIndex = 8;
this.TXTstatus.Text = "...";
this.TXTstatus.UseSelectable = true;
this.TXTstatus.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109)))));
this.TXTstatus.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel);
//
// ServerControlWindow
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(350, 446);
this.ClientSize = new System.Drawing.Size(350, 457);
this.Controls.Add(this.TXTstatus);
this.Controls.Add(this.stopServerButton);
this.Controls.Add(this.metroTabControl1);
this.Controls.Add(this.openUiButton);
@@ -574,7 +612,6 @@ namespace Step.UI
this.Resizable = false;
this.ShadowType = MetroFramework.Forms.MetroFormShadowType.AeroShadow;
this.ShowInTaskbar = false;
this.Text = "CMS Step";
this.Theme = MetroFramework.MetroThemeStyle.Default;
this.NotifyIconMenu.ResumeLayout(false);
this.metroTabControl1.ResumeLayout(false);
@@ -615,5 +652,6 @@ namespace Step.UI
private MetroFramework.Controls.MetroListView LISTThreadStatus;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
private MetroFramework.Controls.MetroTextBox TXTstatus;
}
}
+87 -58
View File
@@ -19,10 +19,21 @@ namespace Step.UI
String HomePageUI;
String TestJSPageUI;
bool ncStatus = false;
List<RegistrationInfo> MVVMListeners;
public ServerControlWindow()
{
InitializeComponent();
//Begin the update
LISTThreadStatus.BeginUpdate();
//clear the List
LISTThreadStatus.Items.Clear();
//Add all items
LISTThreadStatus.Items.Add(new ListViewItem(new string[] { "TryNcConnection", "---" }));
//End the update
LISTThreadStatus.EndUpdate();
HomePageUI = "http://localhost:" + ServerStartupConfig.ServerPort.ToString() + "/index.html";
TestJSPageUI = "http://localhost:" + ServerStartupConfig.ServerPort.ToString() + "/Testjavascript//index.html";
@@ -92,6 +103,10 @@ namespace Step.UI
private void StopServerItem_Click(object sender, EventArgs e)
{
//Unsubscrube MVVM threads
foreach(RegistrationInfo Info in MVVMListeners)
MessageServices.Current.UnSubscribe(Info);
MessageServices.Current.Publish("StopServer");
}
@@ -117,23 +132,32 @@ namespace Step.UI
private void TestJSButton_Click(object sender, EventArgs e)
{
StartCMSClient(TestJSPageUI);
}
private void InitializeMessageListeners()
{
MessageServices.Current.Subscribe(SEND_MESSAGE, (a, b) =>
MVVMListeners = new List<RegistrationInfo>();
MVVMListeners.Add(MessageServices.Current.Subscribe(SEND_MESSAGE, (a, b) =>
{
// Cast object to ErrorMessageModel
ErrorMessageModel message = (ErrorMessageModel)a;
// If error has a fatal level, icon must be error
message.ErrorLevel = message.ErrorLevel > (int)ERROR_LEVEL.ERROR ? (int)ERROR_LEVEL.ERROR : message.ErrorLevel;
// Open BalloonTip with data
StepNotifyIcon.ShowBalloonTip(1000, message.Title, message.Message, (ToolTipIcon)message.ErrorLevel);
});
if (!this.IsDisposed)
this.Invoke((MethodInvoker)delegate ()
{
// Open BalloonTip with data
StepNotifyIcon.ShowBalloonTip(1000, message.Title, message.Message, (ToolTipIcon)message.ErrorLevel);
MessageServices.Current.Subscribe(SEND_NC_STATUS, (a, b) =>
//ShowMessage on UI
TXTstatus.Text = "[" + DateTime.Now.ToString("T") + "] " + message.Message;
});
}));
MVVMListeners.Add(MessageServices.Current.Subscribe(SEND_NC_STATUS, (a, b) =>
{
bool newNcStatus = (bool)a;
@@ -150,79 +174,84 @@ namespace Step.UI
message = "Comunication started";
toolTipIcon = ToolTipIcon.Info;
}
this.Invoke((MethodInvoker)delegate () {
StepNotifyIcon.ShowBalloonTip(1000, title, message, toolTipIcon);
});
if (!this.IsDisposed)
this.Invoke((MethodInvoker)delegate () {
StepNotifyIcon.ShowBalloonTip(1000, title, message, toolTipIcon);
TXTstatus.Text = "[" + DateTime.Now.ToString("T") + "] " + title;
});
}
if (ncStatus)
this.Invoke((MethodInvoker)delegate ()
{
StepNotifyIcon.Icon = Properties.Resources.Step_Icon;
});
if (!this.IsDisposed)
this.Invoke((MethodInvoker)delegate ()
{
StepNotifyIcon.Icon = Properties.Resources.Step_Icon;
});
else
{
this.Invoke((MethodInvoker)delegate ()
{
TXTType.Text = "";
TXTName.Text = "";
TXTNcSerial.Text = "";
TXTCMSMach.Text = "";
TXTSftVers.Text = "";
TXTNCProc.Text = "";
TXTTime.Text = "";
TXTLang.Text = "";
StepNotifyIcon.Icon = Properties.Resources.Step_Disconnected;
});
if(!this.IsDisposed)
this.Invoke((MethodInvoker)delegate ()
{
TXTType.Text = "";
TXTName.Text = "";
TXTNcSerial.Text = "";
TXTCMSMach.Text = "";
TXTSftVers.Text = "";
TXTNCProc.Text = "";
TXTTime.Text = "";
TXTLang.Text = "";
StepNotifyIcon.Icon = Properties.Resources.Step_Disconnected;
});
}
//Other type
this.Invoke((MethodInvoker)delegate () {
CHNcConnected.Checked = ncStatus;
});
if (!this.IsDisposed)
this.Invoke((MethodInvoker)delegate () {
CHNcConnected.Checked = ncStatus;
});
}));
});
MessageServices.Current.Subscribe(SEND_THREADS_STATUS, (a, b) =>
{
MVVMListeners.Add(MessageServices.Current.Subscribe(SEND_THREADS_STATUS, (a, b) =>
{
//Other type
this.Invoke((MethodInvoker)delegate () {
if (!this.IsDisposed)
this.Invoke((MethodInvoker)delegate () {
//Begin the update
LISTThreadStatus.BeginUpdate();
//Begin the update
LISTThreadStatus.BeginUpdate();
//clear the List
LISTThreadStatus.Items.Clear();
//clear the List
LISTThreadStatus.Items.Clear();
//Add all items
foreach (KeyValuePair<string, String> Thr in (Dictionary<String, String>)a)
LISTThreadStatus.Items.Add(new ListViewItem(new string[] { Thr.Key, Thr.Value }));
//Add all items
foreach (KeyValuePair<string, String> Thr in (Dictionary<String, String>)a)
LISTThreadStatus.Items.Add(new ListViewItem(new string[] { Thr.Key, Thr.Value }));
//End the update
LISTThreadStatus.EndUpdate();
});
});
//End the update
LISTThreadStatus.EndUpdate();
});
}));
MessageServices.Current.Subscribe(SEND_GENERIC_DATA, (a, b) =>
MVVMListeners.Add(MessageServices.Current.Subscribe(SEND_GENERIC_DATA, (a, b) =>
{
DTONcGenericDataModel data = (DTONcGenericDataModel)a;
//Other type
this.Invoke((MethodInvoker)delegate () {
TXTType.Text = NcConfig.NcVendor;
TXTName.Text = data.NcModel;
TXTNcSerial.Text = data.SerialNumber;
TXTCMSMach.Text = data.CmsMachineIdNumber;
TXTSftVers.Text = data.NcSoftwareVersion;
TXTNCProc.Text = data.ProcessNumber.ToString();
TXTLang.Text = data.Language.EnglishName;
TXTTime.Text = data.DateTime.ToShortDateString() + " " + data.DateTime.ToShortTimeString();
});
});
if (!this.IsDisposed)
this.Invoke((MethodInvoker)delegate () {
TXTType.Text = NcConfig.NcVendor;
TXTName.Text = data.NcModel;
TXTNcSerial.Text = data.SerialNumber;
TXTCMSMach.Text = data.CmsMachineIdNumber;
TXTSftVers.Text = data.NcSoftwareVersion;
TXTNCProc.Text = data.ProcessNumber.ToString();
TXTLang.Text = data.Language.EnglishName;
TXTTime.Text = data.DateTime.ToShortDateString() + " " + data.DateTime.ToShortTimeString();
});
}));
}
}
+1 -1
View File
@@ -51,7 +51,7 @@ namespace Step
LogInfo("Application closed");
}
// Stop Threads
ThreadsHandler.Stop();
ThreadsHandler.Close();
// Stop messageservice listeners
ListenersHandler.Stop();
// Close WinForm
@@ -104,4 +104,10 @@
font-size:32px;
}
}
.machine-info{
min-width: 60px;
margin-left: 5px;
margin-right: 5px;
}
}
+5
View File
@@ -489,6 +489,11 @@ button.square {
#app > header .window-buttons .close {
font-size: 32px;
}
#app > header .machine-info {
min-width: 60px;
margin-left: 5px;
margin-right: 5px;
}
.ribbon-container {
height: 100%;
float: left;
@@ -3,7 +3,7 @@
<div class="content">
<h2>{{title}}</h2>
<div class="summary">
<span v-if="source">{{processid}} {{source}}</span>
<span v-if="source">{{source}} {{processid}}</span>
<time>{{date | date("DD/MM/YYYY hh:mm")}}</time>
</div>
</div>
@@ -12,6 +12,7 @@
<hr/>
<label>{{'machineinfo_model_nc' | localize('Modello Nc:')}} <strong>{{machineInfo.ncModel}}</strong></label>
<label>{{'machineinfo_serial_nc' | localize('Num. Seriale Nc:')}} <strong>{{machineInfo.ncSerialNumber}}</strong></label>
<label>{{'machineinfo_firmware_version' | localize('Versione software HMI:')}} <strong>{{machineInfo.firmwareVersion}}</strong></label>
<label>{{'machineinfo_plc_version' | localize('Versione Plc:')}} <strong>{{machineInfo.plcVersion}}</strong></label>
<label>{{'machineinfo_current_language' | localize('Lingua selezionata:')}} <strong>{{machineInfo.defaultLanguage}}</strong></label>
+4 -2
View File
@@ -20,13 +20,15 @@ export class machineService extends baseRestService {
machineName: result.machineModel,
firmwareVersion: result.ncSoftwareVersion,
machineSerialNumber: result.serialNumber,
machineSerialNumber: result.cmsMachineIdNumber,
installationDate: result.installationDate,
ncModel: result.ncModel,
ncSerialNumber: result.serialNumber,
processes: result.processNumber,
plcVersion: result.plcVersion,
cmsCoreVersion: result.coreLibraryVersion,
cmsServerVersion: result.serverVersion
} as MachineInfoModel)
@@ -47,7 +49,7 @@ export interface NCInfoModel {
machineModel: string,
dateTime: Date,
installationDate: Date,
machineNumber: string,
cmsMachineIdNumber: string,
processNumber: number,
ncModel: string,
plcVersion: string
+2 -1
View File
@@ -1,7 +1,7 @@
export interface MachineInfoModel {
machineSerialNumber?: string;
machineName?: string;
ncSerialNumber?: string;
installationDate?: Date;
ncBrand?: string;
ncModel?: string;
@@ -27,6 +27,7 @@ export interface MachineInfoActions {
export const machineInfoStore = {
state: {
machineSerialNumber: "00000000000000",
ncSerialNumber: "00000000000000",
machineName: "Poseidon",
installationDate: null,