diff --git a/Libs/CMS_CORE_Library.dll b/Libs/CMS_CORE_Library.dll
index 3a0456d3..3ee70c99 100644
Binary files a/Libs/CMS_CORE_Library.dll and b/Libs/CMS_CORE_Library.dll differ
diff --git a/Step.Config/Config/areasConfig.xml b/Step.Config/Config/areasConfig.xml
index 790f4cb6..9fe3e547 100644
--- a/Step.Config/Config/areasConfig.xml
+++ b/Step.Config/Config/areasConfig.xml
@@ -1,86 +1,38 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+ true
+ false
+ true
+
+
+ true
+ false
+ true
+
+
+ true
+ true
+ true
+
+
+ false
+ true
+ false
+
+
+ true
+ false
+ true
+
+
+ true
+ false
+ false
+
+
+ true
+ true
+ true
+
+
\ No newline at end of file
diff --git a/Step.Config/Config/areasConfigValidator.xsd b/Step.Config/Config/areasConfigValidator.xsd
index 633c4878..386f9918 100644
--- a/Step.Config/Config/areasConfigValidator.xsd
+++ b/Step.Config/Config/areasConfigValidator.xsd
@@ -1,82 +1,74 @@
-
+
-
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/Step.Config/Config/ncSoftKeyConfig.xml b/Step.Config/Config/ncSoftKeyConfig.xml
new file mode 100644
index 00000000..050f9417
--- /dev/null
+++ b/Step.Config/Config/ncSoftKeyConfig.xml
@@ -0,0 +1,116 @@
+
+
+
+ true
+ Auto
+
+
+ true
+ Edit
+
+
+ true
+ Mdi
+
+
+ true
+ Dnc
+
+ [
+ true
+ Ref
+ ]
+
+ true
+ Jog
+
+
+ true
+ Jog Inc
+
+
+ true
+ Restart
+
+
+ true
+ Teach
+
+
+ true
+ Restract
+
+
+ true
+ Wcs Mcs
+
+
+ true
+ Handle
+
+
+ true
+ Reset
+
+
+
+ true
+ Blk/Blk
+
+
+ true
+ Blk Del
+
+
+ true
+ OpStop
+
+
+ true
+ DryRun
+
+
+ true
+ PrgTest
+
+
+ true
+ Manual Handle Interrupt
+
+
+ true
+ Teach In
+
+
+ true
+ Inc Plane
+
+
+ true
+ +
+
+
+ true
+ -
+
+
+ true
+ Rapid
+
+
+ true
+ x1
+
+
+ true
+ x10
+
+
+ true
+ x10
+
+
+ true
+ x10
+
+
\ No newline at end of file
diff --git a/Step.Config/Config/ncSoftKeyConfigValidator.xsd b/Step.Config/Config/ncSoftKeyConfigValidator.xsd
new file mode 100644
index 00000000..3217250c
--- /dev/null
+++ b/Step.Config/Config/ncSoftKeyConfigValidator.xsd
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Step.Config/Config/softKeyConfig.xml b/Step.Config/Config/userSoftKeyConfig.xml
similarity index 100%
rename from Step.Config/Config/softKeyConfig.xml
rename to Step.Config/Config/userSoftKeyConfig.xml
diff --git a/Step.Config/Config/softKeyConfigValidator.xsd b/Step.Config/Config/userSoftKeyConfigValidator.xsd
similarity index 100%
rename from Step.Config/Config/softKeyConfigValidator.xsd
rename to Step.Config/Config/userSoftKeyConfigValidator.xsd
diff --git a/Step.Config/ServerConfig.cs b/Step.Config/ServerConfig.cs
index 90f4bc6c..866f3fd4 100644
--- a/Step.Config/ServerConfig.cs
+++ b/Step.Config/ServerConfig.cs
@@ -19,7 +19,8 @@ namespace Step.Config
public static List FunctionsAccessConfig;
public static List AllFunctionalityDisabled;
- public static List SoftKeysConfig;
+ public static List SoftKeysConfig;
+ public static List NcSoftKeysConfig;
public static List InitialAlarmsConfig;
public static List HeadsConfig;
diff --git a/Step.Config/ServerConfigController.cs b/Step.Config/ServerConfigController.cs
index 1c8c351e..aea019a2 100644
--- a/Step.Config/ServerConfigController.cs
+++ b/Step.Config/ServerConfigController.cs
@@ -1,6 +1,5 @@
using Step.Model.ConfigModels;
using Step.Utils;
-using static Step.Utils.SupportFunctions;
using System;
using System.Globalization;
using System.Linq;
@@ -8,6 +7,7 @@ using System.Xml.Linq;
using System.Xml.Schema;
using static Step.Config.ServerConfig;
using static Step.Model.Constants;
+using static Step.Utils.SupportFunctions;
namespace Step.Config
{
@@ -20,7 +20,8 @@ namespace Step.Config
ReadServerConfig();
ReadAreaConfig();
ReadMaintenancesConfig();
- ReadSoftKeysConfig();
+ ReadNcSoftKeys();
+ ReadUserSoftKeysConfig();
ReadAlarmsConfig();
ReadHeadsConfig();
}
@@ -138,7 +139,7 @@ namespace Step.Config
}
}
- #region Read config from file
+ #region Read config from file from configuration
public static void ReadServerConfig()
{
@@ -203,22 +204,39 @@ namespace Step.Config
Deadline = DateTime.Parse(x.Element("deadline").Value),
Type = x.Element("type").Value,
CouterId = Convert.ToInt32(x.Element("counterId").Value)
- }
- )
+ })
.ToList();
}
-
- private static void ReadSoftKeysConfig()
+
+ private static void ReadNcSoftKeys()
{
- // Get Softkeys
- XDocument xmlConfigFile = GetXmlHandlerWithValidator(SOFTKEYS_CONFIG_SCHEMA_PATH, SOFTKEYS_CONFIG_PATH);
+ XDocument xmlConfigFile = GetXmlHandlerWithValidator(NC_SOFTKEYS_CONFIG_SCHEMA_PATH, NC_SOFTKEYS_CONFIG_PATH);
+ // Read Nc softkey configuration from XML
+ NcSoftKeysConfig = xmlConfigFile
+ .Root
+ .Elements()
+ .Where(x => Convert.ToBoolean(x.Element("active").Value) == true) // Filter for active softkey
+ .Select(x => new NcSoftKeysModel()
+ {
+ Id = GetPlcIdFromNcSoftKey(x.Name.ToString()),
+ Name = x.Name.ToString(),
+ VisualizedName = x.Element("visualizedName").Value,
+ IsActive = Convert.ToBoolean(x.Element("active").Value)
+ })
+ .ToList();
+ }
+
+ private static void ReadUserSoftKeysConfig()
+ {
+ // Get softkey file content
+ XDocument xmlConfigFile = GetXmlHandlerWithValidator(USER_SOFTKEYS_CONFIG_SCHEMA_PATH, USER_SOFTKEYS_CONFIG_PATH);
int id = 1;
// Read softkey configuration from XML with LINQ
SoftKeysConfig = xmlConfigFile
.Root
.Elements()
- .Where(x => Convert.ToBoolean(x.Element("active").Value) == true) // Only active softkey
- .Select(x => new SoftKeyConfigModel()
+ .Where(x => Convert.ToBoolean(x.Element("active").Value) == true) // Filter for active softkey
+ .Select(x => new UserSoftKeyConfigModel()
{
Id = id++, // autoincrement Id
PlcId = Convert.ToInt32(x.Element("plcId")?.Value), // If exists
@@ -276,8 +294,6 @@ namespace Step.Config
.ToList();
}
- #endregion Read config from file
-
-
+ #endregion Read config from file from configuration
}
}
\ No newline at end of file
diff --git a/Step.Config/Step.Config.csproj b/Step.Config/Step.Config.csproj
index 9ca61a53..4c735507 100644
--- a/Step.Config/Step.Config.csproj
+++ b/Step.Config/Step.Config.csproj
@@ -47,11 +47,11 @@
-
+
PreserveNewest
Designer
-
+
Designer
Always
@@ -77,6 +77,10 @@
PreserveNewest
+
+ PreserveNewest
+ Designer
+
Always
Designer
@@ -85,6 +89,10 @@
Designer
Always
+
+ Designer
+ Always
+
diff --git a/Step.Model/ConfigModels/NcSoftKeysModel.cs b/Step.Model/ConfigModels/NcSoftKeysModel.cs
new file mode 100644
index 00000000..b9c19c02
--- /dev/null
+++ b/Step.Model/ConfigModels/NcSoftKeysModel.cs
@@ -0,0 +1,10 @@
+namespace Step.Model.ConfigModels
+{
+ public class NcSoftKeysModel
+ {
+ public int Id;
+ public bool IsActive;
+ public string Name;
+ public string VisualizedName;
+ }
+}
\ No newline at end of file
diff --git a/Step.Model/ConfigModels/SoftKeyConfigModel.cs b/Step.Model/ConfigModels/UserSoftKeyConfigModel.cs
similarity index 94%
rename from Step.Model/ConfigModels/SoftKeyConfigModel.cs
rename to Step.Model/ConfigModels/UserSoftKeyConfigModel.cs
index 766a9572..c4477daf 100644
--- a/Step.Model/ConfigModels/SoftKeyConfigModel.cs
+++ b/Step.Model/ConfigModels/UserSoftKeyConfigModel.cs
@@ -3,7 +3,7 @@ using static Step.Model.Constants;
namespace Step.Model.ConfigModels
{
- public class SoftKeyConfigModel
+ public class UserSoftKeyConfigModel
{
public int Id { get; set; }
public Dictionary LocalizedNames { get; set; }
diff --git a/Step.Model/Constants.cs b/Step.Model/Constants.cs
index e53866f7..a2e7cbe7 100644
--- a/Step.Model/Constants.cs
+++ b/Step.Model/Constants.cs
@@ -89,8 +89,8 @@ namespace Step.Model
public const string MAINTENANCES_CONFIG_SCHEMA_PATH = CONFIG_DIRECTORY + "maintenancesConfigValidator.xsd";
public const string MAINTENANCES_CONFIG_PATH = CONFIG_DIRECTORY + "maintenancesConfig.xml";
- public const string SOFTKEYS_CONFIG_SCHEMA_PATH = CONFIG_DIRECTORY + "softKeyConfigValidator.xsd";
- public const string SOFTKEYS_CONFIG_PATH = CONFIG_DIRECTORY + "softKeyConfig.xml";
+ public const string USER_SOFTKEYS_CONFIG_SCHEMA_PATH = CONFIG_DIRECTORY + "userSoftKeyConfigValidator.xsd";
+ public const string USER_SOFTKEYS_CONFIG_PATH = CONFIG_DIRECTORY + "userSoftKeyConfig.xml";
public const string ALARMS_CONFIG_SCHEMA_PATH = CONFIG_DIRECTORY + "alarmsConfigValidator.xsd";
public const string ALARMS_CONFIG_PATH = CONFIG_DIRECTORY + "alarmsConfig.xml";
@@ -98,6 +98,9 @@ namespace Step.Model
public const string HEADS_CONFIG_SCHEMA_PATH = CONFIG_DIRECTORY + "headsConfigValidator.xsd";
public const string HEADS_CONFIG_PATH = CONFIG_DIRECTORY + "headsConfig.xml";
+ public const string NC_SOFTKEYS_CONFIG_SCHEMA_PATH = CONFIG_DIRECTORY + "ncSoftKeyConfigValidator.xsd";
+ public const string NC_SOFTKEYS_CONFIG_PATH = CONFIG_DIRECTORY + "ncSoftKeyConfig.xml";
+
public static string WEBSITE_DIRECTORY = Path.Combine(BASE_PATH, "..", "wwwroot");
public static string LANGUAGE_PACK_DIRECTORY = BASE_PATH + "\\languages\\";
public static string LANGUAGE_SCHEMA_PATH = BASE_PATH + "\\LanguageValidator.xsd";
@@ -117,7 +120,8 @@ namespace Step.Model
public const string SEND_PROCESSES_DATA = "SEND_PROCESSES_STATUS";
public const string SEND_FUNCTIONALITY_DATA = "SEND_FUNCTION_DATA";
public const string SEND_EXPIRED_MAINTENANCES_DATA = "SEND_EXPIRED_MAINTENANCES_DATA";
- public const string SEND_SOFTKEYS_DATA = "SEND_SOFT_KEYS_DATA";
+ public const string SEND_USER_SOFTKEYS_DATA = "SEND_USER_SOFTKEYS_DATA";
+ public const string SEND_NC_SOFTKEYS_DATA = "SEND_NC_SOFTKEYS_DATA";
public const string SEND_HEADS_DATA = "SEND_HEADS_DATA";
public const string BROADCAST_DATA = "BROADCAST_DATA";
diff --git a/Step.Model/DTOModels/DTONcSoftKeyModel.cs b/Step.Model/DTOModels/DTONcSoftKeyModel.cs
new file mode 100644
index 00000000..01ac0263
--- /dev/null
+++ b/Step.Model/DTOModels/DTONcSoftKeyModel.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Step.Model.DTOModels
+{
+ public class DTONcSoftKeyModel
+ {
+ public int Id;
+ public bool Active;
+ public bool Value;
+
+ public override bool Equals(object obj)
+ {
+ var item = obj as DTONcSoftKeyModel;
+
+ if (Id != item.Id)
+ return false;
+ if (Active != item.Active)
+ return false;
+ if (Value != item.Value)
+ return false;
+
+ return true;
+ }
+
+ public override int GetHashCode()
+ {
+ return base.GetHashCode();
+ }
+ }
+}
diff --git a/Step.Model/DTOModels/DTOSoftKeyModel.cs b/Step.Model/DTOModels/DTOUserSoftKeyModel.cs
similarity index 88%
rename from Step.Model/DTOModels/DTOSoftKeyModel.cs
rename to Step.Model/DTOModels/DTOUserSoftKeyModel.cs
index 214670c2..af991d64 100644
--- a/Step.Model/DTOModels/DTOSoftKeyModel.cs
+++ b/Step.Model/DTOModels/DTOUserSoftKeyModel.cs
@@ -7,7 +7,7 @@ using static Step.Model.Constants;
namespace Step.Model.DTOModels
{
- public class DTOSoftKeyConfigModel
+ public class DTOUserSoftKeyConfigModel
{
public int Id { get; set; }
public int Category { get; set; }
@@ -16,7 +16,7 @@ namespace Step.Model.DTOModels
public Dictionary SubKeys { get; set; }
}
- public class DTOSoftKeyModel
+ public class DTOUserSoftKeyModel
{
public int Id { get; set; }
public int Category { get; set; }
@@ -25,7 +25,7 @@ namespace Step.Model.DTOModels
public override bool Equals(object obj)
{
- var item = obj as DTOSoftKeyModel;
+ var item = obj as DTOUserSoftKeyModel;
if (Id != item.Id)
return false;
diff --git a/Step.Model/Step.Model.csproj b/Step.Model/Step.Model.csproj
index ccc33061..08cdf7a6 100644
--- a/Step.Model/Step.Model.csproj
+++ b/Step.Model/Step.Model.csproj
@@ -63,10 +63,11 @@
+
-
+
@@ -90,11 +91,12 @@
DTOLanguageModel.cs.d.ts
+
-
+
diff --git a/Step.NC/NcHandler.cs b/Step.NC/NcHandler.cs
index 0433706f..30a9aeb5 100644
--- a/Step.NC/NcHandler.cs
+++ b/Step.NC/NcHandler.cs
@@ -441,13 +441,13 @@ namespace Step.NC
return cmsError;
}
- public CmsError GetSoftKeys(out List softKeys)
+ public CmsError GetUserSoftKeys(out List softKeys)
{
- softKeys = new List();
+ softKeys = new List();
List plcSoftKeys = new List();
// Get softkeys data from PLC
- CmsError cmsError = numericalControl.PLC_RSoftKeys(ref plcSoftKeys);
+ CmsError cmsError = numericalControl.PLC_RUserSoftKeys(ref plcSoftKeys);
if (cmsError.IsError())
return cmsError;
@@ -459,10 +459,10 @@ namespace Step.NC
// Foreach subkey create a softkey
foreach (var subkey in softKey.SubKeys)
{
- // Find plc value
+ // Find the plc matching data
var plcSoftKey = plcSoftKeys.Find(x => x.Id == subkey.PlcId);
- // Set data
- softKeys.Add(new DTOSoftKeyModel()
+ // Create and add new user softkey model
+ softKeys.Add(new DTOUserSoftKeyModel()
{
Id = subkey.Id,
Active = plcSoftKey.Active,
@@ -473,9 +473,9 @@ namespace Step.NC
}
else
{
- // Find plc value
+ // Find the plc matching data
var plcSoftKey = plcSoftKeys.Find(x => x.Id == softKey.PlcId);
- softKeys.Add(new DTOSoftKeyModel()
+ softKeys.Add(new DTOUserSoftKeyModel()
{
Id = softKey.Id,
Active = plcSoftKey.Active,
@@ -487,6 +487,32 @@ namespace Step.NC
return cmsError;
}
+ public CmsError GetNcSoftKeys(out List ncSoftKeys)
+ {
+ ncSoftKeys = new List();
+ List plcSoftKeys = new List();
+
+ // Get Nc softkeys data from PLC
+ CmsError cmsError = numericalControl.PLC_RNcSoftKeys(ref plcSoftKeys);
+ if (cmsError.IsError())
+ return cmsError;
+
+ foreach (var softKey in NcSoftKeysConfig)
+ {
+ // Find the plc matching data
+ var plcSoftKey = plcSoftKeys.Find(x => x.Id == softKey.Id);
+
+ // Create and add Nc softkey model
+ ncSoftKeys.Add(new DTONcSoftKeyModel()
+ {
+ Id = softKey.Id,
+ Active = plcSoftKey.Active,
+ Value = plcSoftKey.Value
+ });
+ }
+
+ return cmsError;
+ }
public CmsError GetHeadsData(out List heads)
{
@@ -566,10 +592,18 @@ namespace Step.NC
#region Write data
- public CmsError PutSoftKeyValue(uint id)
+ public CmsError PutNcSoftKeyClick(uint id)
{
- // Write softkey pression to plc
- CmsError cmsError = numericalControl.PLC_WSoftKey(id);
+ // Write Nc softkey press to plc
+ CmsError cmsError = numericalControl.PLC_WNcSoftKey(id);
+
+ return cmsError;
+ }
+
+ public CmsError PutUserSoftKeyClick(uint id)
+ {
+ // Write user softkey press to plc
+ CmsError cmsError = numericalControl.PLC_WNcSoftKey(id);
return cmsError;
}
diff --git a/Step.Tasks/ThreadsFunctions.cs b/Step.Tasks/ThreadsFunctions.cs
index 19b444cf..58be7a3e 100644
--- a/Step.Tasks/ThreadsFunctions.cs
+++ b/Step.Tasks/ThreadsFunctions.cs
@@ -18,7 +18,8 @@ public static class ThreadsFunctions
private static long ReadProcPPTimer = 0, ReadProcPPTimes = 0;
private static long ReadFunctionTimer = 0, ReadFunctionTimes = 0;
private static long ReadMaintenanceTimer = 0, ReadMaintenanceTimes = 0;
- private static long ReadSoftKeysTimer = 0, ReadSoftKeysTimes = 0;
+ private static long ReadUserSoftKeysTimer = 0, ReadUserSoftKeysTimes = 0;
+ private static long ReadNcSoftKeysTimer = 0, ReadNcSoftKeysTimes = 0;
private static Thread ConnThread;
@@ -53,7 +54,7 @@ public static class ThreadsFunctions
TryNcConnection();
sw.Stop();
- //Send to the UI the time
+ //Update thread timer
ReadAlarmsTimer += sw.ElapsedMilliseconds;
ReadAlarmsTimes++;
@@ -96,7 +97,7 @@ public static class ThreadsFunctions
TryNcConnection();
sw.Stop();
- //Send time to the UI
+ // Update thread timer
ReadPowerOnTimer += sw.ElapsedMilliseconds;
ReadPowerOnTimes++;
@@ -141,7 +142,8 @@ public static class ThreadsFunctions
TryNcConnection();
sw.Stop();
- //Send to the UI the time
+
+ // Update thread timer
ReadProcPPTimer += sw.ElapsedMilliseconds;
ReadProcPPTimes++;
@@ -185,7 +187,8 @@ public static class ThreadsFunctions
TryNcConnection();
sw.Stop();
- //Send to the UI the time
+
+ // Update thread timer
ReadFunctionTimer += sw.ElapsedMilliseconds;
ReadFunctionTimes++;
@@ -229,7 +232,8 @@ public static class ThreadsFunctions
TryNcConnection();
sw.Stop();
- //Send to the UI the time
+
+ // Update thread timer
ReadMaintenanceTimer += sw.ElapsedMilliseconds;
ReadMaintenanceTimes++;
@@ -243,7 +247,7 @@ public static class ThreadsFunctions
}
}
- public static void ReadSoftKeysData()
+ public static void ReadUserSoftKeysData()
{
NcHandler ncHandler = new NcHandler();
Stopwatch sw = new Stopwatch();
@@ -261,21 +265,67 @@ public static class ThreadsFunctions
if (ncHandler.numericalControl.NC_IsConnected())
{
- // Get Data from config and PLC
- libraryError = ncHandler.GetSoftKeys(out List softKeys);
+ // Get softkey data from config and PLC
+ libraryError = ncHandler.GetUserSoftKeys(out List softKeys);
if (libraryError.errorCode != 0)
ManageLibraryError(libraryError);
else
// Send through signalR
- MessageServices.Current.Publish(SEND_SOFTKEYS_DATA, null, softKeys);
+ MessageServices.Current.Publish(SEND_USER_SOFTKEYS_DATA, null, softKeys);
}
else
TryNcConnection();
sw.Stop();
- //Send to the UI the time
- ReadSoftKeysTimer += sw.ElapsedMilliseconds;
- ReadSoftKeysTimes++;
+
+ // Update thread timer
+ ReadUserSoftKeysTimer += sw.ElapsedMilliseconds;
+ ReadUserSoftKeysTimes++;
+
+ // Wait
+ Thread.Sleep(200);
+ }
+ }
+ catch (ThreadAbortException)
+ {
+ ncHandler.Dispose();
+ }
+ }
+
+ public static void ReadNcSoftKeysData()
+ {
+ NcHandler ncHandler = new NcHandler();
+ Stopwatch sw = new Stopwatch();
+
+ try
+ {
+ // Try connection
+ CmsError libraryError = ncHandler.Connect();
+ if (libraryError.errorCode != 0)
+ ManageLibraryError(libraryError);
+
+ while (true)
+ {
+ sw.Restart();
+
+ if (ncHandler.numericalControl.NC_IsConnected())
+ {
+ // Get softkey data from config and PLC
+ libraryError = ncHandler.GetNcSoftKeys(out List ncSoftKeys);
+ if (libraryError.errorCode != 0)
+ ManageLibraryError(libraryError);
+ else
+ // Send through signalR
+ MessageServices.Current.Publish(SEND_NC_SOFTKEYS_DATA, null, ncSoftKeys);
+ }
+ else
+ TryNcConnection();
+
+ sw.Stop();
+
+ // Update thread timer
+ ReadUserSoftKeysTimer += sw.ElapsedMilliseconds;
+ ReadUserSoftKeysTimes++;
// Wait
Thread.Sleep(200);
@@ -317,9 +367,10 @@ public static class ThreadsFunctions
TryNcConnection();
sw.Stop();
- //Send to the UI the time
- ReadSoftKeysTimer += sw.ElapsedMilliseconds;
- ReadSoftKeysTimes++;
+
+ //Update thread timer
+ ReadNcSoftKeysTimer += sw.ElapsedMilliseconds;
+ ReadNcSoftKeysTimes++;
// Wait
Thread.Sleep(500);
@@ -472,11 +523,17 @@ public static class ThreadsFunctions
ReadMaintenanceTimer = 0;
ReadMaintenanceTimes = 0;
}
- if (ThreadsHandler.RunningThreadStatus.ContainsKey("ReadSoftKeysData") && ReadSoftKeysTimes != 0)
+ if (ThreadsHandler.RunningThreadStatus.ContainsKey("ReadUserSoftKeysData") && ReadUserSoftKeysTimes != 0)
{
- ThreadsHandler.RunningThreadStatus["ReadSoftKeysData"] = (ReadSoftKeysTimer / ReadSoftKeysTimes) + " mS";
- ReadSoftKeysTimer = 0;
- ReadSoftKeysTimes = 0;
+ ThreadsHandler.RunningThreadStatus["ReadUserSoftKeysData"] = (ReadUserSoftKeysTimer / ReadUserSoftKeysTimes) + " mS";
+ ReadUserSoftKeysTimer = 0;
+ ReadUserSoftKeysTimes = 0;
+ }
+ if (ThreadsHandler.RunningThreadStatus.ContainsKey("ReadNcSoftKeysData") && ReadNcSoftKeysTimes != 0)
+ {
+ ThreadsHandler.RunningThreadStatus["ReadNcSoftKeysData"] = (ReadNcSoftKeysTimer / ReadNcSoftKeysTimes) + " mS";
+ ReadNcSoftKeysTimer = 0;
+ ReadNcSoftKeysTimes = 0;
}
MessageServices.Current.Publish(SEND_THREADS_STATUS, null, ThreadsHandler.RunningThreadStatus);
diff --git a/Step.Tasks/ThreadsHandler.cs b/Step.Tasks/ThreadsHandler.cs
index cd362592..74d4c5a0 100644
--- a/Step.Tasks/ThreadsHandler.cs
+++ b/Step.Tasks/ThreadsHandler.cs
@@ -16,7 +16,8 @@ namespace Step.Core
ThreadsFunctions.ReadProcessesPPStatus,
ThreadsFunctions.ReadEnabledFunctionality,
ThreadsFunctions.ReadExpiredMaintenances,
- ThreadsFunctions.ReadSoftKeysData,
+ ThreadsFunctions.ReadNcSoftKeysData,
+ ThreadsFunctions.ReadUserSoftKeysData,
ThreadsFunctions.ReadHeadsData
};
diff --git a/Step.Utils/supportFunctions.cs b/Step.Utils/supportFunctions.cs
index 479dd41a..e085811c 100644
--- a/Step.Utils/supportFunctions.cs
+++ b/Step.Utils/supportFunctions.cs
@@ -24,5 +24,41 @@ namespace Step.Utils
}
}
+
+ public static int GetPlcIdFromNcSoftKey(string softKey)
+ {
+ switch (softKey)
+ {
+ case "auto": return 0;
+ case "edit": return 1;
+ case "mdi": return 2;
+ case "dnc": return 3;
+ case "ref": return 4;
+ case "jog": return 5;
+ case "jogInc": return 6;
+ case "restart": return 7;
+ case "teach": return 8;
+ case "retract": return 9;
+ case "wcsMcs": return 10;
+ case "handle": return 11;
+ case "reset": return 12;
+ case "blk": return 13;
+ case "blkDel": return 14;
+ case "opStop": return 15;
+ case "dryRun": return 16;
+ case "prgTest": return 17;
+ case "manualHandleInterrupt": return 18;
+ case "teachIn": return 19;
+ case "incPlane": return 20;
+ case "plus": return 21;
+ case "minus": return 22;
+ case "rapid": return 23;
+ case "xOne": return 24;
+ case "xTen": return 25;
+ case "xHundred": return 26;
+ case "xThousand": return 27;
+ default: return -1;
+ }
+ }
}
}
diff --git a/Step/Controllers/SignalR/NcHub.cs b/Step/Controllers/SignalR/NcHub.cs
index 52f210c3..4a2d9af6 100644
--- a/Step/Controllers/SignalR/NcHub.cs
+++ b/Step/Controllers/SignalR/NcHub.cs
@@ -92,7 +92,19 @@ namespace Step.Controllers.SignalR
MessageServices.Current.Publish(SHOW_MSG_UI, null, "Recovery Alarm. ID: " + id);
}
- public void UserSoftKeyClicked(int id)
+ public void NcSoftKeyClick(int id)
+ {
+ using (NcHandler ncHandler = new NcHandler())
+ {
+ ncHandler.Connect();
+ // Write click into plc memory
+ CmsError libraryError = ncHandler.PutNcSoftKeyClick((uint)id);
+ if (libraryError.IsError())
+ throw new HubException(libraryError.message);
+ }
+ }
+
+ public void UserSoftKeyClick(int id)
{
using (NcHandler ncHandler = new NcHandler())
{
@@ -108,7 +120,7 @@ namespace Step.Controllers.SignalR
if (subkey.Id == id)
{
// Write click button
- ncHandler.PutSoftKeyValue((uint)softKey.PlcId);
+ ncHandler.PutUserSoftKeyClick((uint)softKey.PlcId);
break;
}
}
@@ -118,7 +130,7 @@ namespace Step.Controllers.SignalR
if (softKey.Id == id)
{
// Write click button
- ncHandler.PutSoftKeyValue((uint)softKey.PlcId);
+ ncHandler.PutUserSoftKeyClick((uint)softKey.PlcId);
break;
}
}
@@ -131,8 +143,6 @@ namespace Step.Controllers.SignalR
using (NcHandler ncHandler = new NcHandler())
{
CmsError libraryError = ncHandler.Connect();
- if (libraryError.IsError())
- throw new HubException(libraryError.message);
libraryError = ncHandler.PutSelectProcess(procNumber);
if (libraryError.IsError())
diff --git a/Step/Controllers/WebApi/ConfigurationController.cs b/Step/Controllers/WebApi/ConfigurationController.cs
index cf0cf72a..33d49873 100644
--- a/Step/Controllers/WebApi/ConfigurationController.cs
+++ b/Step/Controllers/WebApi/ConfigurationController.cs
@@ -43,17 +43,24 @@ namespace Step.Controllers.WebApi
return Ok(clientConfiguration);
}
+
+ [Route("nc_softKeys"), HttpGet]
+ public IHttpActionResult GetNcSoftKeysConfig()
+ {
+ return Ok(NcSoftKeysConfig);
+ }
+
[Route("softKeys"), HttpGet]
public IHttpActionResult GetSoftKeysConfig()
{
- Dictionary> output = new Dictionary>();
+ Dictionary> output = new Dictionary>();
foreach (var softKey in SoftKeysConfig)
{
// Check if category exists
if (!output.ContainsKey(softKey.Category))
{
// Add category if not exits
- output.Add(softKey.Category, new List< DTOSoftKeyConfigModel>());
+ output.Add(softKey.Category, new List< DTOUserSoftKeyConfigModel>());
}
// Create subkeys dictionary for group
@@ -67,7 +74,7 @@ namespace Step.Controllers.WebApi
}
}
// Add to the category the new softkey
- output[softKey.Category].Add(new DTOSoftKeyConfigModel()
+ output[softKey.Category].Add(new DTOUserSoftKeyConfigModel()
{
Id = softKey.Id,
Category = softKey.Category,
@@ -93,5 +100,6 @@ namespace Step.Controllers.WebApi
return Ok(heads);
}
+
}
}
\ No newline at end of file
diff --git a/Step/Listeners/ListenersHandler.cs b/Step/Listeners/ListenersHandler.cs
index 4bca0e3b..bbb86207 100644
--- a/Step/Listeners/ListenersHandler.cs
+++ b/Step/Listeners/ListenersHandler.cs
@@ -47,9 +47,13 @@ namespace Step.Listeners
{
SignalRListener.SendExpMaintenancesData(a);
}));
- infos.Add(MessageServices.Current.Subscribe(SEND_SOFTKEYS_DATA, async (a, b) =>
+ infos.Add(MessageServices.Current.Subscribe(SEND_NC_SOFTKEYS_DATA, async (a, b) =>
{
- SignalRListener.SendSoftKeysData(a);
+ SignalRListener.SendNcSoftKeysData(a);
+ }));
+ infos.Add(MessageServices.Current.Subscribe(SEND_USER_SOFTKEYS_DATA, async (a, b) =>
+ {
+ SignalRListener.SendUserSoftKeysData(a);
}));
infos.Add(MessageServices.Current.Subscribe(SEND_HEADS_DATA, async (a, b) =>
{
diff --git a/Step/Listeners/SignalR/SignalRListener.cs b/Step/Listeners/SignalR/SignalRListener.cs
index 019d64b4..92d7eb54 100644
--- a/Step/Listeners/SignalR/SignalRListener.cs
+++ b/Step/Listeners/SignalR/SignalRListener.cs
@@ -17,7 +17,8 @@ namespace Step.Listeners.SignalR
private static List LastExpiredMaintenances = new List();
private static DTOPowerOnDataModel LastPowerOnData = new DTOPowerOnDataModel();
private static DTOProcessDataModel LastProcessesData = new DTOProcessDataModel();
- private static List LastSoftKeysData = new List();
+ private static List LastUserSoftKeysData = new List();
+ private static List LastNcSoftKeysData = new List();
private static List LastHeadsData = new List();
private static bool LastIsNcConnected = false;
@@ -88,7 +89,7 @@ namespace Step.Listeners.SignalR
// Send data to clients
context.Clients.Group("ncData").processesData(processesStatus);
}
- }
+ }
public static void SendFunctionalityData(object functionalityData)
{
@@ -118,17 +119,31 @@ namespace Step.Listeners.SignalR
}
}
- public static void SendSoftKeysData(object softKeys)
+ public static void SendNcSoftKeysData(object softKeys)
{
var context = GlobalHost.ConnectionManager.GetHubContext();
- List newData = softKeys as List;
+ List newData = softKeys as List;
// Check if collections are equals
- if (newData.Count != LastSoftKeysData.Count || !LastSoftKeysData.All(newData.Contains))
+ if (newData.Count != LastNcSoftKeysData.Count || !LastNcSoftKeysData.All(newData.Contains))
{
- LastSoftKeysData = newData;
+ LastNcSoftKeysData = newData;
// Send data to clients
- context.Clients.Group("ncData").softKeys(softKeys);
+ context.Clients.Group("ncData").ncSoftKeys(softKeys);
+ }
+ }
+
+ public static void SendUserSoftKeysData(object softKeys)
+ {
+ var context = GlobalHost.ConnectionManager.GetHubContext();
+ List newData = softKeys as List;
+
+ // Check if collections are equals
+ if (newData.Count != LastUserSoftKeysData.Count || !LastUserSoftKeysData.All(newData.Contains))
+ {
+ LastUserSoftKeysData = newData;
+ // Send data to clients
+ context.Clients.Group("ncData").userSoftKeys(softKeys);
}
}
@@ -147,6 +162,7 @@ namespace Step.Listeners.SignalR
}
private volatile static object _broadcastlock = new Object();
+
public static void BroadcastData()
{
var context = GlobalHost.ConnectionManager.GetHubContext();
@@ -170,20 +186,21 @@ namespace Step.Listeners.SignalR
// Send Maintenances
group.expiredMaintenances(LastExpiredMaintenances);
- // Send nc status
+ // Send nc status
context.Clients.Group("ncData").ncNetworkStatus(
new
{
connected = LastIsNcConnected
});
// Send softkeys
- context.Clients.Group("ncData").softKeys(LastSoftKeysData);
+ context.Clients.Group("ncData").ncSoftKeys(LastNcSoftKeysData);
+
+ context.Clients.Group("ncData").userSoftKeys(LastUserSoftKeysData);
// Send heads data
context.Clients.Group("ncData").heads(LastHeadsData);
Debug.WriteLine(string.Format("{0} {1} Broadcast..completed", DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"), DateTime.Now.Millisecond));
Monitor.Exit(_broadcastlock);
-
}
}
}
\ No newline at end of file