Changed Client manager on Server
This commit is contained in:
Generated
+3
@@ -44,6 +44,7 @@ namespace Active_Client.View
|
||||
this.Browser.Size = new System.Drawing.Size(1920, 1080);
|
||||
this.Browser.TabIndex = 1;
|
||||
this.Browser.Text = "chromiumWebBrowser2";
|
||||
this.Browser.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Browser_KeyDown);
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
@@ -55,6 +56,7 @@ namespace Active_Client.View
|
||||
this.DoubleBuffered = true;
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.KeyPreview = true;
|
||||
this.MaximizeBox = false;
|
||||
this.MaximumSize = new System.Drawing.Size(1920, 1080);
|
||||
this.MinimizeBox = false;
|
||||
@@ -65,6 +67,7 @@ namespace Active_Client.View
|
||||
this.Text = "CMS-STEP Client";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
|
||||
this.Load += new System.EventHandler(this.MainForm_Load);
|
||||
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.MainForm_KeyDown);
|
||||
this.Resize += new System.EventHandler(this.MainForm_Resize);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
|
||||
+13
-1
@@ -184,7 +184,6 @@ namespace Active_Client.View
|
||||
|
||||
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -768,6 +767,19 @@ namespace Active_Client.View
|
||||
}
|
||||
}
|
||||
|
||||
private void MainForm_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Alt && e.KeyCode == Keys.F4)
|
||||
{
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void Browser_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
//Windows Keys Handler
|
||||
public void keyPressedHandler(bool altPressed, bool ctrlPressed, bool shiftPressed, int key)
|
||||
|
||||
@@ -1025,7 +1025,6 @@ namespace Active_Client.View
|
||||
//if it has the border and a title execute focus
|
||||
if (ActiveNCWindowStyle != 0 && ActiveNCWindowBorder == WS_BORDER && ReadWindowTitle(hwnd) != "" && hwnd != ncprocess.MainWindowHandle)
|
||||
{
|
||||
|
||||
SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_SHOWWINDOW);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -978,8 +978,6 @@ public static class ThreadsFunctions
|
||||
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
if (ServerStartupConfig.AutoOpenCmsClient)
|
||||
StartCMSClient(null);
|
||||
|
||||
|
||||
if(NcConfig.NcVendor == NC_VENDOR.FANUC || NcConfig.NcVendor == NC_VENDOR.OSAI)
|
||||
@@ -994,11 +992,15 @@ public static class ThreadsFunctions
|
||||
// cmsError = toolTable.RestoreTableLock();
|
||||
}
|
||||
}
|
||||
|
||||
// Start/Restart NC threads
|
||||
ThreadsHandler.StartWorkers();
|
||||
if (!cmsError.IsError())
|
||||
{
|
||||
if (ServerStartupConfig.AutoOpenCmsClient)
|
||||
StartCMSClient();
|
||||
|
||||
reconnectionIsRunning = false;
|
||||
// Start/Restart NC threads
|
||||
ThreadsHandler.StartWorkers();
|
||||
reconnectionIsRunning = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void RestoreConnection()
|
||||
@@ -1163,22 +1165,38 @@ public static class ThreadsFunctions
|
||||
|
||||
return sleep;
|
||||
}
|
||||
public static void StartCMSClient(string url)
|
||||
public static void StartCMSClient()
|
||||
{
|
||||
//Setup the Path Variable
|
||||
string CMSClientPath = "";
|
||||
if (!ClientIsRunning())
|
||||
{
|
||||
// Check if the system is 64/32 bit
|
||||
if (Environment.Is64BitOperatingSystem && File.Exists(CLIENT_PATH_64))
|
||||
CMSClientPath = CLIENT_PATH_64;
|
||||
else if (File.Exists(CLIENT_PATH_86))
|
||||
CMSClientPath = CLIENT_PATH_86;
|
||||
|
||||
if (!String.IsNullOrEmpty(CMSClientPath))
|
||||
Process.Start(CMSClientPath, url);
|
||||
ThreadsHandler.StartClient = new Thread(() => clientProcess());
|
||||
ThreadsHandler.StartClient.Start();
|
||||
}
|
||||
}
|
||||
|
||||
private static void clientProcess()
|
||||
{
|
||||
string CMSClientPath = "";
|
||||
// Check if the system is 64/32 bit
|
||||
if (Environment.Is64BitOperatingSystem && File.Exists(CLIENT_PATH_64))
|
||||
CMSClientPath = CLIENT_PATH_64;
|
||||
else if (File.Exists(CLIENT_PATH_86))
|
||||
CMSClientPath = CLIENT_PATH_86;
|
||||
|
||||
if (!String.IsNullOrEmpty(CMSClientPath))
|
||||
{
|
||||
Process pr = Process.Start(CMSClientPath, null);
|
||||
|
||||
if (ServerStartupConfig.AutoOpenCmsClient)
|
||||
{
|
||||
pr.WaitForExit();
|
||||
MessageServices.Current.Publish(SEND_STOP_SERVER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static bool ClientIsRunning()
|
||||
{
|
||||
Process[] p = Process.GetProcessesByName(CLIENT_EXE_NAME_NOEXT);
|
||||
|
||||
@@ -31,6 +31,8 @@ namespace Step.Core
|
||||
};
|
||||
|
||||
private volatile static List<Thread> RunningThreadsList = new List<Thread>();
|
||||
public static Thread StartClient;
|
||||
|
||||
internal volatile static Dictionary<string, string> RunningThreadStatus = new Dictionary<string, string>();
|
||||
|
||||
public static void Start()
|
||||
@@ -89,10 +91,18 @@ namespace Step.Core
|
||||
RunningThreadsList.ForEach(thread =>
|
||||
{
|
||||
thread.Abort();
|
||||
});
|
||||
});
|
||||
|
||||
if(ThreadsHandler.StartClient != null)
|
||||
ThreadsHandler.StartClient.Abort();
|
||||
|
||||
//Abort Connect Thread
|
||||
ThreadsFunctions.AbortNcConnection();
|
||||
}
|
||||
|
||||
public static void StartClientFromUI()
|
||||
{
|
||||
ThreadsFunctions.StartCMSClient();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Step.Model;
|
||||
using Step.Core;
|
||||
using Step.Model;
|
||||
using Step.Model.DTOModels;
|
||||
using Step.NC;
|
||||
using System;
|
||||
@@ -132,7 +133,7 @@ namespace Step.UI
|
||||
private void OpenUiButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
//Open CMS Client
|
||||
StartCMSClient(null);
|
||||
ThreadsHandler.StartClientFromUI();
|
||||
}
|
||||
|
||||
private void StopServerButton_Click(object sender, EventArgs e)
|
||||
@@ -158,25 +159,6 @@ namespace Step.UI
|
||||
MessageServices.Current.Publish(SEND_STOP_SERVER);
|
||||
}
|
||||
|
||||
public static void StartCMSClient(string url)
|
||||
{
|
||||
//Setup the Path Variable
|
||||
string CMSClientPath = "";
|
||||
if (!ClientIsRunning())
|
||||
{
|
||||
// Check if the system is 64/32 bit
|
||||
if (Environment.Is64BitOperatingSystem && File.Exists(CLIENT_PATH_64))
|
||||
CMSClientPath = CLIENT_PATH_64;
|
||||
else if (File.Exists(CLIENT_PATH_86))
|
||||
CMSClientPath = CLIENT_PATH_86;
|
||||
|
||||
if (!String.IsNullOrEmpty(CMSClientPath))
|
||||
Process.Start(CMSClientPath, url);
|
||||
else
|
||||
MessageBox.Show("CMS-Active Client not found");
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeMessageListeners()
|
||||
{
|
||||
MVVMListeners = new List<RegistrationInfo>
|
||||
@@ -210,11 +192,12 @@ namespace Step.UI
|
||||
StepNotifyIcon.ShowBalloonTip(1000, message.Title, message.Message, (ToolTipIcon.Error));
|
||||
|
||||
//ShowMessage on UI
|
||||
TXTstatus.Text = "[" + DateTime.Now.ToString("T") + "] " + message.Message;
|
||||
TXTstatus.Text = "[" + DateTime.Now.ToString("T") + "] " + message.Message;
|
||||
|
||||
// Notify user
|
||||
if(MessageBox.Show(new Form { TopMost = true }, message.Message, message.Title, MessageBoxButtons.OK, MessageBoxIcon.Error) == DialogResult.OK)
|
||||
MessageServices.Current.Publish(SEND_STOP_SERVER);
|
||||
});
|
||||
// Notify user
|
||||
if(MessageBox.Show(message.Message, message.Title, MessageBoxButtons.OK, MessageBoxIcon.Error) == DialogResult.OK)
|
||||
MessageServices.Current.Publish(SEND_STOP_SERVER);
|
||||
}
|
||||
}),
|
||||
// NC status handler
|
||||
|
||||
@@ -134,6 +134,10 @@
|
||||
<Project>{3f5c2483-fc87-43ef-92a8-66ff7d0e440f}</Project>
|
||||
<Name>Step.Config</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Step.Core\Step.Core.csproj">
|
||||
<Project>{de54ff4c-8390-4489-882a-1bc7d99ef185}</Project>
|
||||
<Name>Step.Core</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Step.Model\Step.Model.csproj">
|
||||
<Project>{631375DD-06D3-49BB-8130-D9DDB34C429D}</Project>
|
||||
<Name>Step.Model</Name>
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace Step.Utils
|
||||
{
|
||||
if (beforeFormReady)
|
||||
{
|
||||
MessageBox.Show(error.Message, error.Title, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show(new Form { TopMost = true }, error.Message, error.Title, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -121,13 +121,13 @@ namespace Step.Utils
|
||||
{
|
||||
// Notify user
|
||||
MessageServices.Current.Publish(SEND_STOP_THREADS);
|
||||
MessageBox.Show(error.Message, error.Title, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show(new Form { TopMost = true }, error.Message, error.Title, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageServices.Current.Publish(SEND_STOP_SERVER);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Notify user
|
||||
MessageServices.Current.Publish(SEND_STOP_THREADS);
|
||||
//MessageServices.Current.Publish(SEND_STOP_THREADS);
|
||||
MessageServices.Current.Publish(SEND_MESSAGE, null, error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,11 +235,6 @@ namespace Step.Controllers.SignalR
|
||||
throw new HubException(cmsError.localizationKey);
|
||||
}
|
||||
}
|
||||
|
||||
public void QuitServerApp()
|
||||
{
|
||||
if (ServerStartupConfig.AutoOpenCmsClient)
|
||||
MessageServices.Current.Publish(SEND_STOP_SERVER);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -3,6 +3,7 @@ using Step.Config;
|
||||
using Step.Core;
|
||||
using Step.Database;
|
||||
using Step.Listeners;
|
||||
using Step.Model;
|
||||
using Step.NC;
|
||||
using Step.UI;
|
||||
using Step.Utils;
|
||||
@@ -43,8 +44,9 @@ namespace Step
|
||||
ServerConfigController.ReadStartupConfig();
|
||||
|
||||
// Start WinForm
|
||||
ServerControlWindow.Start();
|
||||
|
||||
ServerControlWindow.Start();
|
||||
|
||||
|
||||
DatabaseContext.SetUpDbConnectionAndDbConfig();
|
||||
|
||||
// Register listener to "close application" messages
|
||||
|
||||
@@ -127,7 +127,6 @@ if (typeof cmsClient != "undefined") {
|
||||
Vue.filter('localize')("modal_confirm_close_application", "Sei sicuro di voler chiudere l'applicazione?"),
|
||||
() => {
|
||||
messageService.publishToChannel("close-scada");
|
||||
Hub.Current.QuitServerApp();
|
||||
cmsClient.closeForm();
|
||||
},null ,'modal');
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ export class Hub {
|
||||
|
||||
private static activeProgramData(data) {
|
||||
var oldPath = (store.state as AppModel).process.currentProgram;
|
||||
|
||||
|
||||
if (data.path && (!oldPath || data.path != oldPath.path)) {
|
||||
fileService.getActiveFileInfo(data.path).then(r => {
|
||||
processModelActions.setCurrentProgramImage(store, r.image);
|
||||
@@ -194,7 +194,7 @@ export class Hub {
|
||||
processModelActions.setProcessMessage(store, data.processMessage)
|
||||
processModelActions.setCurrentOrigin(store, data.activeOrigin);
|
||||
processModelActions.setCanLoadProgram(store, data.canLoadProgram);
|
||||
processModelActions.setUnitMeasure(store, data.unitMeasure);
|
||||
processModelActions.setUnitMeasure(store, data.unitMeasure);
|
||||
processModelActions.isRunning(store, data.isRunning);
|
||||
processModelActions.selectProcess(store, data.selectedProcess);
|
||||
processModelActions.selectAxis(store, data.selectedAxis);
|
||||
@@ -276,7 +276,7 @@ export class Hub {
|
||||
Factory.Get(MessageService).publishToChannel("force-ui-update", null);
|
||||
}
|
||||
if (status == "connected" && Hub._serverConnectionNotificationVisible) {
|
||||
|
||||
|
||||
var toast = document.querySelector('#serverConnection') as any;
|
||||
(iziToast as any).hide(toast);
|
||||
Hub._serverConnectionNotificationVisible = false;
|
||||
@@ -408,9 +408,9 @@ export class Hub {
|
||||
|
||||
public ncSoftKeyClick(id: number) {
|
||||
this._hub.server.ncSoftKeyClick(id);
|
||||
|
||||
if(typeof cmsClient != "undefined"){
|
||||
if(cmsClient.getNcWindowState() == 1)
|
||||
|
||||
if (typeof cmsClient != "undefined") {
|
||||
if (cmsClient.getNcWindowState() == 1)
|
||||
cmsClient.forceNcFocus();
|
||||
}
|
||||
}
|
||||
@@ -431,10 +431,6 @@ export class Hub {
|
||||
this._hub.server.selectAxis(id);
|
||||
}
|
||||
|
||||
public QuitServerApp() {
|
||||
try { this._hub.server.quitServerApp(); } catch (err) { }
|
||||
}
|
||||
|
||||
public Hello() {
|
||||
this._hub.server.hello();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user