diff --git a/CMS_CORE_Library/DataStructures.cs b/CMS_CORE_Library/DataStructures.cs
index 260f3c8..b605528 100644
--- a/CMS_CORE_Library/DataStructures.cs
+++ b/CMS_CORE_Library/DataStructures.cs
@@ -404,22 +404,22 @@ namespace CMS_CORE_Library
/** Error-Mode */
ERROR = 12
};
-
+
public static IFormatProvider numberFormat = (NumberFormatInfo)CultureInfo.InvariantCulture.NumberFormat.Clone();
-
+
#endregion Constants
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- #region ToolsConfig
+ #region Tool Table Models
public enum MAGAZINE_ACTIONS
{
NONE = 0,
LOADING = 1,
UNLOADING = 2,
- TRANSFER = 3,
- GENERIC = 4
+ TRANSFER = 4,
+ GENERIC = 5
}
public enum ROTATION
@@ -550,9 +550,8 @@ namespace CMS_CORE_Library
public string Path;
public int Number;
}
-
- public class PositionWithMultiToolModel : PositionModel
+ public class PositionWithMultiToolModel : PositionModel
{
public MountedMultiToolModel ChildShank;
}
@@ -568,6 +567,7 @@ namespace CMS_CORE_Library
public string Name;
public List ChildsTools;
}
+
public class MountedToolModel
{
public int Id;
@@ -581,7 +581,23 @@ namespace CMS_CORE_Library
public int ToolId;
}
+ public class MagazineActionModel
+ {
+ public MAGAZINE_ACTIONS action;
+ public int OriginMagazine;
+ public int OriginPosition;
+ public int DestinationMagazine;
+ public int DestinationPosition;
+ public MagazineActionToolModel Tool;
+ }
+ public class MagazineActionToolModel
+ {
+ public int Id;
+ public int ToolType;
+ public string Name;
+ public bool IsMultitool;
+ }
///////////////// Tools Configuration
public class FieldsConfiguration
{
@@ -631,6 +647,7 @@ namespace CMS_CORE_Library
public List MagazinePosConfiguration;
public EdgesConfiguration EdgesConfiguration;
}
- #endregion ToolsConfig
+
+ #endregion Tool Table Models
}
}
\ No newline at end of file
diff --git a/CMS_CORE_Library/Demo/ILibraryService.cs b/CMS_CORE_Library/Demo/ILibraryService.cs
index af0a8c0..f73ebe6 100644
--- a/CMS_CORE_Library/Demo/ILibraryService.cs
+++ b/CMS_CORE_Library/Demo/ILibraryService.cs
@@ -225,6 +225,9 @@ namespace Nc_Demo_Application.Server.Service
[WebInvoke(Method = "PUT", UriTemplate = "tool_table/magazine/{magazineId}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
void UpdateMagazine(string magazineId, List magazine);
+
+ [WebGet(UriTemplate = "tool_table/magazines_action", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
+ void GetMagazinesAction(out MagazineActionModel magazinesAction);
#endregion
}
diff --git a/CMS_CORE_Library/Demo/Nc_Demo.cs b/CMS_CORE_Library/Demo/Nc_Demo.cs
index 6e20577..bf1e550 100644
--- a/CMS_CORE_Library/Demo/Nc_Demo.cs
+++ b/CMS_CORE_Library/Demo/Nc_Demo.cs
@@ -1654,7 +1654,6 @@ namespace CMS_CORE.Demo
config.MaxToolsPerFamily = 100;
config.MaxMultitools = 4;
config.MaxToolsPerMultitools = 3;
-
config.EdgesConfiguration.EdgesAdditionalParamsConfiguration = new Dictionary>();
// Remove path and set only names
@@ -2376,6 +2375,27 @@ namespace CMS_CORE.Demo
return NO_ERROR;
}
+
+ public override CmsError TOOLS_GetMagazinesStatus(ref MagazineActionModel magazineAction)
+ {
+ // Check if the NC Demo is Connected
+ CmsError cmsError = CheckConnection();
+ if (cmsError.IsError())
+ return cmsError;
+
+ try
+ {
+ // Call demo update
+ serverService.GetMagazinesAction(out magazineAction);
+
+ return NO_ERROR;
+ }
+ catch (Exception ex)
+ {
+ return ManageException(ex);
+ }
+ }
+
#endregion ToolTable
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs
index 1aba308..4a458a4 100644
--- a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs
+++ b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs
@@ -1783,6 +1783,11 @@ namespace CMS_CORE.Fanuc
{
return NO_ERROR;
}
+
+ public override CmsError TOOLS_GetMagazinesStatus(ref MagazineActionModel magazineAction)
+ {
+ return NO_ERROR;
+ }
#endregion Tools Management
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/CMS_CORE_Library/Nc.cs b/CMS_CORE_Library/Nc.cs
index bf10705..3ed16c8 100644
--- a/CMS_CORE_Library/Nc.cs
+++ b/CMS_CORE_Library/Nc.cs
@@ -1346,6 +1346,8 @@ namespace CMS_CORE
public abstract CmsError TOOLS_WUnloadToolFromShank(int shankId, int positionId, int toolId);
+ public abstract CmsError TOOLS_GetMagazinesStatus(ref MagazineActionModel magazineAction);
+
#endregion Tool Table
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1488,18 +1490,14 @@ namespace CMS_CORE
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#region Fixed memory area
-
+ // TODO REMOVE
//Lingua CN
internal MEMORY_CELL PARAM_LING_FANUC = new MEMORY_CELL(MEMORY_TYPE.Null, 3281, 0, 1);
//Matricola Macchina
- internal MEMORY_CELL MATR_MACCH_OSAI = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 3403, 0, 1);
-
internal MEMORY_CELL MATR_MACCH_FANUC = new MEMORY_CELL(MEMORY_TYPE.Fanuc_D, 4018, 0, 1);
- internal MEMORY_CELL MATR_MACCH_SIEMENS = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 255, 0, 1);
- //Messaggi PLC
- internal MEMORY_CELL PLC_MESS_OSAI = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 12000, 0, 64);
+ internal MEMORY_CELL MATR_MACCH_SIEMENS = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 255, 0, 1);
#endregion Fixed memory area
diff --git a/CMS_CORE_Library/Osai/Nc_Osai.cs b/CMS_CORE_Library/Osai/Nc_Osai.cs
index 84052e7..5868ffc 100644
--- a/CMS_CORE_Library/Osai/Nc_Osai.cs
+++ b/CMS_CORE_Library/Osai/Nc_Osai.cs
@@ -15,7 +15,6 @@ using System.Threading;
using static CMS_CORE_Library.DataStructures;
using static CMS_CORE.Nc;
using static CMS_CORE.Osai.MEMORY_ADDRESS;
-using CMS_CORE_Library;
namespace CMS_CORE.Osai
{
@@ -2154,7 +2153,10 @@ namespace CMS_CORE.Osai
{
return NO_ERROR;
}
-
+ public override CmsError TOOLS_GetMagazinesStatus(ref MagazineActionModel magazineAction)
+ {
+ return NO_ERROR;
+ }
#endregion Tools Management
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -2607,7 +2609,7 @@ namespace CMS_CORE.Osai
internal static class MEMORY_ADDRESS
{
internal const int STARTING_ADDRESS = 12000;
-
+ internal static MEMORY_CELL MATR_MACCH_OSAI = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 3403, 0, 1);
internal static MEMORY_CELL FUNCTION_ACCESS = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 12003, 8);
internal static MEMORY_CELL PRE_POST_POWER_ON = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 12775, 2);
diff --git a/CMS_CORE_Library/Siemens/Nc_Siemens.cs b/CMS_CORE_Library/Siemens/Nc_Siemens.cs
index e6c393a..434016f 100644
--- a/CMS_CORE_Library/Siemens/Nc_Siemens.cs
+++ b/CMS_CORE_Library/Siemens/Nc_Siemens.cs
@@ -11,13 +11,13 @@ using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
-using System.Windows.Forms;
using System.Xml.Linq;
using static CMS_CORE.Nc;
using static CMS_CORE.Siemens.MEMORY_ADDRESS;
using static CMS_CORE_Library.DataStructures;
using static CMS_CORE_Library.ToolConfigurations;
using static Siemens.Sinumerik.Operate.Services.ToolMngmntSvc;
+using static CMS_CORE.Utils.Nc_Utils;
namespace CMS_CORE.Siemens
{
@@ -103,8 +103,7 @@ namespace CMS_CORE.Siemens
private static List MultitoolsData = new List();
private static List MagazineMountedTools = new List();
public static List FamiliesData = new List();
-
- public static bool MagazineActionInProgess;
+ public static MagazineActionModel MagazineAction = new MagazineActionModel();
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -158,7 +157,7 @@ namespace CMS_CORE.Siemens
MagazinePositionSvc = new DataSvc();
MagazineActionsSvc = new DataSvc();
- ToolMngmtListGuid = SiemensToolSvc.Subscribe(TOOLS_UpdateToolsData);
+ ToolMngmtListGuid = SiemensToolSvc.Subscribe(ToolMngmtSvcHandler);
SetupToolTableData();
}
}
@@ -176,7 +175,7 @@ namespace CMS_CORE.Siemens
//Set Connected to FALSE and close the session
Connected = false;
if (SiemensToolSvc != null)
- SiemensToolSvc.UnSubscribe(TOOLS_UpdateToolsData);
+ SiemensToolSvc.UnSubscribe(ToolMngmtSvcHandler);
return NO_ERROR;
}
@@ -231,7 +230,7 @@ namespace CMS_CORE.Siemens
{
Path = "DB71.DBB0"
};
- MagazineActionsSvc.Subscribe(MagazineAction_OnChange, magActionsItem);
+ MagazineActionsSvc.Subscribe(MagazineStatus_OnChange, magActionsItem);
}
public override CmsError NC_GetTranslatedPlcMessages(string language, ref Dictionary messages)
@@ -1868,154 +1867,6 @@ namespace CMS_CORE.Siemens
return NO_ERROR;
}
-
- private void MagazinePosition_OnChange(Guid guid, Item[] items, DataSvcStatus[] status)
- {
- // Parse each new item
- foreach (Item item in items)
- {
- // Get Ids
- string[] ids = item.SymbolicName.Split('_');
- int magazineId = Convert.ToInt32(ids[0]);
- int positionId = Convert.ToInt32(ids[1]);
-
- foreach (PositionModel pos in MagazinePositionsData)
- {
- // Find position
- if (pos.PositionId == positionId && pos.MagazineId == magazineId)
- {
- // Set Value
- pos.Disabled = GetBitValue(Convert.ToInt32(item.Value), 1);
- }
- }
- }
- }
-
- private void MagazineAction_OnChange(Guid guid, Item item, DataSvcStatus status)
- {
- DataSvc dataSvc = new DataSvc();
-
- Item action = new Item("DB71.DBB4");
- dataSvc.Read(action);
-
- switch ((MAGAZINE_ACTIONS)Convert.ToInt32(action.Value))
- {
- case MAGAZINE_ACTIONS.NONE: break;
- case MAGAZINE_ACTIONS.LOADING:
- {
- List- magazineValue = new List
- ()
- {
- new Item("DB71.DBW28"), // Mag Id
- new Item("DB71.DBW30"), // Pos Id
- };
- // Get tool id
- dataSvc.Read(magazineValue.ToArray());
- uint paramId = (((uint)magazineValue[1].Value - 1) * 11) + 5;
- Item toolId = new Item(string.Format("/Tool/Magazine/placeData[c{0} , {1}]", (uint)magazineValue[0].Value, paramId));
- dataSvc.Read(toolId);
- }
- break;
- case MAGAZINE_ACTIONS.UNLOADING:
- {
- List
- magazineValue = new List
- ()
- {
- new Item("DB71.DBW24"), // Mag Id
- new Item("DB71.DBW26"), // Pos Id
- };
- // Get tool id
- dataSvc.Read(magazineValue.ToArray());
- uint paramId = (((uint)magazineValue[1].Value - 1) * 11) + 5;
- Item toolId = new Item(string.Format("/Tool/Magazine/placeData[c{0} , {1}]", (uint)magazineValue[0].Value, paramId));
- dataSvc.Read(toolId);
- }
- break;
- case MAGAZINE_ACTIONS.TRANSFER:
- {
-
- }break;
- default:
- {
-
- }break;
- }
-
-
-
- MessageBox.Show(item.Value.ToString());
- }
-
- private void TOOLS_UpdateToolsData(Guid guid, ToolInfo[] toolInfos)
- {
- try
- {
- // For each new action
- for (int i = 0; i < toolInfos.Count(); i++)
- { // Choose behavior based on the actions
- TOOLS_ChooseActions(toolInfos[i]);
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.Message);
- }
- }
-
- private void AddOrUpdateFamilyChild(string familyName)
- {
- // Find family
- int familyIndex = FamiliesData.FindIndex(x => x.Name == familyName);
- if (familyIndex < 0)
- {
- // Create family and add child
- FamiliesData.Add(new FamilyModel()
- {
- Name = familyName
- });
- }
- }
-
- private static void GetIdsFromSiemensString(string text, out int toolId, out int edgeId)
- {
- toolId = 0;
- edgeId = 0;
-
- if (!String.IsNullOrWhiteSpace(text))
- {
- // Get indexes from string
- int startingData = text.IndexOf("[", StringComparison.Ordinal) + 1;
- int secondData = text.IndexOf(",", StringComparison.Ordinal) + 1;
- int endingData = text.IndexOf("]", StringComparison.Ordinal);
- // If the string is matching with the pattern STRING[N]=N or STRING[N,M]=N
- if (startingData > 0 && endingData > 0)
- // STRING[N,M]=N case
- if (secondData > 0)
- {
- toolId = Convert.ToInt32(text.Substring(startingData, secondData - (startingData + 1)));
- edgeId = Convert.ToInt32(text.Substring(secondData, endingData - (secondData)));
- }
- else // STRING[N]=N case
- {
- toolId = Convert.ToInt32(text.Substring(startingData, endingData - (startingData)));
- edgeId = 0;
- }
- }
- }
-
- public static string GetUntilOrEmpty(string text, string stopAt = "[")
- {
- // Get string unti
- if (!String.IsNullOrWhiteSpace(text))
- {
- // Find character index
- int charLocation = text.IndexOf(stopAt, StringComparison.Ordinal);
-
- if (charLocation > 0)
- return text.Substring(0, charLocation);
- }
-
- return String.Empty;
- }
-
public override CmsError TOOLS_RShanksData(ref List shanksData)
{
@@ -2148,7 +1999,6 @@ namespace CMS_CORE.Siemens
return NO_ERROR;
}
-
public override CmsError TOOLS_WUpdateFamilyData(string oldName, string newName)
{
@@ -2617,6 +2467,12 @@ namespace CMS_CORE.Siemens
return NO_ERROR;
}
+ public override CmsError TOOLS_GetMagazinesStatus(ref MagazineActionModel magazineAction)
+ {
+ magazineAction = MagazineAction;
+ return NO_ERROR;
+ }
+
#endregion Tool Management
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -2990,11 +2846,499 @@ namespace CMS_CORE.Siemens
}
}
-
- #endregion Subordinate private functions
+ #endregion Subordinate Private Functions
#region Tool private functions
-
+
+ private void MagazinePosition_OnChange(Guid guid, Item[] items, DataSvcStatus[] status)
+ {
+ // Parse each new item
+ foreach (Item item in items)
+ {
+ // Get Ids
+ string[] ids = item.SymbolicName.Split('_');
+ int magazineId = Convert.ToInt32(ids[0]);
+ int positionId = Convert.ToInt32(ids[1]);
+
+ foreach (PositionModel pos in MagazinePositionsData)
+ {
+ // Find position
+ if (pos.PositionId == positionId && pos.MagazineId == magazineId)
+ {
+ // Set Value
+ pos.Disabled = GetBitValue(Convert.ToInt32(item.Value), 1);
+ }
+ }
+ }
+ }
+
+ private void MagazineStatus_OnChange(Guid guid, Item item, DataSvcStatus status)
+ {
+ DataSvc dataSvc = new DataSvc();
+ Item action = new Item("DB71.DBB4");
+ dataSvc.Read(action);
+
+ if ((uint)item.Value == 0)
+ {
+ MagazineAction = new MagazineActionModel()
+ {
+ action = MAGAZINE_ACTIONS.NONE,
+ OriginMagazine = 0,
+ OriginPosition = 0,
+ DestinationMagazine = 0,
+ DestinationPosition = 0,
+ Tool = null
+ };
+ }
+ else
+ {
+ List
- magazineValue = new List
- ()
+ {
+ new Item("DB71.DBW20"), // Intermediate mag Id
+ new Item("DB71.DBW22"), // intermediate pos Id
+
+ new Item("DB71.DBW24"), // Unload mag Id
+ new Item("DB71.DBW26"), // Unload pos Id
+
+ new Item("DB71.DBW28"), // Load mag Id
+ new Item("DB71.DBW30") // Load pos Id
+ };
+
+ // Read magazine positions
+ dataSvc.Read(magazineValue.ToArray());
+
+ uint toolMagId = 0;
+ uint toolPosId = 0;
+ uint toolId = 0;
+
+ switch ((MAGAZINE_ACTIONS)Convert.ToInt32(action.Value))
+ {
+ case MAGAZINE_ACTIONS.LOADING:
+ {
+ toolPosId = (((uint)magazineValue[1].Value - 1) * 11) + 3; // (position_id - 1) * 11 + 3
+ toolMagId = (uint)magazineValue[0].Value;
+ }
+ break;
+
+ case MAGAZINE_ACTIONS.UNLOADING:
+ {
+ toolPosId = (((uint)magazineValue[3].Value - 1) * 11) + 3;
+ toolMagId = (uint)magazineValue[2].Value;
+ }
+ break;
+
+ case MAGAZINE_ACTIONS.TRANSFER:
+ {
+ toolPosId = (((uint)magazineValue[3].Value - 1) * 11) + 3;
+ toolMagId = (uint)magazineValue[2].Value;
+ }
+ break;
+ }
+ // If position and magazine exist
+ if (toolMagId != 0 && toolPosId != 0)
+ {
+ // Read tool id
+ Item toolIdItem = new Item(string.Format("/Tool/Magazine/placeData[c{0} , {1}]", toolMagId, toolPosId));
+ dataSvc.Read(toolIdItem);
+ toolId = (uint)toolIdItem.Value;
+ }
+
+ // Find tool data into tools list
+ MagazineActionToolModel tool = ToolTableData.Where(x => x.Id == toolId)?.Select(x => new MagazineActionToolModel
+ {
+ Id = x.Id,
+ Name = x.FamilyName,
+ ToolType = x.ToolType,
+ IsMultitool = false
+ }).FirstOrDefault();
+
+ if (tool == null)
+ // If not found in the tools list, find in the multitools
+ tool = MultitoolsData.Where(x => x.Id == toolId)?.Select(x => new MagazineActionToolModel
+ {
+ Id = x.Id,
+ Name = x.Name,
+ ToolType = 0,
+ IsMultitool = true
+ }).FirstOrDefault();
+
+ MagazineAction = new MagazineActionModel()
+ {
+ action = (MAGAZINE_ACTIONS)Convert.ToInt32(action.Value),
+ OriginMagazine = Convert.ToInt32(magazineValue[4].Value),
+ OriginPosition = Convert.ToInt32(magazineValue[5].Value),
+ DestinationMagazine = Convert.ToInt32(magazineValue[2].Value),
+ DestinationPosition = Convert.ToInt32(magazineValue[3].Value),
+ Tool = tool
+ };
+ }
+
+ Console.WriteLine(item.Value.ToString());
+ }
+
+ private void PopulateToolsTableFromFileStrings(string[] toolsStrings)
+ {
+ SiemensEdgesConfiguration toolEdgesConfig = new SiemensEdgesConfiguration();
+
+ int lastFirstId = 0;
+ int lastSecondId = 0;
+ int toolIndex = 0;
+ int edgeIndex = 0;
+ int multitoolIndex = 0;
+
+ // Foreach string
+ for (int i = 0; i < toolsStrings.Count(); i++)
+ {
+ string actualString = toolsStrings[i]; // Get actual string data
+
+ GetIdsFromSiemensString(actualString, out int firstId, out int secondId); // find ids from current string
+
+ if (firstId != 0)
+ {
+ // If tool is changed, change current index tool
+ if (lastFirstId != firstId)
+ {
+ toolIndex = ToolTableData.FindIndex(x => x.Id == firstId);
+ multitoolIndex = MultitoolsData.FindIndex(x => x.Id == firstId);
+ }
+
+ if (secondId == 0)
+ {
+ switch (GetUntilOrEmpty(actualString)) // Cut string until [ character
+ {
+ case "$TC_TP1":
+ {
+ ToolTableData.Add(new SiemensToolModel()
+ {
+ Id = firstId,
+ ChildId = Convert.ToInt32(actualString.Split('=').LastOrDefault())
+ });
+ // Update Index
+ toolIndex = ToolTableData.Count - 1;
+ }
+ break;
+
+ case "$TC_TP2":
+ {
+ string familyName = actualString.Split('=').LastOrDefault().Replace("\"", "");
+ ToolTableData[toolIndex].FamilyName = familyName;
+ // Add new family with new tool
+ AddOrUpdateFamilyChild(familyName);
+ }
+ break;
+
+ case "$TC_TP3":
+ {
+ ToolTableData[toolIndex].LeftSize = Convert.ToByte(actualString.Split('=').LastOrDefault());
+ }
+ break;
+
+ case "$TC_TP4":
+ {
+ ToolTableData[toolIndex].RightSize = Convert.ToByte(actualString.Split('=').LastOrDefault());
+ }
+ break;
+
+ case "$TC_TP7":
+ {
+ ToolTableData[toolIndex].MagazinePositionType = Convert.ToInt32(actualString.Split('=').LastOrDefault());
+ }
+ break;
+
+ case "$TC_TP8":
+ {
+ // Get tool status
+ int toolStatus = Convert.ToInt32(actualString.Split('=').LastOrDefault());
+
+ ToolTableData[toolIndex].IsActive = GetBitValue(toolStatus, 1);
+ ToolTableData[toolIndex].InFixedPlace = GetBitValue(toolStatus, 2);
+ ToolTableData[toolIndex].IsInhibited = GetBitValue(toolStatus, 3);
+ ToolTableData[toolIndex].IsMeasured = GetBitValue(toolStatus, 4);
+ ToolTableData[toolIndex].InChangeTool = GetBitValue(toolStatus, 5);
+ ToolTableData[toolIndex].IsEnabled = GetBitValue(toolStatus, 6);
+ ToolTableData[toolIndex].IsInUse = GetBitValue(toolStatus, 7);
+ ToolTableData[toolIndex].PreAlarm = GetBitValue(toolStatus, 8);
+ }
+ break;
+
+ case "$TC_TP9":
+ {
+ ToolTableData[toolIndex].LifeType = (SIEMENS_LIFE_TYPE)Convert.ToInt32(actualString.Split('=').LastOrDefault());
+ }
+ break;
+
+ case "$TC_TP25":
+ {
+ // Get tool general information
+ var toolInfo = Convert.ToInt32(actualString.Split('=').LastOrDefault());
+
+ // Convert rotation data
+ ROTATION rotation = ROTATION.NONE;
+ if (GetBitValue(toolInfo, 9))
+ rotation = ROTATION.CLOCKWHISE;
+ else if (GetBitValue(toolInfo, 10))
+ rotation = ROTATION.COUNTERCLOCKWHISE;
+ // Set new data
+
+ ToolTableData[toolIndex].Cooling1 = GetBitValue(toolInfo, 11);
+ ToolTableData[toolIndex].Cooling2 = GetBitValue(toolInfo, 12);
+ ToolTableData[toolIndex].Rotation = rotation;
+ }
+ break;
+
+ case "$TC_TP_MAX_VELO":
+ {
+ ToolTableData[toolIndex].MaxSpeed = Convert.ToDouble(actualString.Split('=').LastOrDefault(), numberFormat);
+ }
+ break;
+
+ case "$TC_TP_MAX_ACC":
+ {
+ ToolTableData[toolIndex].MaxAcceleration = Convert.ToDouble(actualString.Split('=').LastOrDefault(), numberFormat);
+ }
+ break;
+
+ case "$TC_MTPN":
+ {
+ // Insert new multitool
+ MultitoolsData.Add(new ShankModel()
+ {
+ Id = firstId,
+ MaxChilds = Convert.ToInt32(actualString.Split('=').LastOrDefault())
+ });
+ // Update Index
+ multitoolIndex = MultitoolsData.Count - 1;
+ }
+ break;
+
+ case "$TC_MTP2":
+ {
+ MultitoolsData[multitoolIndex].Name = actualString.Split('=').LastOrDefault().Replace("\"", "");
+ }
+ break;
+
+ case "$TC_MTP3":
+ {
+ MultitoolsData[multitoolIndex].LeftSize = Convert.ToInt32(actualString.Split('=').LastOrDefault());
+ }
+ break;
+
+ case "$TC_MTP4":
+ {
+ MultitoolsData[multitoolIndex].RightSize = Convert.ToInt32(actualString.Split('=').LastOrDefault());
+ }
+ break;
+
+ case "$TC_MTP7":
+ {
+ MultitoolsData[multitoolIndex].MagazinePositionType = Convert.ToInt32(actualString.Split('=').LastOrDefault());
+ }
+ break;
+
+ case "$TC_MTP8":
+ {
+ // Get tool status
+ byte toolStatus = Convert.ToByte(actualString.Split('=').LastOrDefault());
+
+ MultitoolsData[multitoolIndex].IsEnabled = GetBitValue(toolStatus, 2);
+ MultitoolsData[multitoolIndex].IsInhibited = GetBitValue(toolStatus, 3);
+ MultitoolsData[multitoolIndex].InChangeTool = GetBitValue(toolStatus, 6);
+ MultitoolsData[multitoolIndex].InFixedPlace = GetBitValue(toolStatus, 7);
+ MultitoolsData[multitoolIndex].InUse = GetBitValue(toolStatus, 8);
+ }
+ break;
+ }
+ }
+ else
+ {
+ // If secondId is changed, change current edge id
+ if (lastSecondId != secondId && toolIndex >= 0)
+ edgeIndex = ToolTableData[toolIndex].EdgesData.FindIndex(x => x.Id == secondId);
+
+ switch (GetUntilOrEmpty(actualString))
+ {
+ case "$TC_DP1":
+ {
+ if (secondId == 1) // Read tool type from first edge type
+ ToolTableData[toolIndex].ToolType = Convert.ToInt32(actualString.Split('=').LastOrDefault());
+ // Add new edge
+ ToolTableData[toolIndex].EdgesData.Add(new EdgeModel() { Id = secondId });
+ edgeIndex = ToolTableData[toolIndex].EdgesData.Count - 1; // Update Index
+ }
+ break;
+
+ case "$TC_MOP1":
+ {
+ SiemensToolModel tool = ToolTableData[toolIndex];
+ if (tool.LifeType == SIEMENS_LIFE_TYPE.TIME)
+ {
+ ToolTableData[toolIndex]
+ .EdgesData[edgeIndex]
+ .PreAlmLife = Convert.ToInt32(actualString.Split('=').LastOrDefault());
+ }
+ }
+ break;
+
+ case "$TC_MOP2":
+ {
+ SiemensToolModel tool = ToolTableData[toolIndex];
+ if (tool.LifeType == SIEMENS_LIFE_TYPE.TIME)
+ {
+ ToolTableData[toolIndex]
+ .EdgesData[edgeIndex]
+ .ResidualLife = Convert.ToInt32(actualString.Split('=').LastOrDefault());
+ }
+ }
+ break;
+
+ case "$TC_MOP11":
+ {
+ SiemensToolModel tool = ToolTableData[toolIndex];
+ if (tool.LifeType == SIEMENS_LIFE_TYPE.TIME)
+ {
+ ToolTableData[toolIndex]
+ .EdgesData[edgeIndex]
+ .NominalLife = Convert.ToInt32(actualString.Split('=').LastOrDefault());
+ }
+ }
+ break;
+
+ case "$TC_MOP3":
+ {
+ SiemensToolModel tool = ToolTableData[toolIndex];
+ if (tool.LifeType == SIEMENS_LIFE_TYPE.COUNT)
+ {
+ ToolTableData[toolIndex]
+ .EdgesData[edgeIndex]
+ .PreAlmLife = Convert.ToInt32(actualString.Split('=').LastOrDefault());
+ }
+ }
+ break;
+
+ case "$TC_MOP4":
+ {
+ SiemensToolModel tool = ToolTableData[toolIndex];
+ if (tool.LifeType == SIEMENS_LIFE_TYPE.COUNT)
+ {
+ ToolTableData[toolIndex]
+ .EdgesData[edgeIndex]
+ .ResidualLife = Convert.ToInt32(actualString.Split('=').LastOrDefault());
+ }
+ }
+ break;
+
+ case "$TC_MOP13":
+ {
+ SiemensToolModel tool = ToolTableData[toolIndex];
+ if (tool.LifeType == SIEMENS_LIFE_TYPE.COUNT)
+ {
+ ToolTableData[toolIndex]
+ .EdgesData[edgeIndex]
+ .NominalLife = Convert.ToInt32(actualString.Split('=').LastOrDefault());
+ }
+ }
+ break;
+
+ case "$TC_DP2":
+ case "$TC_DP3":
+ case "$TC_DP4":
+ case "$TC_DP5":
+ case "$TC_DP6":
+ case "$TC_DP7":
+ case "$TC_DP8":
+ case "$TC_DP9":
+ case "$TC_DP10":
+ case "$TC_DP11":
+ case "$TC_DP12":
+ case "$TC_DP13":
+ case "$TC_DP14":
+ case "$TC_DP15":
+ case "$TC_DP16":
+ case "$TC_DP17":
+ case "$TC_DP21":
+ case "$TC_DP22":
+ case "$TC_DP23":
+ case "$TC_DP24":
+ case "$TC_DP25":
+ case "$TC_DPV":
+ case "$TC_DPV3":
+ case "$TC_DPV4":
+ case "$TC_DPV5":
+ case "$TC_DPNT":
+ {
+ SiemensToolModel tool = ToolTableData[toolIndex];
+
+ // Get tool type additional parameters
+ if (toolEdgesConfig.EdgesConfig.ContainsKey(tool.ToolType))
+ {
+ // Find if actual param exist for the tool type
+ List toolTypeConfig = toolEdgesConfig.EdgesConfig[tool.ToolType];
+ EdgeConfigModel paramConfig = toolTypeConfig.Where(x => x.Path == (GetUntilOrEmpty(actualString) + "[")).FirstOrDefault();
+
+ // If Exist
+ if (paramConfig != null)
+ ToolTableData[toolIndex]
+ .EdgesData[edgeIndex]
+ .EdgeAdditionalParams // Add additional param
+ .Add(paramConfig.Name, Convert.ToDouble(actualString.Split('=').LastOrDefault(), numberFormat));
+ }
+ }
+ break;
+
+ case "$TC_MPP1":
+ {
+ MagazinePositionsData.Add(new PositionModel()
+ {
+ PositionId = secondId,
+ MagazineId = firstId,
+ Type = Convert.ToInt32(actualString.Split('=').LastOrDefault())
+ });
+ }
+ break;
+
+ case "$TC_MPP4":
+ {
+ int index = MagazinePositionsData.FindIndex(x => x.PositionId == secondId && x.MagazineId == firstId);
+ if (index >= 0)
+ MagazinePositionsData[index].Disabled = GetBitValue(Convert.ToInt32(actualString.Split('=').LastOrDefault()), 1);
+ }
+ break;
+
+ case "$TC_MPP6":
+ {
+ int toolId = Convert.ToInt32(actualString.Split('=').LastOrDefault());
+ if (toolId != 0)
+ {
+ MountToolToList(toolId, firstId, secondId);
+ }
+ }
+ break;
+
+ case "$TC_MTPP6":
+ {
+ // Find tool by id
+ int toolId = Convert.ToInt32(actualString.Split('=').LastOrDefault());
+ if (toolId != 0)
+ {
+ // Find tool by id
+ SiemensToolModel tool = ToolTableData.Where(x => x.Id == toolId).First();
+ // Add new multitool child
+ MultitoolsData[multitoolIndex].ChildsTools.Add(new ShankChildModel()
+ {
+ Id = toolId,
+ MultitoolId = secondId,
+ FamilyName = tool.FamilyName,
+ ToolType = tool.ToolType
+ });
+ }
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
+
private string[] ReadToolTableFile()
{
// Create a configuration file
@@ -3140,6 +3484,7 @@ namespace CMS_CORE.Siemens
edgeData.PreAlmLife = Convert.ToDouble(toolsString.FirstOrDefault(X => X.StartsWith("$TC_MOP1[" + toolId + "," + edgeId)).Split('=').LastOrDefault(), numberFormat);
}
break;
+
case SIEMENS_LIFE_TYPE.COUNT:
{
edgeData.ResidualLife = Convert.ToDouble(toolsString.FirstOrDefault(X => X.StartsWith("$TC_MOP4[" + toolId + "," + edgeId)).Split('=').LastOrDefault(), numberFormat);
@@ -3147,6 +3492,7 @@ namespace CMS_CORE.Siemens
edgeData.PreAlmLife = Convert.ToDouble(toolsString.FirstOrDefault(X => X.StartsWith("$TC_MOP3[" + toolId + "," + edgeId)).Split('=').LastOrDefault(), numberFormat);
}
break;
+
case SIEMENS_LIFE_TYPE.WEAR:
{
// TODO: Check params
@@ -3160,344 +3506,23 @@ namespace CMS_CORE.Siemens
return edgeData;
}
- private void PopulateToolsTableFromFileStrings(string[] toolsStrings)
+ private void ToolMngmtSvcHandler(Guid guid, ToolInfo[] toolInfos)
{
- SiemensEdgesConfiguration toolEdgesConfig = new SiemensEdgesConfiguration();
-
- int lastFirstId = 0;
- int lastSecondId = 0;
- int toolIndex = 0;
- int edgeIndex = 0;
- int multitoolIndex = 0;
-
- // Foreach string
- for (int i = 0; i < toolsStrings.Count(); i++)
+ try
{
- string actualString = toolsStrings[i]; // Get actual string data
-
- GetIdsFromSiemensString(actualString, out int firstId, out int secondId); // find ids from current string
-
- if (firstId != 0)
- {
- // If tool is changed, change current index tool
- if (lastFirstId != firstId)
- {
- toolIndex = ToolTableData.FindIndex(x => x.Id == firstId);
- multitoolIndex = MultitoolsData.FindIndex(x => x.Id == firstId);
- }
-
- if (secondId == 0)
- {
- switch (GetUntilOrEmpty(actualString)) // Cut string until [ character
- {
- case "$TC_TP1":
- {
- ToolTableData.Add(new SiemensToolModel()
- {
- Id = firstId,
- ChildId = Convert.ToInt32(actualString.Split('=').LastOrDefault())
- });
- // Update Index
- toolIndex = ToolTableData.Count - 1;
- }
- break;
- case "$TC_TP2":
- {
- string familyName = actualString.Split('=').LastOrDefault().Replace("\"", "");
- ToolTableData[toolIndex].FamilyName = familyName;
- // Add new family with new tool
- AddOrUpdateFamilyChild(familyName);
- }
- break;
- case "$TC_TP3":
- {
- ToolTableData[toolIndex].LeftSize = Convert.ToByte(actualString.Split('=').LastOrDefault());
- }
- break;
- case "$TC_TP4":
- {
- ToolTableData[toolIndex].RightSize = Convert.ToByte(actualString.Split('=').LastOrDefault());
- }
- break;
- case "$TC_TP7":
- {
- ToolTableData[toolIndex].MagazinePositionType = Convert.ToInt32(actualString.Split('=').LastOrDefault());
- }
- break;
- case "$TC_TP8":
- {
- // Get tool status
- int toolStatus = Convert.ToInt32(actualString.Split('=').LastOrDefault());
-
- ToolTableData[toolIndex].IsActive = GetBitValue(toolStatus, 1);
- ToolTableData[toolIndex].InFixedPlace = GetBitValue(toolStatus, 2);
- ToolTableData[toolIndex].IsInhibited = GetBitValue(toolStatus, 3);
- ToolTableData[toolIndex].IsMeasured = GetBitValue(toolStatus, 4);
- ToolTableData[toolIndex].InChangeTool = GetBitValue(toolStatus, 5);
- ToolTableData[toolIndex].IsEnabled = GetBitValue(toolStatus, 6);
- ToolTableData[toolIndex].IsInUse = GetBitValue(toolStatus, 7);
- ToolTableData[toolIndex].PreAlarm = GetBitValue(toolStatus, 8);
- }
- break;
- case "$TC_TP9":
- {
- ToolTableData[toolIndex].LifeType = (SIEMENS_LIFE_TYPE)Convert.ToInt32(actualString.Split('=').LastOrDefault());
- }
- break;
- case "$TC_TP25":
- {
- // Get tool general information
- var toolInfo = Convert.ToInt32(actualString.Split('=').LastOrDefault());
-
- // Convert rotation data
- ROTATION rotation = ROTATION.NONE;
- if (GetBitValue(toolInfo, 9))
- rotation = ROTATION.CLOCKWHISE;
- else if (GetBitValue(toolInfo, 10))
- rotation = ROTATION.COUNTERCLOCKWHISE;
- // Set new data
-
- ToolTableData[toolIndex].Cooling1 = GetBitValue(toolInfo, 11);
- ToolTableData[toolIndex].Cooling2 = GetBitValue(toolInfo, 12);
- ToolTableData[toolIndex].Rotation = rotation;
- }
- break;
- case "$TC_TP_MAX_VELO":
- {
- ToolTableData[toolIndex].MaxSpeed = Convert.ToDouble(actualString.Split('=').LastOrDefault(), numberFormat);
- }
- break;
- case "$TC_TP_MAX_ACC":
- {
- ToolTableData[toolIndex].MaxAcceleration = Convert.ToDouble(actualString.Split('=').LastOrDefault(), numberFormat);
- }
- break;
- case "$TC_MTPN":
- {
- // Insert new multitool
- MultitoolsData.Add(new ShankModel()
- {
- Id = firstId,
- MaxChilds = Convert.ToInt32(actualString.Split('=').LastOrDefault())
- });
- // Update Index
- multitoolIndex = MultitoolsData.Count - 1;
- }
- break;
- case "$TC_MTP2":
- {
- MultitoolsData[multitoolIndex].Name = actualString.Split('=').LastOrDefault().Replace("\"", "");
- }
- break;
- case "$TC_MTP3":
- {
- MultitoolsData[multitoolIndex].LeftSize = Convert.ToInt32(actualString.Split('=').LastOrDefault());
- }
- break;
- case "$TC_MTP4":
- {
- MultitoolsData[multitoolIndex].RightSize = Convert.ToInt32(actualString.Split('=').LastOrDefault());
- }
- break;
- case "$TC_MTP7":
- {
- MultitoolsData[multitoolIndex].MagazinePositionType = Convert.ToInt32(actualString.Split('=').LastOrDefault());
- }
- break;
- case "$TC_MTP8":
- {
- // Get tool status
- byte toolStatus = Convert.ToByte(actualString.Split('=').LastOrDefault());
-
- MultitoolsData[multitoolIndex].IsEnabled = GetBitValue(toolStatus, 2);
- MultitoolsData[multitoolIndex].IsInhibited = GetBitValue(toolStatus, 3);
- MultitoolsData[multitoolIndex].InChangeTool = GetBitValue(toolStatus, 6);
- MultitoolsData[multitoolIndex].InFixedPlace = GetBitValue(toolStatus, 7);
- MultitoolsData[multitoolIndex].InUse = GetBitValue(toolStatus, 8);
- }
- break;
- }
- }
- else
- {
- // If secondId is changed, change current edge id
- if (lastSecondId != secondId && toolIndex >= 0)
- edgeIndex = ToolTableData[toolIndex].EdgesData.FindIndex(x => x.Id == secondId);
-
- switch (GetUntilOrEmpty(actualString))
- {
- case "$TC_DP1":
- {
- if (secondId == 1) // Read tool type from first edge type
- ToolTableData[toolIndex].ToolType = Convert.ToInt32(actualString.Split('=').LastOrDefault());
- // Add new edge
- ToolTableData[toolIndex].EdgesData.Add(new EdgeModel() { Id = secondId });
- edgeIndex = ToolTableData[toolIndex].EdgesData.Count - 1; // Update Index
- }
- break;
- case "$TC_MOP1":
- {
- SiemensToolModel tool = ToolTableData[toolIndex];
- if (tool.LifeType == SIEMENS_LIFE_TYPE.TIME)
- {
- ToolTableData[toolIndex]
- .EdgesData[edgeIndex]
- .PreAlmLife = Convert.ToInt32(actualString.Split('=').LastOrDefault());
- }
- }
- break;
- case "$TC_MOP2":
- {
- SiemensToolModel tool = ToolTableData[toolIndex];
- if (tool.LifeType == SIEMENS_LIFE_TYPE.TIME)
- {
- ToolTableData[toolIndex]
- .EdgesData[edgeIndex]
- .ResidualLife = Convert.ToInt32(actualString.Split('=').LastOrDefault());
- }
- }
- break;
- case "$TC_MOP11":
- {
- SiemensToolModel tool = ToolTableData[toolIndex];
- if (tool.LifeType == SIEMENS_LIFE_TYPE.TIME)
- {
- ToolTableData[toolIndex]
- .EdgesData[edgeIndex]
- .NominalLife = Convert.ToInt32(actualString.Split('=').LastOrDefault());
- }
- }
- break;
- case "$TC_MOP3":
- {
- SiemensToolModel tool = ToolTableData[toolIndex];
- if (tool.LifeType == SIEMENS_LIFE_TYPE.COUNT)
- {
- ToolTableData[toolIndex]
- .EdgesData[edgeIndex]
- .PreAlmLife = Convert.ToInt32(actualString.Split('=').LastOrDefault());
- }
- }
- break;
- case "$TC_MOP4":
- {
- SiemensToolModel tool = ToolTableData[toolIndex];
- if (tool.LifeType == SIEMENS_LIFE_TYPE.COUNT)
- {
- ToolTableData[toolIndex]
- .EdgesData[edgeIndex]
- .ResidualLife = Convert.ToInt32(actualString.Split('=').LastOrDefault());
- }
- }
- break;
- case "$TC_MOP13":
- {
- SiemensToolModel tool = ToolTableData[toolIndex];
- if (tool.LifeType == SIEMENS_LIFE_TYPE.COUNT)
- {
- ToolTableData[toolIndex]
- .EdgesData[edgeIndex]
- .NominalLife = Convert.ToInt32(actualString.Split('=').LastOrDefault());
- }
- }
- break;
- case "$TC_DP2":
- case "$TC_DP3":
- case "$TC_DP4":
- case "$TC_DP5":
- case "$TC_DP6":
- case "$TC_DP7":
- case "$TC_DP8":
- case "$TC_DP9":
- case "$TC_DP10":
- case "$TC_DP11":
- case "$TC_DP12":
- case "$TC_DP13":
- case "$TC_DP14":
- case "$TC_DP15":
- case "$TC_DP16":
- case "$TC_DP17":
- case "$TC_DP21":
- case "$TC_DP22":
- case "$TC_DP23":
- case "$TC_DP24":
- case "$TC_DP25":
- case "$TC_DPV":
- case "$TC_DPV3":
- case "$TC_DPV4":
- case "$TC_DPV5":
- case "$TC_DPNT":
- {
- SiemensToolModel tool = ToolTableData[toolIndex];
-
- // Get tool type additional parameters
- if (toolEdgesConfig.EdgesConfig.ContainsKey(tool.ToolType))
- {
- // Find if actual param exist for the tool type
- List toolTypeConfig = toolEdgesConfig.EdgesConfig[tool.ToolType];
- EdgeConfigModel paramConfig = toolTypeConfig.Where(x => x.Path == (GetUntilOrEmpty(actualString) + "[")).FirstOrDefault();
-
- // If Exist
- if (paramConfig != null)
- ToolTableData[toolIndex]
- .EdgesData[edgeIndex]
- .EdgeAdditionalParams // Add additional param
- .Add(paramConfig.Name, Convert.ToDouble(actualString.Split('=').LastOrDefault(), numberFormat));
- }
- }
- break;
- case "$TC_MPP1":
- {
- MagazinePositionsData.Add(new PositionModel()
- {
- PositionId = secondId,
- MagazineId = firstId,
- Type = Convert.ToInt32(actualString.Split('=').LastOrDefault())
- });
- }
- break;
- case "$TC_MPP4":
- {
- int index = MagazinePositionsData.FindIndex(x => x.PositionId == secondId && x.MagazineId == firstId);
- if (index >= 0)
- MagazinePositionsData[index].Disabled = GetBitValue(Convert.ToInt32(actualString.Split('=').LastOrDefault()), 1);
- }
- break;
- case "$TC_MPP6":
- {
- int toolId = Convert.ToInt32(actualString.Split('=').LastOrDefault());
- if (toolId != 0)
- {
- MountToolToList(toolId, firstId, secondId);
- }
- }
- break;
- case "$TC_MTPP6":
- {
- // Find tool by id
- int toolId = Convert.ToInt32(actualString.Split('=').LastOrDefault());
- if (toolId != 0)
- {
- // Find tool by id
- SiemensToolModel tool = ToolTableData.Where(x => x.Id == toolId).First();
- // Add new multitool child
- MultitoolsData[multitoolIndex].ChildsTools.Add(new ShankChildModel()
- {
- Id = toolId,
- MultitoolId = secondId,
- FamilyName = tool.FamilyName,
- ToolType = tool.ToolType
- });
- }
- }
- break;
- }
- }
+ // For each new action
+ for (int i = 0; i < toolInfos.Count(); i++)
+ { // Choose behavior based on the actions
+ ActionsHandler(toolInfos[i]);
}
}
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex.Message);
+ }
}
- private void TOOLS_ChooseActions(ToolInfo toolInfo)
+ private void ActionsHandler(ToolInfo toolInfo)
{
string[] toolsStrings = ReadToolTableFile();
@@ -3519,6 +3544,7 @@ namespace CMS_CORE.Siemens
}
}
break;
+
case ToolAction.TOOL_CREATED:
{
// string[] toolsStrings = ReadToolTableFile();
@@ -3536,6 +3562,7 @@ namespace CMS_CORE.Siemens
}
}
break;
+
case ToolAction.TOOL_DATA_CHANGED:
{
// string[] toolsStrings = ReadToolTableFile();
@@ -3568,6 +3595,7 @@ namespace CMS_CORE.Siemens
}
}
break;
+
case ToolAction.TOOL_MOVED:
{
// Read magazine id from memory
@@ -3620,7 +3648,48 @@ namespace CMS_CORE.Siemens
return toolIds[toolIds.Count - 1] + 1;
}
- #endregion
+ private void AddOrUpdateFamilyChild(string familyName)
+ {
+ // Find family
+ int familyIndex = FamiliesData.FindIndex(x => x.Name == familyName);
+ if (familyIndex < 0)
+ {
+ // Create family and add child
+ FamiliesData.Add(new FamilyModel()
+ {
+ Name = familyName
+ });
+ }
+ }
+
+ private static void GetIdsFromSiemensString(string text, out int toolId, out int edgeId)
+ {
+ toolId = 0;
+ edgeId = 0;
+
+ if (!String.IsNullOrWhiteSpace(text))
+ {
+ // Get indexes from string
+ int startingData = text.IndexOf("[", StringComparison.Ordinal) + 1;
+ int secondData = text.IndexOf(",", StringComparison.Ordinal) + 1;
+ int endingData = text.IndexOf("]", StringComparison.Ordinal);
+ // If the string is matching with the pattern STRING[N]=N or STRING[N,M]=N
+ if (startingData > 0 && endingData > 0)
+ // STRING[N,M]=N case
+ if (secondData > 0)
+ {
+ toolId = Convert.ToInt32(text.Substring(startingData, secondData - (startingData + 1)));
+ edgeId = Convert.ToInt32(text.Substring(secondData, endingData - (secondData)));
+ }
+ else // STRING[N]=N case
+ {
+ toolId = Convert.ToInt32(text.Substring(startingData, endingData - (startingData)));
+ edgeId = 0;
+ }
+ }
+ }
+
+ #endregion Tool private functions
}
internal static class MEMORY_ADDRESS
diff --git a/CMS_CORE_Library/ToolConfigurations.cs b/CMS_CORE_Library/ToolConfigurations.cs
index a9a80bd..0f2cbeb 100644
--- a/CMS_CORE_Library/ToolConfigurations.cs
+++ b/CMS_CORE_Library/ToolConfigurations.cs
@@ -11,40 +11,40 @@ namespace CMS_CORE_Library
private static Dictionary toolTypeList = new Dictionary()
{
- {100, "Milling tool"},
- {110, "Ball nose end mill"},
- {111, "Conical ball end"},
- {120, "End mill"},
- {121, "End mill corner rounding"},
- {130, "Angle head cutter"},
- {131, "Corn.round.ang.hd.cut"},
- {140, "Facing tool"},
- {145, "Thread cutter"},
- {150, "Side mill"},
- {151, "Saw"},
- {155, "Bevelled cutter"},
- {156, "Bevelled cutter corner"},
- {157, "Tap. die-sink. cutter"},
- {160, "Drill&thread cut."},
- {200, "Twist drill"},
- {205, "Solid drill"},
- {210, "Boring bar"},
- {220, "Center drill"},
- {230, "Countersink"},
- {231, "Counterbore"},
- {240, "Tap"},
- {241, "Fine tap"},
- {242, "Tap, Whitworth"},
- {250, "Reamer"},
- {700, "Slotting saw"},
- {710, "3D probe"},
- {711, "Edge finder"},
- {712, "Mono probe"},
- {713, "L probe"},
- {714, "Star probe"},
- {725, "Calibrating tool"},
- {730, "Stop"},
- {900, "Auxiliary tools"}
+ {100, "millingTool"},
+ {110, "ballNoseEndMill"},
+ {111, "conicalBallEnd"},
+ {120, "endMill"},
+ {121, "endMillCornerRounding"},
+ {130, "angleHeadCutter"},
+ {131, "cornRoundAngHdCut"},
+ {140, "facingTool"},
+ {145, "threadCutter"},
+ {150, "sideMill"},
+ {151, "saw"},
+ {155, "bevelledCutter"},
+ {156, "bevelledCutterCorner"},
+ {157, "tapDieSinkCutter"},
+ {160, "drillThreadCut"},
+ {200, "twistDrill"},
+ {205, "solidDrill"},
+ {210, "boringBar"},
+ {220, "centerDrill"},
+ {230, "counterSink"},
+ {231, "counterBore"},
+ {240, "tap"},
+ {241, "fineTap"},
+ {242, "tapWhitworth"},
+ {250, "reamer"},
+ {700, "slottingSaw"},
+ {710, "3Dprobe"},
+ {711, "edgeFinder"},
+ {712, "monoProbe"},
+ {713, "lProbe"},
+ {714, "starProbe"},
+ {725, "calibratingTool"},
+ {730, "stop"},
+ {900, "auxiliaryTools"}
};
private static Dictionary toolLifeList = new Dictionary()
diff --git a/CMS_CORE_Library/Utils/Nc_Utils.cs b/CMS_CORE_Library/Utils/Nc_Utils.cs
index 31e05f7..4b269a9 100644
--- a/CMS_CORE_Library/Utils/Nc_Utils.cs
+++ b/CMS_CORE_Library/Utils/Nc_Utils.cs
@@ -1,9 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace CMS_CORE.Utils
{
@@ -22,7 +19,6 @@ namespace CMS_CORE.Utils
HighWord = BitConverter.ToUInt16(bytes, 2);
}
-
// 2 WORD -> INT
public static void WordTOInt(out int IntVal, ushort LowWord, ushort HighWord)
{
@@ -38,7 +34,6 @@ namespace CMS_CORE.Utils
IntVal = BitConverter.ToInt32(bytes, 0);
}
-
// INT -> 2 WORD (LIST)
public static List IntTOWordList(List UintVal)
{
@@ -58,7 +53,6 @@ namespace CMS_CORE.Utils
return Word;
}
-
// 2 WORD -> INT (LIST)
public static List WordTOIntList(List UintVal)
{
@@ -90,8 +84,6 @@ namespace CMS_CORE.Utils
HighWord = BitConverter.ToUInt16(bytes, 2);
}
-
-
// 2 WORD -> UINT
public static void WordTOUint(out uint UintVal, ushort LowWord, ushort HighWord)
{
@@ -107,8 +99,6 @@ namespace CMS_CORE.Utils
UintVal = BitConverter.ToUInt32(bytes, 0);
}
-
-
// UINT -> 2 WORD (LIST)
public static List UIntTOWordList(List UintVal)
{
@@ -128,8 +118,6 @@ namespace CMS_CORE.Utils
return Word;
}
-
-
// 2 WORD -> UINT (LIST)
public static List WordTOUintList(List UintVal)
{
@@ -168,5 +156,21 @@ namespace CMS_CORE.Utils
return fileContent;
}
+
+
+ public static string GetUntilOrEmpty(string text, string stopAt = "[")
+ {
+ // Get string unti
+ if (!String.IsNullOrWhiteSpace(text))
+ {
+ // Find character index
+ int charLocation = text.IndexOf(stopAt, StringComparison.Ordinal);
+
+ if (charLocation > 0)
+ return text.Substring(0, charLocation);
+ }
+
+ return String.Empty;
+ }
}
-}
+}
\ No newline at end of file
diff --git a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Constants.cs b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Constants.cs
index 4976744..8fd1392 100644
--- a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Constants.cs
+++ b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Constants.cs
@@ -2,7 +2,7 @@
namespace Nc_Demo_Application
{
- static class Constants
+ public static class Constants
{
// Database configuration
public static string RUNNING_PATH_DIR = AppDomain.CurrentDomain.BaseDirectory;
@@ -18,6 +18,7 @@ namespace Nc_Demo_Application
public const string READ_FAMILIES_QUERY = "SELECT * FROM family";
public const string READ_SHANKS_QUERY = "SELECT * FROM shank";
public const string READ_MAGAZINES_QUERY = "SELECT * FROM magazine";
+ public const string READ_MAGAZINES_ACTION_QUERY = "SELECT * FROM magazine_status";
public const string READ_EDGES_QUERY = "SELECT * FROM edge";
// Server configuration
@@ -62,6 +63,15 @@ namespace Nc_Demo_Application
SPINDLE = 2
}
+ public enum MAGAZINE_ACTIONS
+ {
+ NONE = 0,
+ LOADING = 1,
+ UNLOADING = 2,
+ TRANSFER = 4,
+ GENERIC = 5
+ }
+
// File
public const string FILE_FOLDER = "./part_program/";
public const string LANGUAGE_FOLDER = "./Languages/";
diff --git a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Database/DatabaseController.cs b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Database/DatabaseController.cs
index de122e9..6416da2 100644
--- a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Database/DatabaseController.cs
+++ b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Database/DatabaseController.cs
@@ -27,6 +27,7 @@ namespace Nc_Demo_Application.Database
private DataTable FamiliesDataTable;
private DataTable ShanksDataTable;
private DataTable MagazinesPositionDataTable;
+ private DataTable MagazinesActionDataTable;
private DataTable EdgeDataTable;
#region Constructor & Private functions
@@ -42,6 +43,7 @@ namespace Nc_Demo_Application.Database
ToolsDataTable = new DataTable();
ShanksDataTable = new DataTable();
MagazinesPositionDataTable = new DataTable();
+ MagazinesActionDataTable = new DataTable();
NcProcessDataTable = new DataTable();
BinaryMemory = new DataTable();
EdgeDataTable = new DataTable();
@@ -85,6 +87,7 @@ namespace Nc_Demo_Application.Database
ShanksDataTable.Dispose();
MagazinesPositionDataTable.Dispose();
EdgeDataTable.Dispose();
+ MagazinesActionDataTable.Dispose();
// Close sql connection
sqlConnection.Close();
@@ -1408,13 +1411,13 @@ namespace Nc_Demo_Application.Database
{
//var itemToBeRemoved = shanks.Where(x => x.Id == Convert.ToInt32(row["shankId"]))?.FirstOrDefault();
//if (itemToBeRemoved != null)
- shanks.Remove(shanks.Where(x => x.Id == Convert.ToInt32(row["shankId"]))?.FirstOrDefault());
+ shanks.Remove(shanks.Where(x => x.Id == Convert.ToInt32(row["shankId"]))?.FirstOrDefault());
}
else if (Convert.ToInt32(row["toolId"]) != 0)
{
//var itemToBeRemoved = tools.Where(x => x.Id == Convert.ToInt32(row["toolId"])).FirstOrDefault();
//if (itemToBeRemoved != null)
- tools.Remove(tools.Where(x => x.Id == Convert.ToInt32(row["toolId"])).FirstOrDefault());
+ tools.Remove(tools.Where(x => x.Id == Convert.ToInt32(row["toolId"])).FirstOrDefault());
}
}
}
@@ -1484,6 +1487,96 @@ namespace Nc_Demo_Application.Database
}
+ public MagazineActionModel ReadMagazinesAction()
+ {
+ try
+ {
+ ReadDataFromDatabase(READ_MAGAZINES_ACTION_QUERY, ref MagazinesActionDataTable);
+
+ return GetMagazinesActionModel();
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("Read magazines STATUS exception: " + ex.Message);
+ return null;
+ }
+ }
+
+ public MagazineActionModel GetMagazinesActionModel()
+ {
+ List tools = GetToolsData();
+ // Get shanks Data
+ List shanks = GetShanks();
+
+ MagazineActionModel status = new MagazineActionModel();
+ foreach(DataRow row in MagazinesActionDataTable.Rows)
+ {
+ // Get tool
+ MagazineActionToolModel tool = tools.Where(x => x.Id == Convert.ToInt32(row["tool_id"]))?
+ .Select(x => new MagazineActionToolModel
+ {
+ Id = x.Id,
+ IsMultitool = false,
+ Name = x.FamilyName,
+ ToolType = x.ToolType
+ }).FirstOrDefault();
+ if(tool == null)
+ // Get shank
+ tool = shanks.Where(x => x.Id == Convert.ToInt32(row["tool_id"]))?
+ .Select(x => new MagazineActionToolModel
+ {
+ Id = x.Id,
+ IsMultitool = true,
+ Name = x.Name,
+ ToolType = 0
+ }).FirstOrDefault();
+
+ if (tool == null)
+ // Create default model
+ tool = new MagazineActionToolModel()
+ {
+ Id = Convert.ToInt32(row["tool_id"])
+ };
+ // Set model data
+ status.action = (MAGAZINE_ACTIONS)Convert.ToInt32(row["action"]);
+ status.Tool = tool;
+ status.Tool.Id = Convert.ToInt32(row["tool_id"]);
+ status.OriginMagazine = Convert.ToInt32(row["orig_mag"]);
+ status.OriginPosition = Convert.ToInt32(row["orig_pos"]);
+ status.DestinationMagazine = Convert.ToInt32(row["dest_mag"]);
+ status.DestinationPosition = Convert.ToInt32(row["dest_pos"]);
+ }
+
+ return status;
+ }
+
+ public void UpdateMagazineAction(MagazineActionModel ncData)
+ {
+ try
+ {
+ // Update local ncDatatable data
+ foreach (DataRow row in MagazinesActionDataTable.Rows)
+ {
+ row["action"] = (int)ncData.action;
+ row["tool_id"] = ncData.Tool.Id;
+ row["orig_mag"] = ncData.OriginMagazine;
+ row["orig_pos"] = ncData.OriginPosition;
+ row["dest_mag"] = ncData.DestinationMagazine;
+ row["dest_pos"] = ncData.DestinationPosition;
+ }
+
+ UpdateMagAction(MagazinesActionDataTable);
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("Update magazines action exception: " + ex.Message);
+ }
+ }
+
+ public void UpdateMagAction(DataTable magAction)
+ {
+ UpdateDatabaseFromDataTable(magAction, READ_MAGAZINES_ACTION_QUERY);
+ }
#endregion Magazines
}
}
\ No newline at end of file
diff --git a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Database/Models/ToolsDataModel.cs b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Database/Models/ToolsDataModel.cs
index 3d3ed39..998bb3a 100644
--- a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Database/Models/ToolsDataModel.cs
+++ b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Database/Models/ToolsDataModel.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using static Nc_Demo_Application.Constants;
namespace Nc_Demo_Application.Database.Models
{
@@ -84,4 +85,23 @@ namespace Nc_Demo_Application.Database.Models
public int PositionId;
public int ToolId;
}
+
+ public class MagazineActionModel
+ {
+ public MAGAZINE_ACTIONS action;
+ public int OriginMagazine;
+ public int OriginPosition;
+ public int DestinationMagazine;
+ public int DestinationPosition;
+ public MagazineActionToolModel Tool;
+ }
+
+ public class MagazineActionToolModel
+ {
+ public int Id;
+ public int ToolType;
+ public string Name;
+ public bool IsMultitool;
+ }
+
}
\ No newline at end of file
diff --git a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/Service/ILibraryService.cs b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/Service/ILibraryService.cs
index baa4995..8251666 100644
--- a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/Service/ILibraryService.cs
+++ b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/Service/ILibraryService.cs
@@ -229,6 +229,8 @@ namespace Nc_Demo_Application.Server.Service
[WebInvoke(Method = "PUT", UriTemplate = "tool_table/magazine/{magazineId}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
void UpdateMagazine(string magazineId, List magazine);
+ [WebGet(UriTemplate = "tool_table/magazines_action", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
+ void GetMagazinesAction(out MagazineActionModel magazinesAction);
#endregion
}
}
diff --git a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/Service/LibraryService.cs b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/Service/LibraryService.cs
index a4a2ffa..e9db6d8 100644
--- a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/Service/LibraryService.cs
+++ b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Server/Service/LibraryService.cs
@@ -598,6 +598,10 @@ namespace Nc_Demo_Application.Server.Service
DatabaseController.getInstance().UpdateMagazine(Convert.ToInt32(magazineId), magazine);
}
+ public void GetMagazinesAction(out MagazineActionModel magazinesAction)
+ {
+ magazinesAction = DatabaseController.getInstance().GetMagazinesActionModel();
+ }
#endregion Positions
}
}
\ No newline at end of file
diff --git a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Views/DemoApplicationForm.Designer.cs b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Views/DemoApplicationForm.Designer.cs
index 7fb91b8..9b1d233 100644
--- a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Views/DemoApplicationForm.Designer.cs
+++ b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Views/DemoApplicationForm.Designer.cs
@@ -30,12 +30,12 @@ namespace Nc_Demo_Application
///
private void InitializeComponent()
{
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle();
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DemoApplicationForm));
this.serverStatusLabel = new System.Windows.Forms.Label();
this.ncDataPage = new System.Windows.Forms.TabPage();
@@ -109,6 +109,18 @@ namespace Nc_Demo_Application
this.addFileButton = new System.Windows.Forms.ToolStripButton();
this.newFileNameTextBox = new System.Windows.Forms.ToolStripTextBox();
this.magazinesTab = new System.Windows.Forms.TabPage();
+ this.label26 = new System.Windows.Forms.Label();
+ this.label25 = new System.Windows.Forms.Label();
+ this.label24 = new System.Windows.Forms.Label();
+ this.label23 = new System.Windows.Forms.Label();
+ this.label22 = new System.Windows.Forms.Label();
+ this.magActionToolId = new System.Windows.Forms.TextBox();
+ this.magActionDestPos = new System.Windows.Forms.TextBox();
+ this.magActionDestMag = new System.Windows.Forms.TextBox();
+ this.magActionOrigPos = new System.Windows.Forms.TextBox();
+ this.magActionOrigMag = new System.Windows.Forms.TextBox();
+ this.label21 = new System.Windows.Forms.Label();
+ this.magActionAction = new System.Windows.Forms.ComboBox();
this.magazinesGridView = new System.Windows.Forms.DataGridView();
this.magazineId = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.positionId = new System.Windows.Forms.DataGridViewTextBoxColumn();
@@ -138,6 +150,10 @@ namespace Nc_Demo_Application
this.toolStripEx1 = new Nc_Demo_Application.Views.ToolStripEx();
this.saveFamiliesButton = new System.Windows.Forms.ToolStripButton();
this.toolsPage = new System.Windows.Forms.TabPage();
+ this.label20 = new System.Windows.Forms.Label();
+ this.maxAccTxt = new System.Windows.Forms.TextBox();
+ this.label14 = new System.Windows.Forms.Label();
+ this.maxSpeedTxt = new System.Windows.Forms.TextBox();
this.isEnabledCheckBox = new System.Windows.Forms.CheckBox();
this.label19 = new System.Windows.Forms.Label();
this.shankIdTextBox = new System.Windows.Forms.TextBox();
@@ -212,10 +228,6 @@ namespace Nc_Demo_Application
this.removeTool = new System.Windows.Forms.ToolStripButton();
this.addTool = new System.Windows.Forms.ToolStripButton();
this.stopServer = new System.Windows.Forms.Button();
- this.label14 = new System.Windows.Forms.Label();
- this.maxSpeedTxt = new System.Windows.Forms.TextBox();
- this.label20 = new System.Windows.Forms.Label();
- this.maxAccTxt = new System.Windows.Forms.TextBox();
this.ncDataPage.SuspendLayout();
this.toolStrip5.SuspendLayout();
this.ncTabControl.SuspendLayout();
@@ -518,10 +530,10 @@ namespace Nc_Demo_Application
// ncProcessIdColumn
//
this.ncProcessIdColumn.DataPropertyName = "id";
- dataGridViewCellStyle7.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
- dataGridViewCellStyle7.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
- dataGridViewCellStyle7.SelectionForeColor = System.Drawing.Color.Black;
- this.ncProcessIdColumn.DefaultCellStyle = dataGridViewCellStyle7;
+ dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
+ dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
+ dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.Black;
+ this.ncProcessIdColumn.DefaultCellStyle = dataGridViewCellStyle1;
this.ncProcessIdColumn.HeaderText = "Process Id";
this.ncProcessIdColumn.Name = "ncProcessIdColumn";
this.ncProcessIdColumn.ReadOnly = true;
@@ -779,10 +791,10 @@ namespace Nc_Demo_Application
// BinaryMemoryAddressColumn
//
this.BinaryMemoryAddressColumn.DataPropertyName = "address";
- dataGridViewCellStyle8.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
- dataGridViewCellStyle8.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
- dataGridViewCellStyle8.SelectionForeColor = System.Drawing.Color.Black;
- this.BinaryMemoryAddressColumn.DefaultCellStyle = dataGridViewCellStyle8;
+ dataGridViewCellStyle2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
+ dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
+ dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.Black;
+ this.BinaryMemoryAddressColumn.DefaultCellStyle = dataGridViewCellStyle2;
this.BinaryMemoryAddressColumn.HeaderText = "Byte Address";
this.BinaryMemoryAddressColumn.Name = "BinaryMemoryAddressColumn";
this.BinaryMemoryAddressColumn.ReadOnly = true;
@@ -943,6 +955,18 @@ namespace Nc_Demo_Application
//
// magazinesTab
//
+ this.magazinesTab.Controls.Add(this.label26);
+ this.magazinesTab.Controls.Add(this.label25);
+ this.magazinesTab.Controls.Add(this.label24);
+ this.magazinesTab.Controls.Add(this.label23);
+ this.magazinesTab.Controls.Add(this.label22);
+ this.magazinesTab.Controls.Add(this.magActionToolId);
+ this.magazinesTab.Controls.Add(this.magActionDestPos);
+ this.magazinesTab.Controls.Add(this.magActionDestMag);
+ this.magazinesTab.Controls.Add(this.magActionOrigPos);
+ this.magazinesTab.Controls.Add(this.magActionOrigMag);
+ this.magazinesTab.Controls.Add(this.label21);
+ this.magazinesTab.Controls.Add(this.magActionAction);
this.magazinesTab.Controls.Add(this.magazinesGridView);
this.magazinesTab.Controls.Add(this.toolStripEx2);
this.magazinesTab.Location = new System.Drawing.Point(4, 22);
@@ -953,6 +977,103 @@ namespace Nc_Demo_Application
this.magazinesTab.Text = "Magazines";
this.magazinesTab.UseVisualStyleBackColor = true;
//
+ // label26
+ //
+ this.label26.AutoSize = true;
+ this.label26.Location = new System.Drawing.Point(674, 48);
+ this.label26.Name = "label26";
+ this.label26.Size = new System.Drawing.Size(87, 13);
+ this.label26.TabIndex = 13;
+ this.label26.Text = "Destination Mag:";
+ //
+ // label25
+ //
+ this.label25.AutoSize = true;
+ this.label25.Location = new System.Drawing.Point(839, 47);
+ this.label25.Name = "label25";
+ this.label25.Size = new System.Drawing.Size(28, 13);
+ this.label25.TabIndex = 12;
+ this.label25.Text = "Pos:";
+ //
+ // label24
+ //
+ this.label24.AutoSize = true;
+ this.label24.Location = new System.Drawing.Point(526, 48);
+ this.label24.Name = "label24";
+ this.label24.Size = new System.Drawing.Size(28, 13);
+ this.label24.TabIndex = 11;
+ this.label24.Text = "Pos:";
+ //
+ // label23
+ //
+ this.label23.AutoSize = true;
+ this.label23.Location = new System.Drawing.Point(383, 47);
+ this.label23.Name = "label23";
+ this.label23.Size = new System.Drawing.Size(61, 13);
+ this.label23.TabIndex = 10;
+ this.label23.Text = "Origin Mag:";
+ //
+ // label22
+ //
+ this.label22.AutoSize = true;
+ this.label22.Location = new System.Drawing.Point(214, 48);
+ this.label22.Name = "label22";
+ this.label22.Size = new System.Drawing.Size(37, 13);
+ this.label22.TabIndex = 9;
+ this.label22.Text = "ToolId";
+ //
+ // magActionToolId
+ //
+ this.magActionToolId.Location = new System.Drawing.Point(257, 45);
+ this.magActionToolId.Name = "magActionToolId";
+ this.magActionToolId.Size = new System.Drawing.Size(66, 20);
+ this.magActionToolId.TabIndex = 8;
+ //
+ // magActionDestPos
+ //
+ this.magActionDestPos.Location = new System.Drawing.Point(873, 45);
+ this.magActionDestPos.Name = "magActionDestPos";
+ this.magActionDestPos.Size = new System.Drawing.Size(66, 20);
+ this.magActionDestPos.TabIndex = 7;
+ //
+ // magActionDestMag
+ //
+ this.magActionDestMag.Location = new System.Drawing.Point(767, 45);
+ this.magActionDestMag.Name = "magActionDestMag";
+ this.magActionDestMag.Size = new System.Drawing.Size(66, 20);
+ this.magActionDestMag.TabIndex = 6;
+ //
+ // magActionOrigPos
+ //
+ this.magActionOrigPos.Location = new System.Drawing.Point(560, 45);
+ this.magActionOrigPos.Name = "magActionOrigPos";
+ this.magActionOrigPos.Size = new System.Drawing.Size(66, 20);
+ this.magActionOrigPos.TabIndex = 5;
+ //
+ // magActionOrigMag
+ //
+ this.magActionOrigMag.Location = new System.Drawing.Point(450, 45);
+ this.magActionOrigMag.Name = "magActionOrigMag";
+ this.magActionOrigMag.Size = new System.Drawing.Size(66, 20);
+ this.magActionOrigMag.TabIndex = 4;
+ //
+ // label21
+ //
+ this.label21.AutoSize = true;
+ this.label21.Location = new System.Drawing.Point(15, 47);
+ this.label21.Name = "label21";
+ this.label21.Size = new System.Drawing.Size(37, 13);
+ this.label21.TabIndex = 3;
+ this.label21.Text = "Action";
+ //
+ // magActionAction
+ //
+ this.magActionAction.FormattingEnabled = true;
+ this.magActionAction.Location = new System.Drawing.Point(62, 44);
+ this.magActionAction.Name = "magActionAction";
+ this.magActionAction.Size = new System.Drawing.Size(121, 21);
+ this.magActionAction.TabIndex = 2;
+ //
// magazinesGridView
//
this.magazinesGridView.AllowUserToAddRows = false;
@@ -965,18 +1086,18 @@ namespace Nc_Demo_Application
this.positionType,
this.ShankId,
this.magazineToolId});
- this.magazinesGridView.Location = new System.Drawing.Point(0, 31);
+ this.magazinesGridView.Location = new System.Drawing.Point(0, 90);
this.magazinesGridView.Name = "magazinesGridView";
- this.magazinesGridView.Size = new System.Drawing.Size(978, 607);
+ this.magazinesGridView.Size = new System.Drawing.Size(978, 548);
this.magazinesGridView.TabIndex = 0;
//
// magazineId
//
this.magazineId.DataPropertyName = "magazineId";
- dataGridViewCellStyle9.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
- dataGridViewCellStyle9.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
- dataGridViewCellStyle9.SelectionForeColor = System.Drawing.Color.Black;
- this.magazineId.DefaultCellStyle = dataGridViewCellStyle9;
+ dataGridViewCellStyle3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
+ dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
+ dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.Black;
+ this.magazineId.DefaultCellStyle = dataGridViewCellStyle3;
this.magazineId.FillWeight = 105.2829F;
this.magazineId.HeaderText = "Magazine Id";
this.magazineId.Name = "magazineId";
@@ -986,10 +1107,10 @@ namespace Nc_Demo_Application
// positionId
//
this.positionId.DataPropertyName = "positionId";
- dataGridViewCellStyle10.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
- dataGridViewCellStyle10.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
- dataGridViewCellStyle10.SelectionForeColor = System.Drawing.Color.Black;
- this.positionId.DefaultCellStyle = dataGridViewCellStyle10;
+ dataGridViewCellStyle4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
+ dataGridViewCellStyle4.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
+ dataGridViewCellStyle4.SelectionForeColor = System.Drawing.Color.Black;
+ this.positionId.DefaultCellStyle = dataGridViewCellStyle4;
this.positionId.FillWeight = 94.61015F;
this.positionId.HeaderText = "Position Id";
this.positionId.Name = "positionId";
@@ -1198,10 +1319,10 @@ namespace Nc_Demo_Application
// id
//
this.id.DataPropertyName = "id";
- dataGridViewCellStyle11.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
- dataGridViewCellStyle11.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
- dataGridViewCellStyle11.SelectionForeColor = System.Drawing.Color.Black;
- this.id.DefaultCellStyle = dataGridViewCellStyle11;
+ dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
+ dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
+ dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.Black;
+ this.id.DefaultCellStyle = dataGridViewCellStyle5;
this.id.FillWeight = 60F;
this.id.HeaderText = "Id";
this.id.Name = "id";
@@ -1281,6 +1402,39 @@ namespace Nc_Demo_Application
this.toolsPage.Text = "Tools";
this.toolsPage.UseVisualStyleBackColor = true;
//
+ // label20
+ //
+ this.label20.AutoSize = true;
+ this.label20.Location = new System.Drawing.Point(309, 162);
+ this.label20.Name = "label20";
+ this.label20.Size = new System.Drawing.Size(49, 13);
+ this.label20.TabIndex = 39;
+ this.label20.Text = "Max Acc";
+ //
+ // maxAccTxt
+ //
+ this.maxAccTxt.Location = new System.Drawing.Point(364, 155);
+ this.maxAccTxt.Name = "maxAccTxt";
+ this.maxAccTxt.Size = new System.Drawing.Size(49, 20);
+ this.maxAccTxt.TabIndex = 38;
+ //
+ // label14
+ //
+ this.label14.AutoSize = true;
+ this.label14.Location = new System.Drawing.Point(171, 162);
+ this.label14.Name = "label14";
+ this.label14.Size = new System.Drawing.Size(61, 13);
+ this.label14.TabIndex = 37;
+ this.label14.Text = "Max Speed";
+ //
+ // maxSpeedTxt
+ //
+ this.maxSpeedTxt.CausesValidation = false;
+ this.maxSpeedTxt.Location = new System.Drawing.Point(238, 155);
+ this.maxSpeedTxt.Name = "maxSpeedTxt";
+ this.maxSpeedTxt.Size = new System.Drawing.Size(49, 20);
+ this.maxSpeedTxt.TabIndex = 36;
+ //
// isEnabledCheckBox
//
this.isEnabledCheckBox.AutoSize = true;
@@ -1620,11 +1774,11 @@ namespace Nc_Demo_Application
// edgesId
//
this.edgesId.DataPropertyName = "child_id";
- dataGridViewCellStyle12.BackColor = System.Drawing.Color.White;
- dataGridViewCellStyle12.ForeColor = System.Drawing.Color.Black;
- dataGridViewCellStyle12.SelectionBackColor = System.Drawing.Color.CornflowerBlue;
- dataGridViewCellStyle12.SelectionForeColor = System.Drawing.Color.Black;
- this.edgesId.DefaultCellStyle = dataGridViewCellStyle12;
+ dataGridViewCellStyle6.BackColor = System.Drawing.Color.White;
+ dataGridViewCellStyle6.ForeColor = System.Drawing.Color.Black;
+ dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.CornflowerBlue;
+ dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.Black;
+ this.edgesId.DefaultCellStyle = dataGridViewCellStyle6;
this.edgesId.HeaderText = "Id";
this.edgesId.Name = "edgesId";
//
@@ -1892,39 +2046,6 @@ namespace Nc_Demo_Application
this.stopServer.UseVisualStyleBackColor = true;
this.stopServer.Click += new System.EventHandler(this.StopServer_Click);
//
- // label14
- //
- this.label14.AutoSize = true;
- this.label14.Location = new System.Drawing.Point(171, 162);
- this.label14.Name = "label14";
- this.label14.Size = new System.Drawing.Size(61, 13);
- this.label14.TabIndex = 37;
- this.label14.Text = "Max Speed";
- //
- // maxSpeedTxt
- //
- this.maxSpeedTxt.CausesValidation = false;
- this.maxSpeedTxt.Location = new System.Drawing.Point(238, 155);
- this.maxSpeedTxt.Name = "maxSpeedTxt";
- this.maxSpeedTxt.Size = new System.Drawing.Size(49, 20);
- this.maxSpeedTxt.TabIndex = 36;
- //
- // label20
- //
- this.label20.AutoSize = true;
- this.label20.Location = new System.Drawing.Point(309, 162);
- this.label20.Name = "label20";
- this.label20.Size = new System.Drawing.Size(49, 13);
- this.label20.TabIndex = 39;
- this.label20.Text = "Max Acc";
- //
- // maxAccTxt
- //
- this.maxAccTxt.Location = new System.Drawing.Point(364, 155);
- this.maxAccTxt.Name = "maxAccTxt";
- this.maxAccTxt.Size = new System.Drawing.Size(49, 20);
- this.maxAccTxt.TabIndex = 38;
- //
// DemoApplicationForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -2171,6 +2292,18 @@ namespace Nc_Demo_Application
private System.Windows.Forms.TextBox maxAccTxt;
private System.Windows.Forms.Label label14;
private System.Windows.Forms.TextBox maxSpeedTxt;
+ private System.Windows.Forms.Label label26;
+ private System.Windows.Forms.Label label25;
+ private System.Windows.Forms.Label label24;
+ private System.Windows.Forms.Label label23;
+ private System.Windows.Forms.Label label22;
+ private System.Windows.Forms.TextBox magActionToolId;
+ private System.Windows.Forms.TextBox magActionDestPos;
+ private System.Windows.Forms.TextBox magActionDestMag;
+ private System.Windows.Forms.TextBox magActionOrigPos;
+ private System.Windows.Forms.TextBox magActionOrigMag;
+ private System.Windows.Forms.Label label21;
+ private System.Windows.Forms.ComboBox magActionAction;
}
}
diff --git a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Views/DemoApplicationForm.cs b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Views/DemoApplicationForm.cs
index 5d07c47..74deaab 100644
--- a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Views/DemoApplicationForm.cs
+++ b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Views/DemoApplicationForm.cs
@@ -58,7 +58,7 @@ namespace Nc_Demo_Application
ncProcessStatusColumn.DataSource = Enum.GetValues(typeof(PROC_STATUS));
rotationSelect.DataSource = Enum.GetValues(typeof(ROTATION));
toolTypeSelect.DataSource = Enum.GetValues(typeof(TOOLS_TYPE));
- // magazineComboBox.DataSource = Enum.GetValues(typeof(MAGAZINES));
+ magActionAction.DataSource = Enum.GetValues(typeof(MAGAZINE_ACTIONS));
ShowServer(true);
@@ -159,6 +159,14 @@ namespace Nc_Demo_Application
// Insert magazines data into grid view
DataTable magazines = DatabaseController.getInstance().ReadMagazines();
magazinesGridView.DataSource = magazines;
+ // Set UI components data
+ MagazineActionModel magAction = DatabaseController.getInstance().ReadMagazinesAction();
+ magActionAction.SelectedItem = magAction.action;
+ magActionToolId.Text = magAction.Tool.Id.ToString();
+ magActionOrigMag.Text = magAction.OriginMagazine.ToString();
+ magActionOrigPos.Text = magAction.OriginPosition.ToString();
+ magActionDestMag.Text = magAction.DestinationMagazine.ToString();
+ magActionDestPos.Text = magAction.DestinationPosition.ToString();
}
private void FillToolsInput()
@@ -693,8 +701,20 @@ namespace Nc_Demo_Application
private void SaveMagazinesButton_Click(object sender, EventArgs e)
{
DatabaseController.getInstance().UpdatePositions((DataTable)magazinesGridView.DataSource);
+
+ MagazineActionModel magAction = new MagazineActionModel()
+ {
+ action = (MAGAZINE_ACTIONS)magActionAction.SelectedItem,
+ Tool = new MagazineActionToolModel() { Id = Convert.ToInt32(magActionToolId.Text) },
+ OriginMagazine = Convert.ToInt32(magActionOrigMag.Text),
+ OriginPosition = Convert.ToInt32(magActionOrigPos.Text),
+ DestinationMagazine = Convert.ToInt32(magActionDestMag.Text),
+ DestinationPosition = Convert.ToInt32(magActionDestPos.Text)
+ };
+ DatabaseController.getInstance().UpdateMagazineAction(magAction);
}
+
private void refreshToolUI_Click(object sender, EventArgs e)
{
FillToolsInput();
diff --git a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Views/DemoApplicationForm.resx b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Views/DemoApplicationForm.resx
index f51b394..0247cfe 100644
--- a/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Views/DemoApplicationForm.resx
+++ b/CMS_CORE_Nc_Demo_Application/Nc_Demo_Application/Views/DemoApplicationForm.resx
@@ -120,9 +120,6 @@
17, 17
-
- 17, 17
-
122, 17
@@ -138,9 +135,63 @@
542, 17
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
869, 17
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
752, 17
@@ -255,243 +306,6 @@
647, 17
-
- 122, 17
-
-
- 227, 17
-
-
- 332, 17
-
-
- 437, 17
-
-
- 542, 17
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- 869, 17
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- 752, 17
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-
-
- True
-