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
+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();
});
}));
}
}