Merge branch 'feature/Vendo_HMI_integration' into develop
This commit is contained in:
@@ -33,11 +33,17 @@ namespace Client.Utils
|
||||
|
||||
//BROWSER OBJECT NAME -> The first letter must be Lower-Case (CEF Settings)
|
||||
public const String BROWSER_JS_OBJ_NAME = "cmsClient";
|
||||
|
||||
|
||||
|
||||
//Nc States
|
||||
public enum NcState { HIDE = 0, SHOW = 1,READONLY = 2 };
|
||||
|
||||
|
||||
//HMI Size & Position
|
||||
public const int HMI_WINDOW_POS_X = 56;
|
||||
public const int HMI_WINDOW_POS_Y = 176;
|
||||
public const int HMI_WINDOW_WIDTH = 1024;
|
||||
public const int HMI_WINDOW_HEIGHT = 768;
|
||||
|
||||
public const string StartingPage = "index.html";
|
||||
public const string ConfigPage = "api/configuration/client";
|
||||
|
||||
|
||||
@@ -132,8 +132,11 @@ namespace CMS_Client.Browser_Tools
|
||||
|
||||
public void getScreenBase64(object sender, CfrV8HandlerExecuteEventArgs e)
|
||||
{
|
||||
if (e.Arguments.Count() > 0 && e.Arguments[0].BoolValue)
|
||||
NcWindow.CaptureHMI();
|
||||
e.SetReturnValue(NcWindow.NcCapture);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -62,6 +62,13 @@ namespace CMS_Client.View
|
||||
//Setup Wait Cursor
|
||||
Cursor.Current = Cursors.WaitCursor;
|
||||
|
||||
|
||||
//Start following NC Window
|
||||
if (Config.VendorHmiConfig.Enabled)
|
||||
NcWindow.StartNcFollowing(MainHandle, NcHandle, NcFrm.Width, NcFrm.Height);
|
||||
else
|
||||
NcWindow.StartStepFollowing(MainHandle);
|
||||
|
||||
//Load the page
|
||||
Browser.LoadUrl(Config.ConnectionConfig.StartingUrl);
|
||||
|
||||
@@ -204,12 +211,6 @@ namespace CMS_Client.View
|
||||
//Show the Main Window, when the page is loaded
|
||||
ShowWindow();
|
||||
|
||||
//Start following NC Window
|
||||
if (Config.VendorHmiConfig.Enabled)
|
||||
NcWindow.StartNcFollowing(MainHandle, NcHandle, NcFrm.Width, NcFrm.Height);
|
||||
else
|
||||
NcWindow.StartStepFollowing(MainHandle);
|
||||
|
||||
//If is an Error Show the Error page
|
||||
if (LoadingError.Error && !LoadingError.ErrorInfo.Contains("ERR_ABORTED"))
|
||||
MessageBox.Show("Error While Loading the Page: " + LoadingError.ErrorInfo + "\nPress:\n - F5: reload the Page\n - F1: Back to last Page");
|
||||
|
||||
+136
-99
@@ -19,24 +19,24 @@ namespace CMS_Client.View
|
||||
static class NcWindow
|
||||
{
|
||||
//Const value used for open the Process/Application
|
||||
const String FanucPath = @"\CNCScreenE\CNCScrnE.exe";
|
||||
const String OsaiPath = @"\OSAI\WinNBI\ProVideo.exe";
|
||||
const String SiemensPath = @"\Siemens\MotionControl\siemens\sinumerik\hmi\autostart\run_hmi.exe";
|
||||
const String DemoPath = @"\Nc_Demo_Application.exe";
|
||||
|
||||
const String FanucName = "CNCScrnE";
|
||||
const String OsaiName = "provideo";
|
||||
const String SiemensName = "slsmhmihost";
|
||||
const String DemoName = "Nc_Demo_Application";
|
||||
const String FanucPath = @"\CNCScreenE\CNCScrnE.exe";
|
||||
const String OsaiPath = @"\OSAI\WinNBI\ProVideo.exe";
|
||||
const String SiemensPath = @"\Siemens\MotionControl\siemens\sinumerik\hmi\autostart\run_hmi.exe";
|
||||
const String DemoPath = @"\Nc_Demo_Application.exe";
|
||||
|
||||
const String Win7TaskBar = "Shell_TrayWnd";
|
||||
const String FanucName = "CNCScrnE";
|
||||
const String OsaiName = "provideo";
|
||||
const String SiemensName = "slsmhmihost";
|
||||
const String DemoName = "Nc_Demo_Application";
|
||||
|
||||
const String Win7TaskBar = "Shell_TrayWnd";
|
||||
const String Win7StartBtnCL = "Button";
|
||||
const String Win7StartBtnTxt= "Start";
|
||||
const String Win7StartBtnTxt = "Start";
|
||||
const String SiemensTool1Name = "run_hmi";
|
||||
const String SiemensTool2Name = "slsmsystemmanager";
|
||||
const int WaitingMs = 500;
|
||||
const int TimesToTryKill = 10;
|
||||
const int TimesToTryOpen = 120; // 120 * 500ms = 60000ms => 1min
|
||||
const int WaitingMs = 500;
|
||||
const int TimesToTryKill = 10;
|
||||
const int TimesToTryOpen = 120; // 120 * 500ms = 60000ms => 1min
|
||||
|
||||
//Public variables
|
||||
public static bool WindowStarted { get { return windowstarted; } }
|
||||
@@ -64,7 +64,7 @@ namespace CMS_Client.View
|
||||
private static uint LastdwmsEventTime;
|
||||
private static uint LastHookedPID;
|
||||
private static int TriedTimes;
|
||||
private static bool ProcKilled;
|
||||
private static bool ProcKilled;
|
||||
private static bool IsNcSiemens;
|
||||
|
||||
private static IntPtr ActualHND;
|
||||
@@ -95,10 +95,10 @@ namespace CMS_Client.View
|
||||
|
||||
//Setup the Path/Name of the process
|
||||
SetupNcProcess();
|
||||
|
||||
|
||||
//Read if exists a Process with correct name
|
||||
processes = Process.GetProcessesByName(processname);
|
||||
|
||||
|
||||
//Save the Taskbar Windows Handle
|
||||
TaskBarHandle = FindWindow(Win7TaskBar, "");
|
||||
StartBtnHandle = FindWindow(Win7StartBtnCL, Win7StartBtnTxt);
|
||||
@@ -116,7 +116,7 @@ namespace CMS_Client.View
|
||||
//Set the first founded process
|
||||
ncprocess = processes[0];
|
||||
ncprocess.WaitForInputIdle();
|
||||
|
||||
|
||||
//Wait until the process is started
|
||||
TriedTimes = 1;
|
||||
while (processes[0].MainWindowHandle == IntPtr.Zero && TriedTimes < TimesToTryKill)
|
||||
@@ -130,7 +130,7 @@ namespace CMS_Client.View
|
||||
}
|
||||
|
||||
//Kill the process if needed
|
||||
if(TriedTimes == TimesToTryKill)
|
||||
if (TriedTimes == TimesToTryKill)
|
||||
{
|
||||
//Kill the Process
|
||||
CloseNcWindow();
|
||||
@@ -160,7 +160,7 @@ namespace CMS_Client.View
|
||||
while ((processes.Length <= 0 || (processes[0].MainWindowHandle == IntPtr.Zero)) && TriedTimes < TimesToTryOpen)
|
||||
{
|
||||
processes = Process.GetProcessesByName(processname);
|
||||
if(processes.Length <= 0 || (processes[0].MainWindowHandle == IntPtr.Zero))
|
||||
if (processes.Length <= 0 || (processes[0].MainWindowHandle == IntPtr.Zero))
|
||||
{
|
||||
Thread.Sleep(WaitingMs);
|
||||
TriedTimes++;
|
||||
@@ -183,7 +183,7 @@ namespace CMS_Client.View
|
||||
|
||||
//Show the Main Window & Hide the Others (Only Siemens)
|
||||
ShowWindow(ncprocess.MainWindowHandle, WS_SHOW);
|
||||
if(IsNcSiemens)
|
||||
if (IsNcSiemens)
|
||||
{
|
||||
//Wait 500 ms of Siemens software
|
||||
Thread.Sleep(500);
|
||||
@@ -196,11 +196,11 @@ namespace CMS_Client.View
|
||||
|
||||
SetNcIcon(Resources.SinumerikHmi);
|
||||
}
|
||||
|
||||
|
||||
//Remove the Frame Border
|
||||
style = GetWindowLong(ncprocess.MainWindowHandle, GWL_STYLE);
|
||||
SetWindowLong(ncprocess.MainWindowHandle, GWL_STYLE, (style & ~WS_CAPTION & ~WS_THICKFRAME));
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -253,7 +253,7 @@ namespace CMS_Client.View
|
||||
//Kill Tool Process
|
||||
if (IsNcSiemens)
|
||||
KillAllProcessWithName(SiemensTool2Name);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -280,6 +280,7 @@ namespace CMS_Client.View
|
||||
public static void SetState(NcState St)
|
||||
{
|
||||
state = St;
|
||||
CaptureHMI();
|
||||
}
|
||||
|
||||
|
||||
@@ -291,7 +292,7 @@ namespace CMS_Client.View
|
||||
{
|
||||
ShowWindow(TaskBarHandle, WS_SHOW);
|
||||
ShowWindow(StartBtnHandle, WS_SHOW);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -368,11 +369,12 @@ namespace CMS_Client.View
|
||||
GetWindowThreadProcessId(ncprocess.MainWindowHandle, out NcProcessPID);
|
||||
|
||||
//Resize the Window
|
||||
ResizeAndMoveNcWindow(64, 176, 1024, 768);
|
||||
ResizeAndMoveNcWindow(HMI_WINDOW_POS_X, HMI_WINDOW_POS_Y, HMI_WINDOW_WIDTH, HMI_WINDOW_HEIGHT);
|
||||
|
||||
//Start the Hook
|
||||
if (MainViewHandle != IntPtr.Zero && ncprocess.MainWindowHandle != IntPtr.Zero && MainProcessPID != 0 && NcProcessPID != 0 && windowstarted)
|
||||
{
|
||||
CaptureHMI();
|
||||
//Detach the hook
|
||||
if (hhook != IntPtr.Zero)
|
||||
UnhookWinEvent(hhook);
|
||||
@@ -390,6 +392,7 @@ namespace CMS_Client.View
|
||||
//Start the new Thread of Follow-NC-Window
|
||||
if (Config.VendorHmiConfig.FollowNcWindow)
|
||||
{
|
||||
|
||||
if (FollowNCThread != null)
|
||||
FollowNCThread.Abort();
|
||||
FollowNCThread = new Thread(new ThreadStart(FollowNcBehaviour));
|
||||
@@ -405,7 +408,7 @@ namespace CMS_Client.View
|
||||
public static void StopNcFollowing()
|
||||
{
|
||||
//Un-parent the window
|
||||
if(ncprocess.MainWindowHandle != IntPtr.Zero)
|
||||
if (ncprocess.MainWindowHandle != IntPtr.Zero)
|
||||
SetParent(ncprocess.MainWindowHandle, IntPtr.Zero);
|
||||
|
||||
//Detach the hook
|
||||
@@ -420,25 +423,25 @@ namespace CMS_Client.View
|
||||
//Stop the Follow-Nc Thread
|
||||
if (Config.VendorHmiConfig.FollowNcWindow && FollowNCThread != null)
|
||||
FollowNCThread.Abort();
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#region WINDOWS_EVENT_OVERRIDE
|
||||
|
||||
|
||||
//Following Nc Window Method
|
||||
private static void WinEventProc(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
|
||||
{
|
||||
|
||||
//Read the actual ID of the Process
|
||||
GetWindowThreadProcessId(hwnd, out ActualPID);
|
||||
|
||||
|
||||
ActualHND = hwnd;
|
||||
//Filter if comes multiple event at the same time
|
||||
if (ActualHND != LastHookedHND || dwmsEventTime != LastdwmsEventTime)
|
||||
{
|
||||
{
|
||||
//If the PID is the STEP-HMI Process
|
||||
if (ActualPID == MainProcessPID)
|
||||
{
|
||||
@@ -453,16 +456,16 @@ namespace CMS_Client.View
|
||||
if (PopupHandle != ncprocess.MainWindowHandle)
|
||||
{
|
||||
ResizeOutofBoundWindow(ncprocess.MainWindowHandle, PopupHandle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else if(ActualPID == NcProcessPID)
|
||||
else if (ActualPID == NcProcessPID)
|
||||
{
|
||||
//Hide the TaskBar
|
||||
HideTaskBar();
|
||||
|
||||
|
||||
|
||||
//Disable main manu if is present
|
||||
IntPtr Menu = GetSystemMenu(ActualHND, false);
|
||||
@@ -472,13 +475,13 @@ namespace CMS_Client.View
|
||||
DeleteMenu(Menu, SC_MAXIMIZE, MF_BYCOMMAND);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//If the PID is OTHER Process
|
||||
else
|
||||
{
|
||||
{
|
||||
//Show the TaskBar
|
||||
ShowTaskBar();
|
||||
ShowTaskBar();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -497,7 +500,7 @@ namespace CMS_Client.View
|
||||
|
||||
|
||||
//Resize out of Bound window
|
||||
private static void ResizeOutofBoundWindow(IntPtr ParentHandle,IntPtr WindowHandle)
|
||||
private static void ResizeOutofBoundWindow(IntPtr ParentHandle, IntPtr WindowHandle)
|
||||
{
|
||||
RECT MainRct;
|
||||
RECT ParentRct;
|
||||
@@ -537,7 +540,7 @@ namespace CMS_Client.View
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//Resize & Move NC Window
|
||||
private static void ResizeAndMoveNcWindow(int X, int Y, int width, int height)
|
||||
{
|
||||
@@ -563,30 +566,30 @@ namespace CMS_Client.View
|
||||
// 0: Demo
|
||||
case 0:
|
||||
{
|
||||
processname = DemoName;
|
||||
processpath = @"C:\CMS\STEP\DEMO" + DemoPath;
|
||||
};break;
|
||||
processname = DemoName;
|
||||
processpath = @"C:\CMS\STEP\DEMO" + DemoPath;
|
||||
}; break;
|
||||
|
||||
// 1: Fanuc
|
||||
case 1:
|
||||
{
|
||||
processname = FanucName;
|
||||
processpath = getProgramFilesx86Path() + FanucPath;
|
||||
processname = FanucName;
|
||||
processpath = getProgramFilesx86Path() + FanucPath;
|
||||
}; break;
|
||||
|
||||
// 2: Siemens
|
||||
case 2:
|
||||
{
|
||||
IsNcSiemens = true;
|
||||
processname = SiemensName;
|
||||
processpath = getProgramFilesx86Path() + SiemensPath;
|
||||
IsNcSiemens = true;
|
||||
processname = SiemensName;
|
||||
processpath = getProgramFilesx86Path() + SiemensPath;
|
||||
}; break;
|
||||
|
||||
// 3: Osai
|
||||
case 3:
|
||||
{
|
||||
processname = OsaiName;
|
||||
processpath = getProgramFilesx86Path() + OsaiPath;
|
||||
processname = OsaiName;
|
||||
processpath = getProgramFilesx86Path() + OsaiPath;
|
||||
}; break;
|
||||
}
|
||||
}
|
||||
@@ -616,10 +619,10 @@ namespace CMS_Client.View
|
||||
//Hide All windows Process
|
||||
private static void hideAllProcWindows(String ProcessName)
|
||||
{
|
||||
Process [] processes = Process.GetProcessesByName(ProcessName);
|
||||
foreach(Process proc in processes)
|
||||
Process[] processes = Process.GetProcessesByName(ProcessName);
|
||||
foreach (Process proc in processes)
|
||||
{
|
||||
if(proc.MainWindowHandle != IntPtr.Zero)
|
||||
if (proc.MainWindowHandle != IntPtr.Zero)
|
||||
ShowWindow(proc.MainWindowHandle, WS_HIDE);
|
||||
}
|
||||
}
|
||||
@@ -666,6 +669,40 @@ namespace CMS_Client.View
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void CaptureHMI()
|
||||
{
|
||||
RECT rc = new RECT();
|
||||
Graphics gr;
|
||||
bool success = false;
|
||||
Bitmap bmp;
|
||||
MemoryStream m = new MemoryStream();
|
||||
|
||||
Thread.BeginThreadAffinity();
|
||||
m = new MemoryStream();
|
||||
String Base64Capture;
|
||||
if (ncprocess != null && ncprocess.MainWindowHandle != IntPtr.Zero)
|
||||
{
|
||||
GetWindowRect(ncprocess.MainWindowHandle, out rc);
|
||||
bmp = new Bitmap(rc.Right - rc.Left, rc.Bottom - rc.Top);
|
||||
gr = Graphics.FromImage(bmp);
|
||||
success = PrintWindow(ncprocess.MainWindowHandle, gr.GetHdc(), 0);
|
||||
gr.ReleaseHdc();
|
||||
if (success && bmp != null)
|
||||
{
|
||||
bmp.Save(m, ImageFormat.Png);
|
||||
Base64Capture = Convert.ToBase64String(m.ToArray());
|
||||
ncCapture = "data:image/png;base64," + Base64Capture;
|
||||
}
|
||||
m.Dispose();
|
||||
bmp.Dispose();
|
||||
gr.Dispose();
|
||||
}
|
||||
else
|
||||
ncCapture = "data:image/png;base64,";
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -758,47 +795,47 @@ namespace CMS_Client.View
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#region WIN32_METHODS
|
||||
|
||||
private const int GWL_STYLE = -16;
|
||||
private const int GWL_EXSTYLE = -20;
|
||||
private const int LWA_ALPHA = 0x00000002;
|
||||
private const int LWA_COLORKEY = 0x00000001;
|
||||
private const int WS_EX_LAYERED = 0x00080000;
|
||||
private const int WS_EX_TOOLWINDOW = 0x00000080;
|
||||
private const int WS_CHILD = 0x40000000;
|
||||
private const int WS_BORDER = 0x00800000;
|
||||
private const int WS_DLGFRAME = 0x00400000;
|
||||
private const int WS_CAPTION = WS_BORDER | WS_DLGFRAME;
|
||||
private const int WS_THICKFRAME = 262144;
|
||||
private const int WS_HIDE = 0;
|
||||
private const int WS_SHOW = 5;
|
||||
private const int WS_MINIMIZE = 6;
|
||||
private const int WS_SHOWNORMAL = 1;
|
||||
private const int SW_SHOWMAXIMIZED = 3;
|
||||
private const int SW_SHOWDEFAULT = 10;
|
||||
private const int SW_SHOWNOACTIVATE = 4;
|
||||
private const int WM_SETICON = 0x80;
|
||||
private const int ICON_SMALL = 0;
|
||||
private const int ICON_BIG = 1;
|
||||
private const uint EVENT_OBJECT_FOCUS = 0x8005;
|
||||
private const uint WINEVENT_OUTOFCONTEXT= 0;
|
||||
private const UInt32 SWP_NOSIZE = 0x0001;
|
||||
private const UInt32 SWP_NOMOVE = 0x0002;
|
||||
private const UInt32 SWP_NOACTIVATE = 0x0010;
|
||||
private const UInt32 SWP_SHOWWINDOW = 0x0040;
|
||||
private const UInt32 SWP_NOZORDER = 0x0004;
|
||||
private const UInt32 SWP_NOREDRAW = 0x0008;
|
||||
private const UInt32 SWP_HIDEWINDOW = 0x0080;
|
||||
private const int MF_BYCOMMAND = 0x00000000;
|
||||
private const int SC_CLOSE = 0xF060;
|
||||
private const int SC_MINIMIZE = 0xF020;
|
||||
private const int SC_MAXIMIZE = 0xF030;
|
||||
private const int WS_SYSMENU = 0x00080000;
|
||||
private const uint WS_POPUP = 0x80000000;
|
||||
private const int WS_MAXIMIZE = 0x01000000;
|
||||
static readonly IntPtr HWND_BOTTOM = new IntPtr(1);
|
||||
static readonly IntPtr HWND_TOP = new IntPtr(0);
|
||||
static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);
|
||||
static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2);
|
||||
private const int GWL_STYLE = -16;
|
||||
private const int GWL_EXSTYLE = -20;
|
||||
private const int LWA_ALPHA = 0x00000002;
|
||||
private const int LWA_COLORKEY = 0x00000001;
|
||||
private const int WS_EX_LAYERED = 0x00080000;
|
||||
private const int WS_EX_TOOLWINDOW = 0x00000080;
|
||||
private const int WS_CHILD = 0x40000000;
|
||||
private const int WS_BORDER = 0x00800000;
|
||||
private const int WS_DLGFRAME = 0x00400000;
|
||||
private const int WS_CAPTION = WS_BORDER | WS_DLGFRAME;
|
||||
private const int WS_THICKFRAME = 262144;
|
||||
private const int WS_HIDE = 0;
|
||||
private const int WS_SHOW = 5;
|
||||
private const int WS_MINIMIZE = 6;
|
||||
private const int WS_SHOWNORMAL = 1;
|
||||
private const int SW_SHOWMAXIMIZED = 3;
|
||||
private const int SW_SHOWDEFAULT = 10;
|
||||
private const int SW_SHOWNOACTIVATE = 4;
|
||||
private const int WM_SETICON = 0x80;
|
||||
private const int ICON_SMALL = 0;
|
||||
private const int ICON_BIG = 1;
|
||||
private const uint EVENT_OBJECT_FOCUS = 0x8005;
|
||||
private const uint WINEVENT_OUTOFCONTEXT = 0;
|
||||
private const UInt32 SWP_NOSIZE = 0x0001;
|
||||
private const UInt32 SWP_NOMOVE = 0x0002;
|
||||
private const UInt32 SWP_NOACTIVATE = 0x0010;
|
||||
private const UInt32 SWP_SHOWWINDOW = 0x0040;
|
||||
private const UInt32 SWP_NOZORDER = 0x0004;
|
||||
private const UInt32 SWP_NOREDRAW = 0x0008;
|
||||
private const UInt32 SWP_HIDEWINDOW = 0x0080;
|
||||
private const int MF_BYCOMMAND = 0x00000000;
|
||||
private const int SC_CLOSE = 0xF060;
|
||||
private const int SC_MINIMIZE = 0xF020;
|
||||
private const int SC_MAXIMIZE = 0xF030;
|
||||
private const int WS_SYSMENU = 0x00080000;
|
||||
private const uint WS_POPUP = 0x80000000;
|
||||
private const int WS_MAXIMIZE = 0x01000000;
|
||||
static readonly IntPtr HWND_BOTTOM = new IntPtr(1);
|
||||
static readonly IntPtr HWND_TOP = new IntPtr(0);
|
||||
static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);
|
||||
static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern int DeleteMenu(IntPtr hMenu, int nPosition, int wFlags);
|
||||
@@ -856,8 +893,8 @@ namespace CMS_Client.View
|
||||
static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int count);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
static extern IntPtr SetWinEventHook(uint eventMin, uint eventMax, IntPtr hmodWinEventProc, WinEventDelegate lpfnWinEventProc, uint idProcess,uint idThread, uint dwFlags);
|
||||
delegate void WinEventDelegate(IntPtr hWinEventHook, uint eventType,IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime);
|
||||
static extern IntPtr SetWinEventHook(uint eventMin, uint eventMax, IntPtr hmodWinEventProc, WinEventDelegate lpfnWinEventProc, uint idProcess, uint idThread, uint dwFlags);
|
||||
delegate void WinEventDelegate(IntPtr hWinEventHook, uint eventType, IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
@@ -868,7 +905,7 @@ namespace CMS_Client.View
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern IntPtr FindWindow(string className, string windowText);
|
||||
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
static extern bool SetWindowText(IntPtr hWnd, string text);
|
||||
@@ -882,7 +919,7 @@ namespace CMS_Client.View
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
static extern IntPtr GetAncestor(IntPtr hWnd, uint uCmd);
|
||||
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
static extern bool SetLayeredWindowAttributes(IntPtr hwnd, uint crKey, byte bAlpha, uint dwFlags);
|
||||
@@ -924,8 +961,8 @@ namespace CMS_Client.View
|
||||
public int Right;
|
||||
public int Bottom;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,6 +132,46 @@ body {
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
#nc-hmi{
|
||||
position: absolute;
|
||||
top: 168px;
|
||||
left: 48px;
|
||||
height: 784px;
|
||||
width: 1040px;
|
||||
border-radius: 2px;
|
||||
background-color: #4e585e;
|
||||
box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
#nc-hmi-img{
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
left: 8px;
|
||||
height: 768px;
|
||||
width: 1024px;
|
||||
border: none;
|
||||
}
|
||||
|
||||
#nc-softkeys-container{
|
||||
position: absolute;
|
||||
top: 480px;
|
||||
left: 1096px;
|
||||
width: 816px;
|
||||
height: 472px;
|
||||
background-image: linear-gradient(to bottom, #657178, #404040);
|
||||
box-shadow: 0 0 2px 0 rgba(0, 0, 0, 0.4);
|
||||
border-radius: 2px;
|
||||
}
|
||||
#nc-softkeys-header {
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
width: 816px;
|
||||
height: 64px;
|
||||
background-color: #4e585e;
|
||||
}
|
||||
|
||||
|
||||
.tester {
|
||||
margin: auto;
|
||||
width: 60vw;
|
||||
|
||||
@@ -1076,6 +1076,24 @@ body {
|
||||
height: calc(100vh - 80px);
|
||||
z-index: 1;
|
||||
}
|
||||
#nc-hmi {
|
||||
position: absolute;
|
||||
top: 168px;
|
||||
left: 48px;
|
||||
height: 784px;
|
||||
width: 1040px;
|
||||
border-radius: 2px;
|
||||
background-color: #4e585e;
|
||||
box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
#nc-hmi-img {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
left: 8px;
|
||||
height: 768px;
|
||||
width: 1024px;
|
||||
border: none;
|
||||
}
|
||||
.tester {
|
||||
margin: auto;
|
||||
width: 60vw;
|
||||
|
||||
Vendored
+12
-12
File diff suppressed because one or more lines are too long
Vendored
+10
-10
File diff suppressed because one or more lines are too long
Vendored
+6
-6
File diff suppressed because one or more lines are too long
Vendored
+6
-6
File diff suppressed because one or more lines are too long
Vendored
+6
-6
File diff suppressed because one or more lines are too long
Vendored
+928
-976
File diff suppressed because one or more lines are too long
@@ -4,18 +4,22 @@
|
||||
<app-header></app-header>
|
||||
<alarm-list></alarm-list>
|
||||
<div id="back-view">
|
||||
<router-view name="backview"></router-view>
|
||||
<div id="nc-hmi">
|
||||
<img id="nc-hmi-img" :src="HMIsrc" />
|
||||
</div >
|
||||
<div id="nc-softkeys-container"><div id="nc-softkeys-header"> </div></div>
|
||||
</div>
|
||||
|
||||
<div id="main-view" ref="main-view">
|
||||
<router-view/>
|
||||
</div>
|
||||
<div id="main-view-handler" ref="main-view-handler" @click="toggleMainView()">
|
||||
<vue-gesture :type="'swipedown'" :call="toggleMainView" :onmove="movepanel">
|
||||
<div class="handle">
|
||||
<i class="fa fa-angle-double-down"></i>
|
||||
</div>
|
||||
</vue-gesture>
|
||||
|
||||
<vue-gesture :type="'swipedown'" :call="toggleMainView" :onmove="movepanel">
|
||||
<div class="handle">
|
||||
<i class="fa fa-angle-double-down"></i>
|
||||
</div>
|
||||
</vue-gesture>
|
||||
</div>
|
||||
<app-footer></app-footer>
|
||||
|
||||
@@ -35,6 +39,7 @@ import { appModelActions } from "src/store";
|
||||
import "./app.business-logic";
|
||||
import * as iziToast from "izitoast";
|
||||
|
||||
|
||||
export default {
|
||||
name: "app",
|
||||
components: {
|
||||
@@ -42,9 +47,11 @@ export default {
|
||||
appFooter: Footer,
|
||||
modalContainer: ModalContainer,
|
||||
alarmList
|
||||
|
||||
},
|
||||
mounted: function() {
|
||||
let ms = Factory.Get(MessageService);
|
||||
this.HMIsrc = cmsClient.getScreenBase64();
|
||||
ms.subscribeToChannel("show-modal", args => {
|
||||
this.applyBlur = true;
|
||||
});
|
||||
@@ -63,6 +70,11 @@ export default {
|
||||
this.$forceUpdate();
|
||||
});
|
||||
|
||||
ms.subscribeToChannel("HMI-updateUI", args => {
|
||||
this.HMIsrc = args[0];
|
||||
});
|
||||
|
||||
|
||||
let _this = this;
|
||||
Factory.Get(LoginService)
|
||||
.getUserInfo()
|
||||
@@ -93,9 +105,22 @@ export default {
|
||||
},
|
||||
watch: {
|
||||
isMainViewLiftedUp: function() {
|
||||
if (this.state.isMainViewLiftedUp)
|
||||
if (this.state.isMainViewLiftedUp){
|
||||
|
||||
//Setup the Position of the View
|
||||
this.applyViewPosition(-window.innerHeight + 84);
|
||||
else this.applyViewPosition(0);
|
||||
|
||||
//Show the HMI with delay (For the animation)
|
||||
Factory.Get(MessageService).publishToChannel("HMI-show",600);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Setup the Position of the View
|
||||
this.applyViewPosition(0);
|
||||
|
||||
//Hide the HMI && clear the delay - variable
|
||||
Factory.Get(MessageService).publishToChannel("HMI-hide");
|
||||
}
|
||||
},
|
||||
loadingOperations: function(n, o) {
|
||||
if (o == 0 && n > 0) {
|
||||
@@ -153,7 +178,8 @@ export default {
|
||||
return {
|
||||
state: this.$store.state,
|
||||
applyBlur: false,
|
||||
loadingOperations: 0
|
||||
loadingOperations: 0,
|
||||
HMIsrc: "",
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import Vue from "vue";
|
||||
import Factory from "./factoryService";
|
||||
import { MessageService } from "./messageService";
|
||||
|
||||
// credit: http://www.javascriptkit.com/javatutors/touchevents2.shtml
|
||||
function swipedetect(el, callback, onmovecallback) {
|
||||
@@ -26,7 +28,8 @@ function swipedetect(el, callback, onmovecallback) {
|
||||
startY = touchobj.pageY
|
||||
lastXswipe = touchobj.pageX
|
||||
lastYswipe = touchobj.pageY
|
||||
e.preventDefault()
|
||||
e.preventDefault()
|
||||
Factory.Get(MessageService).publishToChannel("HMI-start-drag");
|
||||
}, false)
|
||||
|
||||
touchsurface.addEventListener('touchmove', function(e) {
|
||||
@@ -54,6 +57,7 @@ function swipedetect(el, callback, onmovecallback) {
|
||||
touchsurface.addEventListener('touchend', function(e) {
|
||||
var touchobj = e.changedTouches[0]
|
||||
|
||||
Factory.Get(MessageService).publishToChannel("HMI-stop-drag",600);
|
||||
handleswipe(swipedir)
|
||||
e.preventDefault()
|
||||
}, false)
|
||||
|
||||
@@ -9,6 +9,16 @@ import { AreaModel } from "src/store/machineStatus.store";
|
||||
import { machineInfoActions } from "src/store/machineInfo.store";
|
||||
|
||||
declare let cmsClient: any;
|
||||
let HMIvisible = false;
|
||||
let oldHMIvisible = false;
|
||||
let HMIAlarmsVisible = false;
|
||||
let HMIModalsVisible = false;
|
||||
let HMIDragging = false;
|
||||
let HMIshowTimeout;
|
||||
let HMIAlarmsTimeout;
|
||||
let HMIModalsTimeout;
|
||||
let HMIDraggingTimeout;
|
||||
let HMIScreenshotInterval;
|
||||
|
||||
const messageService = Factory.Get(MessageService);
|
||||
|
||||
@@ -18,7 +28,7 @@ messageService.subscribeToChannel("show-axes-calibration", () => { ModalHelper.S
|
||||
|
||||
|
||||
|
||||
//
|
||||
//Loading machine configuration
|
||||
async function loadMachineConfig() {
|
||||
try {
|
||||
let machine = new machineService();
|
||||
@@ -46,6 +56,8 @@ async function loadMachineConfig() {
|
||||
|
||||
loadMachineConfig();
|
||||
|
||||
|
||||
//Hide & Close Buttons
|
||||
if (typeof cmsClient != "undefined") {
|
||||
messageService.subscribeToChannel("close", () => { cmsClient.closeForm(); });
|
||||
messageService.subscribeToChannel("hide", () => { cmsClient.minimizeForm(); });
|
||||
@@ -54,3 +66,139 @@ else {
|
||||
messageService.subscribeToChannel("close", () => { alert("Function not allowed for this Browser"); });
|
||||
messageService.subscribeToChannel("hide", () => { alert("Function not allowed for this Browser"); });
|
||||
}
|
||||
|
||||
|
||||
//Show-Hide Vendor HMI
|
||||
if (typeof cmsClient != "undefined") {
|
||||
|
||||
//Hide at Startup = 0 (not-visible)
|
||||
cmsClient.setNcWindowState(0);
|
||||
|
||||
//Events handler
|
||||
Factory.Get(MessageService).subscribeToChannel("HMI-show", args => {
|
||||
clearTimeout(HMIshowTimeout);
|
||||
if (args[0] > 0)
|
||||
HMIshowTimeout = setTimeout(ShowHmi, args[0]);
|
||||
else
|
||||
ShowHmi()
|
||||
});
|
||||
|
||||
Factory.Get(MessageService).subscribeToChannel("HMI-hide", args => {
|
||||
clearTimeout(HMIshowTimeout);
|
||||
if (args[0] > 0)
|
||||
HMIshowTimeout = setTimeout(HideHmi, args[0]);
|
||||
else
|
||||
HideHmi()
|
||||
});
|
||||
|
||||
Factory.Get(MessageService).subscribeToChannel("HMI-show-alarms", args => {
|
||||
clearTimeout(HMIAlarmsTimeout);
|
||||
if (args[0] > 0)
|
||||
HMIAlarmsTimeout = setTimeout(showAlarms, args[0]);
|
||||
else
|
||||
showAlarms()
|
||||
});
|
||||
|
||||
Factory.Get(MessageService).subscribeToChannel("HMI-hide-alarms", args => {
|
||||
clearTimeout(HMIAlarmsTimeout);
|
||||
if (args[0] > 0)
|
||||
HMIAlarmsTimeout = setTimeout(hideAlarms, args[0]);
|
||||
else
|
||||
hideAlarms()
|
||||
});
|
||||
|
||||
Factory.Get(MessageService).subscribeToChannel("HMI-show-modal", args => {
|
||||
clearTimeout(HMIModalsTimeout);
|
||||
if (args[0] > 0)
|
||||
HMIModalsTimeout = setTimeout(showModal, args[0]);
|
||||
else
|
||||
showModal()
|
||||
});
|
||||
|
||||
Factory.Get(MessageService).subscribeToChannel("HMI-hide-modal", args => {
|
||||
clearTimeout(HMIModalsTimeout);
|
||||
if (args[0] > 0)
|
||||
HMIModalsTimeout = setTimeout(hideModal, args[0]);
|
||||
else
|
||||
hideModal()
|
||||
});
|
||||
|
||||
Factory.Get(MessageService).subscribeToChannel("HMI-start-drag", args => {
|
||||
clearTimeout(HMIDraggingTimeout);
|
||||
if (args[0] > 0)
|
||||
HMIDraggingTimeout = setTimeout(startDrag, args[0]);
|
||||
else
|
||||
startDrag()
|
||||
});
|
||||
|
||||
Factory.Get(MessageService).subscribeToChannel("HMI-stop-drag", args => {
|
||||
clearTimeout(HMIDraggingTimeout);
|
||||
if (args[0] > 0)
|
||||
HMIDraggingTimeout = setTimeout(stopDrag, args[0]);
|
||||
else
|
||||
stopDrag()
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
//Private functions for HMI State
|
||||
function ShowHmi() {
|
||||
HMIvisible = true;
|
||||
ElaborateHMIStatus();
|
||||
}
|
||||
function HideHmi() {
|
||||
HMIvisible = false;
|
||||
ElaborateHMIStatus();
|
||||
}
|
||||
function showAlarms(){
|
||||
HMIAlarmsVisible = true;
|
||||
ElaborateHMIStatus();
|
||||
}
|
||||
function hideAlarms(){
|
||||
HMIAlarmsVisible = false;
|
||||
ElaborateHMIStatus();
|
||||
}
|
||||
function showModal(){
|
||||
HMIModalsVisible = true;
|
||||
ElaborateHMIStatus();
|
||||
}
|
||||
function hideModal(){
|
||||
HMIModalsVisible = false;
|
||||
ElaborateHMIStatus();
|
||||
}
|
||||
function startDrag(){
|
||||
HMIDragging = true;
|
||||
ElaborateHMIStatus();
|
||||
}
|
||||
function stopDrag(){
|
||||
HMIDragging = false;
|
||||
ElaborateHMIStatus();
|
||||
}
|
||||
|
||||
function ElaborateHMIStatus(){
|
||||
if(!HMIvisible)
|
||||
{
|
||||
updateHmiImage(true);
|
||||
if(HMIScreenshotInterval)
|
||||
clearInterval(HMIScreenshotInterval);
|
||||
cmsClient.setNcWindowState(0);
|
||||
}
|
||||
else if(HMIvisible && !HMIAlarmsVisible && !HMIModalsVisible && !HMIDragging)
|
||||
{
|
||||
if(HMIScreenshotInterval)
|
||||
clearInterval(HMIScreenshotInterval);
|
||||
cmsClient.setNcWindowState(1);
|
||||
}
|
||||
else if(HMIvisible && (HMIAlarmsVisible || HMIModalsVisible || HMIDragging))
|
||||
{
|
||||
cmsClient.setNcWindowState(2);
|
||||
updateHmiImage(true);
|
||||
if(!HMIScreenshotInterval)
|
||||
setInterval(updateHmiImage, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function updateHmiImage(args) {
|
||||
Factory.Get(MessageService).publishToChannel("HMI-updateUI",cmsClient.getScreenBase64(args));
|
||||
}
|
||||
@@ -12,10 +12,12 @@ export default {
|
||||
},
|
||||
created() {
|
||||
Factory.Get(MessageService).subscribeToChannel("show-modal", args => {
|
||||
Factory.Get(MessageService).publishToChannel("HMI-show-modal");
|
||||
this.currentView = args[0];
|
||||
});
|
||||
|
||||
Factory.Get(MessageService).subscribeToChannel("hide-modal", args => {
|
||||
Factory.Get(MessageService).publishToChannel("HMI-hide-modal",300);
|
||||
this.currentView = null;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
</template>
|
||||
<script>
|
||||
import { alarmsModelActions } from "src/store";
|
||||
import { Factory, MessageService } from "src/_base";
|
||||
|
||||
export default {
|
||||
props: {
|
||||
@@ -48,6 +49,11 @@ export default {
|
||||
this.serviceExpanded = true;
|
||||
alarmsModelActions.toggleOpened(this.$store, false);
|
||||
|
||||
if(this.$store.state.alarms.opened || this.$store.state.alarms.serviceOpened)
|
||||
Factory.Get(MessageService).publishToChannel("HMI-show-alarms");
|
||||
else
|
||||
Factory.Get(MessageService).publishToChannel("HMI-hide-alarms",300);
|
||||
|
||||
},
|
||||
|
||||
toggleExpanded() {
|
||||
@@ -58,6 +64,13 @@ export default {
|
||||
|
||||
this.serviceExpanded = false;
|
||||
alarmsModelActions.toggleServiceOpened(this.$store, false);
|
||||
|
||||
|
||||
if(this.$store.state.alarms.opened || this.$store.state.alarms.serviceOpened)
|
||||
Factory.Get(MessageService).publishToChannel("HMI-show-alarms");
|
||||
else
|
||||
Factory.Get(MessageService).publishToChannel("HMI-hide-alarms",300);
|
||||
|
||||
}
|
||||
},
|
||||
data: function() {
|
||||
|
||||
@@ -24,7 +24,6 @@ export default class UserInfo extends Vue {
|
||||
doLogout() {
|
||||
ModalHelper.HideModal();
|
||||
Factory.Get(LoginService).Logout();
|
||||
|
||||
}
|
||||
|
||||
get somethingChanged() {
|
||||
|
||||
Reference in New Issue
Block a user