Refactor models

This commit is contained in:
Lucio Maranta
2018-09-27 16:00:05 +00:00
parent 674c68ac1d
commit e14a8cc30e
26 changed files with 1092 additions and 137 deletions
+10 -9
View File
@@ -1,9 +1,10 @@
using CMS_CORE;
using CMS_CORE.Demo;
using CMS_CORE.Fanuc;
using CMS_CORE.Osai;
using CMS_CORE.Siemens;
using CMS_CORE_Library.Demo;
using CMS_CORE_Library.Fanuc;
using CMS_CORE_Library.Osai;
using CMS_CORE_Library.Siemens;
using CMS_CORE_Application.ToolDatabase;
using CMS_CORE_Library;
using CMS_CORE_Library.Models;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -12,7 +13,7 @@ using System.Linq;
using System.Threading;
using System.Windows.Forms;
using static CMS_CORE_Application.ToolDatabase.ToolModels;
using static CMS_CORE_Library.DataStructures;
using static CMS_CORE_Library.Models.DataStructures;
namespace CMS_CORE_Application
{
@@ -72,7 +73,7 @@ namespace CMS_CORE_Application
PreAndPostPowerOnModel powerOn = new PreAndPostPowerOnModel();
List<AlarmModel> ncAlarms = new List<AlarmModel>();
List<String> Lines = new List<string>();
N = SetNcByType();
CmsError cmsError = N.NC_Connect();
@@ -145,7 +146,7 @@ namespace CMS_CORE_Application
// cmsError = N.MEM_RWByteList(false, 0, Nc.MEMORY_TYPE.Fanuc_R, 0,0, 2048, ref listB);
// cmsError = N.MEM_RWIntegerList(false, 0, Nc.MEMORY_TYPE.Osai_GW, 0, 512, ref list);
// cmsError = N.MEM_RWWordList(false, 0, Nc.MEMORY_TYPE.Fanuc_R, 0, 512, ref listS);
cmsError = N.MEM_RWIntegerList(false, 0, Nc.MEMORY_TYPE.Siemens_DB, 258, 0, 512, ref list);
cmsError = N.MEM_RWIntegerList(false, 0, Nc.MEMORY_TYPE.Siemens_DB, 258, 0, 512, ref list);
st.Stop();
Console.WriteLine(st.ElapsedMilliseconds);
@@ -337,7 +338,7 @@ namespace CMS_CORE_Application
{
TXTip.Enabled = true;
TXTport.Enabled = true;
// TXTip.Text = "192.168.139.1";
// TXTip.Text = "192.168.139.1";
TXTip.Text = "192.168.157.2";
TXTport.Text = "8080";
}
+8 -1
View File
@@ -129,7 +129,8 @@
<DesignTime>True</DesignTime>
<DependentUpon>Reference.svcmap</DependentUpon>
</Compile>
<Compile Include="DataStructures.cs" />
<Compile Include="Models\CmsError.cs" />
<Compile Include="Models\DataStructures.cs" />
<Compile Include="Demo\DemoEdgesConfiguration.cs" />
<Compile Include="Demo\ILibraryService.cs" />
<Compile Include="Demo\Models\BinaryMemoryModel.cs" />
@@ -144,6 +145,9 @@
<Compile Include="Exceptions\Nc_Exception.cs" />
<Compile Include="Fanuc\fwlib32_64.cs" />
<Compile Include="Fanuc\Nc_Fanuc.cs" />
<Compile Include="Models\NcToolModel.cs" />
<Compile Include="Models\PreAndPostPowerOnModels.cs" />
<Compile Include="Models\SiemensToolModels.cs" />
<Compile Include="Nc.cs" />
<Compile Include="Osai\Nc_Osai.cs" />
<Compile Include="Osai\OSAIErrMgr.cs" />
@@ -911,5 +915,8 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Folder Include="Models\JobModels\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
@@ -1,5 +1,5 @@
using System.Collections.Generic;
using static CMS_CORE_Library.DataStructures;
using CMS_CORE_Library.Models;
using System.Collections.Generic;
namespace CMS_CORE_Library.Demo
{
+25 -16
View File
@@ -1,15 +1,15 @@
using System;
using CMS_CORE_Library.Demo.Models;
using CMS_CORE_Library.Demo.Models;
using CMS_CORE_Library.Models;
using System.Collections.Generic;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Collections.Generic;
using CMS_CORE.Demo.Models;
using CMS_CORE_Library.Demo.Models;
using static CMS_CORE_Library.DataStructures;
using static CMS_CORE_Library.Models.DataStructures;
namespace Nc_Demo_Application.Server.Service
{
[ServiceContract]
interface ILibraryService
internal interface ILibraryService
{
[OperationContract]
@@ -17,6 +17,7 @@ namespace Nc_Demo_Application.Server.Service
[WebGet(UriTemplate = "cn/name/", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
void GetName(out string name);
[WebGet(UriTemplate = "cn/language/", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
void GetLanguage(out string language);
@@ -44,7 +45,9 @@ namespace Nc_Demo_Application.Server.Service
[WebGet(UriTemplate = "plc/alarms", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
void PlcAlarms(out List<NcAlarmModel> alarms);
#endregion
#endregion Nc Data API
#region Process API
@@ -62,12 +65,15 @@ namespace Nc_Demo_Application.Server.Service
[WebGet(UriTemplate = "processes/alarms/", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
void GetProcessesAlarms(out List<NcAlarmModel> alarms);
#endregion
#endregion Process API
#region Process Axes API
[WebGet(UriTemplate = "process/{id}/axes/", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
void GetAxesPosition(string id, out List<NcAxisModel> axes);
#endregion
#endregion Process Axes API
#region Binary Memory
@@ -106,9 +112,11 @@ namespace Nc_Demo_Application.Server.Service
[WebInvoke(Method = "PUT", UriTemplate = "binary_memory/dword/{index}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
void PutDWord(string index, BinaryMemoryModel body);
#endregion
#endregion Binary Memory
#region Binary Memory List
[WebGet(UriTemplate = "binary_memory/byte/{index}/list/{number}", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
void GetByteList(string index, string number, out List<byte> byteList);
@@ -138,7 +146,8 @@ namespace Nc_Demo_Application.Server.Service
[WebInvoke(Method = "PUT", UriTemplate = "binary_memory/dword/{index}/list", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
void PutDWordList(string index, BinaryMemoryModel body);
#endregion
#endregion Binary Memory List
#region File Management
@@ -171,7 +180,8 @@ namespace Nc_Demo_Application.Server.Service
[WebGet(UriTemplate = "translation/{language}", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
void GetTranslations(string language, out Dictionary<int, string> fileContent);
#endregion
#endregion File Management
#region Family
@@ -187,7 +197,7 @@ namespace Nc_Demo_Application.Server.Service
[WebInvoke(Method = "DELETE", UriTemplate = "tool_table/family/{name}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
void DeleteFamily(string name);
#endregion
#endregion Family
#region Tools
@@ -254,7 +264,6 @@ namespace Nc_Demo_Application.Server.Service
[WebInvoke(Method = "PUT", UriTemplate = "tool_table/offset", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
void PutOffset(ref OffsetModel offsetData);
#endregion
#endregion Tools
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
using System.Collections.Generic;
namespace CMS_CORE.Demo.Models
namespace CMS_CORE_Library.Demo.Models
{
public class DemoFamilyModel
{
+1 -1
View File
@@ -5,7 +5,7 @@ using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace CMS_CORE.Demo.Models
namespace CMS_CORE_Library.Demo.Models
{
[DataContract]
class TransferFileModel
+1 -1
View File
@@ -5,7 +5,7 @@ using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace CMS_CORE.Demo.Models
namespace CMS_CORE_Library.Demo.Models
{
[DataContract]
class NcAlarmModel
+1 -1
View File
@@ -5,7 +5,7 @@ using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace CMS_CORE.Demo.Models
namespace CMS_CORE_Library.Demo.Models
{
[DataContract]
class NcAxisModel
+1 -1
View File
@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CMS_CORE.Demo.Models
namespace CMS_CORE_Library.Demo.Models
{
class NcDataModel
{
@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CMS_CORE.Demo.Models
namespace CMS_CORE_Library.Demo.Models
{
class NcProcessModel
{
@@ -1,7 +1,8 @@
using System.Collections.Generic;
using static CMS_CORE_Library.DataStructures;
using CMS_CORE_Library.Models;
using System.Collections.Generic;
using static CMS_CORE_Library.Models.DataStructures;
namespace CMS_CORE.Demo.Models
namespace CMS_CORE_Library.Demo.Models
{
public class DemoToolsDataModel
{
+34 -18
View File
@@ -1,7 +1,6 @@
using CMS_CORE.Demo.Models;
using CMS_CORE.Utils;
using CMS_CORE_Library.Demo;
using CMS_CORE_Library.Demo.Models;
using CMS_CORE_Library.Demo.Models;
using CMS_CORE_Library.Models;
using CMS_CORE_Library.Utils;
using Nc_Demo_Application.Server.Service;
using System;
using System.Collections;
@@ -12,13 +11,13 @@ using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.Threading;
using static CMS_CORE.Demo.MEMORY_ADDRESS;
using static CMS_CORE.Nc;
using static CMS_CORE_Library.DataStructures;
using static CMS_CORE_Library.Demo.MEMORY_ADDRESS;
using static CMS_CORE_Library.Models.DataStructures;
using static CMS_CORE_Library.Nc;
using static CMS_CORE_Library.ToolConfigurations;
using static CMS_CORE.Utils.Nc_Utils;
using static CMS_CORE_Library.Utils.Nc_Utils;
namespace CMS_CORE.Demo
namespace CMS_CORE_Library.Demo
{
public class Nc_Demo : Nc
{
@@ -254,9 +253,9 @@ namespace CMS_CORE.Demo
}
public override CmsError NC_WLanguage(CultureInfo Language)
{
{
return NO_ERROR;
}
}
public override CmsError NC_RActiveAlarms(ref List<AlarmModel> alarms)
{
@@ -1103,7 +1102,7 @@ namespace CMS_CORE.Demo
try
{
serverService.GetAxesPosition(process.ToString(), out List<NcAxisModel> demoAxes);
// Parse response get distance to go
foreach (NcAxisModel demoAxis in demoAxes)
{
@@ -1690,7 +1689,7 @@ namespace CMS_CORE.Demo
}
public override CmsError FILES_RActiveProgramData(int processId, ref ActiveProgramDataModel data)
{
{
// Check if the NC Demo is Connected
CmsError cmsError = CheckConnection();
if (cmsError.IsError())
@@ -1806,7 +1805,7 @@ namespace CMS_CORE.Demo
int processId = 0;
// Foreach value
foreach(var val in ints)
foreach (var val in ints)
{
byte[] bytes = BitConverter.GetBytes(val);
@@ -1852,7 +1851,7 @@ namespace CMS_CORE.Demo
StartStopQueueEnabled = bytes[2] == 1,
ProcessId = processId
};
return NO_ERROR;
}
@@ -1886,10 +1885,19 @@ namespace CMS_CORE.Demo
CmsError cmsError = CheckConnection();
if (cmsError.IsError())
return cmsError;
return NO_ERROR;
}
//public override CmsError FILES_WUploadJobMain(int processId)
//{
// CmsError cmsError = CheckConnection();
// if (cmsError.IsError())
// return cmsError;
// return NO_ERROR;
//}
#endregion File Management
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1942,6 +1950,14 @@ namespace CMS_CORE.Demo
config.MagPositionOptionActive = demoConf.MagPositionOption;
config.MaxOffsets = 5;
// Get magazine status
Dictionary<int, bool> magazineStatus = new Dictionary<int, bool>();
CmsError cmsError = TOOLS_RMagazineStatus(ref magazineStatus);
if (cmsError.IsError())
return cmsError;
MagazineConfig.ForEach(x => x.LoadingIsActive = magazineStatus[x.Id]);
config.Magazines = MagazineConfig;
}
catch (Exception ex)
@@ -2729,6 +2745,7 @@ namespace CMS_CORE.Demo
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#region Nc Tool Manager
public override CmsError TOOLS_RMagazineConfig(ref List<NcMagazineConfigModel> config)
{
config = new List<NcMagazineConfigModel>()
@@ -2744,7 +2761,7 @@ namespace CMS_CORE.Demo
Id = 2,
MaxPositions = 10,
Type = NC_MAGAZINE_TYPE.DISK
},
},
new NcMagazineConfigModel()
{
Id = 3,
@@ -2795,7 +2812,6 @@ namespace CMS_CORE.Demo
return ManageException(ex);
}
return NO_ERROR;
}
+1 -1
View File
@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CMS_CORE.Exceptions
namespace CMS_CORE_Library.Exceptions
{
public class Nc_Exception : Exception
{
+4 -3
View File
@@ -1,4 +1,5 @@
using CMS_CORE.Utils;
using CMS_CORE_Library.Models;
using CMS_CORE_Library.Utils;
using System;
using System.Collections.Generic;
using System.Globalization;
@@ -6,11 +7,11 @@ using System.IO;
using System.Linq;
using System.Threading;
using System.Windows.Forms;
using static CMS_CORE_Library.DataStructures;
using static CMS_CORE_Library.Models.DataStructures;
#pragma warning disable 1591
namespace CMS_CORE.Fanuc
namespace CMS_CORE_Library.Fanuc
{
public class Nc_Fanuc : Nc
{
+59
View File
@@ -0,0 +1,59 @@
namespace CMS_CORE_Library.Models
{
public class CmsError
{
public CMS_ERROR_CODES errorCode;
public string localizationKey;
public CmsError(CMS_ERROR_CODES errorCode, string message)
{
this.errorCode = errorCode;
this.localizationKey = message;
}
public bool IsError()
{
if (errorCode == CMS_ERROR_CODES.OK)
return false;
else
return true;
}
public static CmsError InternalError(string message)
{
return new CmsError(CMS_ERROR_CODES.INTERNAL_ERROR, message);
}
public static CmsError NcError(string message)
{
return new CmsError(CMS_ERROR_CODES.NC_PROD_ERROR, message);
}
}
public enum CMS_ERROR_CODES : uint
{
OK = 0,
NC_PROD_ERROR = 1,
NOT_CONNECTED = 2,
PROC_NOT_FOUND = 3,
FUNCTION_NOT_ALLOWED = 4,
BIT_NOT_IN_RANGE = 5,
BYTE_NOT_IN_RANGE = 6,
INTERNAL_ERROR = 7,
INCORRECT_PARAMETERS = 8,
NC_LANGUAGE_ERROR = 9,
SIEMENS_ENVIRONMENT_NOT_FOUND = 10,
SIEMENS_HMI_NOT_RUNNING = 11,
MAX_TOOL_REACHED = 12,
MAX_EDGES_PER_TOOL_REACHED = 13,
MAX_FAMILY_REACHED = 14,
MAX_MULTITOOL_REACHED = 15,
MAX_TOOLS_PER_MULTITOOL_REACHED = 16,
MAX_MULTITOOL_LOCATION_REACHED = 17,
MAG_POS_OCCUPIED = 18,
MAGAZINE_OCCUPIED = 19,
TOOL_IS_MOUNTED = 20,
TOOL_AND_POSITION_NOT_MATCHING = 21,
FILE_NOT_FOUND = 22
}
}
+334
View File
@@ -0,0 +1,334 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using static CMS_CORE_Library.Nc;
namespace CMS_CORE_Library.Models
{
public class DataStructures
{
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#region Data structure models
// R-W MEMORY Cell
internal struct MEMORY_CELL
{
public readonly MEMORY_TYPE MemType;
public readonly int Address;
public readonly int SubAddress; //Only for Siemens
public readonly int Size;
public MEMORY_CELL(MEMORY_TYPE MType, int Addr, int SubAddr, int Sz)
{
MemType = MType;
Address = Addr;
SubAddress = SubAddr;
Size = Sz;
}
public MEMORY_CELL(MEMORY_TYPE MType, int Addr, int Sz)
{
MemType = MType;
Address = Addr;
SubAddress = 0;
Size = Sz;
}
}
public class AlarmModel
{
public uint Id;
public string Message;
public bool IsWarning;
public int Process;
public DateTime DateTime;
}
public class PlcAlarmModel
{
public uint Id;
public bool IsWarning;
public bool RestorationIsActive;
public List<int> Process;
}
public class ProcessDataModel
{
public uint Id;
public string Type;
public bool IsInAlarm;
public string PartProgramName;
public string Status;
public bool Visible;
public ushort Reps;
public bool IsSelected;
}
public class FunctionalityModel
{
public uint Id;
public bool IsActive;
}
public struct StrobeModel
{
public uint Id;
public bool IsActive;
}
public class AxisResetDataModel
{
public bool IsActive;
public int Percentage;
public AxisResetDataModel()
{
IsActive = false;
Percentage = 0;
}
public override bool Equals(object obj)
{
var item = obj as AxisResetDataModel;
if (IsActive == item.IsActive && Percentage == item.Percentage)
return true;
else
return false;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
}
public struct CounterModel
{
public uint Id;
public uint Value;
}
public class SoftKeysModel
{
public uint Id;
public bool Active;
public bool Value;
}
public class HeadDataModel
{
public uint Id;
public byte Process;
public byte Override;
public ushort Load_Abrasive;
public int ActualSpeed_Pressure;
public short MountedTool_Vacum;
public bool IsActive;
public bool IsSelected;
public bool OverrideEditable;
public bool AbrasiveIsActive;
}
public class AxisModel
{
public int Id;
public string Name;
}
public class PreviewFileModel
{
public string Name;
public string Path;
public string AbsolutePath;
public bool IsDirectory;
}
public class InfoFile
{
public string Name;
public DateTime CreationDate;
public DateTime LastModDate;
public List<string> Content;
public string PreviewBase64;
public string AbsolutePath;
}
public class ActiveProgramDataModel
{
public string Path { get; set; }
public List<string> IsoLines { get; set; }
public DateTime TimeLeft { get; set; }
}
public class QueueStatusModel
{
public int ProcessId;
public bool LoadNextProgram;
public QUEUE_STATUS Status;
public bool StartStopQueueEnabled;
}
public enum QUEUE_STATUS
{
NOT_ACTIVE = 0,
RUNNING = 1,
WAITING_OPERATOR = 2,
CLOSING = 3
}
#endregion Data structure models
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#region Constants
public static readonly string[] VALID_PP_FORMATS = { ".txt", ".cnc", ".ini" };
public static readonly string[] VALID_IMAGE_FORMATS = { ".jpg", ".jpeg", ".png" };
public static readonly string IMAGES_PATH = @"C:\CMS\STEP\pp_img\";
public const int USER_SOFTKEYS_NUMBER = 128;
public const int NC_SOFTKEYS_NUMBER = 32;
public const int PROCESS_NUMBER = 6;
public const int ALARMS_NUMBER = 1024;
public const int HEADS_NUMBER = 20;
public enum HEAD_OVERRIDE_SIGN
{
PLUS = 0,
MINUS = 1
}
/** <summary>Process-Status</summary> */
public enum PROC_STATUS : ushort
{
/** <summary>Idle-Status</summary> */
IDLE = 1,
/** <summary>Run-Status</summary> */
RUN = 2,
/** <summary>Hold-Status</summary> */
HOLD = 3,
/** <summary>Error-Status</summary> */
ERROR = 4,
/** <summary>Reset-Status</summary> */
RESET = 5,
/** <summary>Emergency-Status</summary> */
EMERG = 6
};
/** <summary>CMS-Process-Mode</summary> */
public enum PROC_MODE : ushort
{
/** <summary>Automatic-Mode</summary> */
AUTO = 1,
/** <summary>Edit-Mode</summary> */
EDIT = 2,
/** <summary>Mdi-Mode</summary> */
MDI = 3,
/** <summary>Remote-Mode</summary> */
REMOTE = 4,
/** <summary>Teach-Mode</summary> */
TEACH = 5,
/** <summary>Ref-Mode</summary> */
REF = 6,
/** <summary>Jog-Mode</summary> */
JOG = 7,
/** <summary>Joginc-Mode</summary> */
JOGINC = 8,
/** <summary>Ret_on_Profile-Mode</summary> */
RETPROF = 9,
/** <summary>Handle-Mode</summary> */
HANDLE = 10,
/** <summary>Restart-Mode</summary> */
RESTART = 11,
/** <summary>Error-Mode</summary> */
ERROR = 12
};
public enum MAGAZINE_ACTIONS
{
NONE = 0,
LOADING = 1,
UNLOADING = 2,
TRANSFER = 4,
GENERIC = 5
}
public enum SIEMENS_MAGAZINE_TYPE
{
CHAIN = 1,
REVOLVER = 3,
BOX_MAGAZINE = 5,
MAGAZINE_TOOL_BUFFER = 7,
MAGAZINE_LOADING_STATION = 9
}
public enum NC_MAGAZINE_TYPE
{
BOX_MAGAZINE = 0,
DISK = 1,
CHAIN = 2,
}
public enum POSITION_TYPE
{
MAGAZINE_LOCATION = 1,
SPINDLE = 2,
GRIPPER = 3,
LOADER = 4,
TRANSFER_LOCATION = 5,
LOADING_STATION = 6,
LOADING_POINT = 7
}
public enum ROTATION
{
NONE = 0,
CLOCKWHISE = 1,
COUNTERCLOCKWHISE = 2
}
public enum SIEMENS_LIFE_TYPE
{
NONE = 0,
TIME = 1,
COUNT = 2,
WEAR = 4
}
public static IFormatProvider numberFormat = (NumberFormatInfo)CultureInfo.InvariantCulture.NumberFormat.Clone();
#region Cms Errors Codes
public static CmsError NO_ERROR = new CmsError(CMS_ERROR_CODES.OK, "");
public static CmsError NOT_CONNECTED_ERROR = new CmsError(CMS_ERROR_CODES.NOT_CONNECTED, "error_not_connected");
public static CmsError PROC_NOT_FOUND_ERROR = new CmsError(CMS_ERROR_CODES.FUNCTION_NOT_ALLOWED, "error_process_not_found");
public static CmsError FUNCTION_NOT_ALLOWED_ERROR = new CmsError(CMS_ERROR_CODES.FUNCTION_NOT_ALLOWED, "error_function_not_allowed");
public static CmsError BIT_NOT_IN_RANGE_ERROR = new CmsError(CMS_ERROR_CODES.BIT_NOT_IN_RANGE, "error_bit_not_in_range");
public static CmsError BYTE_NOT_IN_RANGE_ERROR = new CmsError(CMS_ERROR_CODES.BYTE_NOT_IN_RANGE, "error_byte_not_in_range");
public static CmsError INCORRECT_PARAMETERS_ERROR = new CmsError(CMS_ERROR_CODES.INCORRECT_PARAMETERS, "error_incorrect_parameters");
public static CmsError INCORRECT_LANGUAGE_ERROR = new CmsError(CMS_ERROR_CODES.NC_LANGUAGE_ERROR, "error_invalid_language");
public static CmsError SIEMENS_ENVIRONMENT_NOT_FOUND_ERROR = new CmsError(CMS_ERROR_CODES.SIEMENS_ENVIRONMENT_NOT_FOUND, "error_siemens_enviroment_not_found_error");
public static CmsError SIEMENS_HMI_NOT_RUNNING_ERROR = new CmsError(CMS_ERROR_CODES.SIEMENS_HMI_NOT_RUNNING, "error_siemens_hmi_not_running");
public static CmsError MAX_TOOL_REACHED_ERROR = new CmsError(CMS_ERROR_CODES.MAX_TOOL_REACHED, "error_max_tool_reached");
public static CmsError MAX_EDGES_PER_TOOL_REACHED_ERROR = new CmsError(CMS_ERROR_CODES.MAX_EDGES_PER_TOOL_REACHED, "error_max_edges_per_tool_reached");
public static CmsError MAX_FAMILY_REACHED_ERROR = new CmsError(CMS_ERROR_CODES.MAX_FAMILY_REACHED, "error_max_family_reached");
public static CmsError MAX_MULTITOOL_REACHED_ERROR = new CmsError(CMS_ERROR_CODES.MAX_MULTITOOL_REACHED, "error_max_multitools_reached");
public static CmsError MAX_TOOLS_PER_MULTITOOL_REACHED_ERROR = new CmsError(CMS_ERROR_CODES.MAX_TOOLS_PER_MULTITOOL_REACHED, "error_max_tools_per_multitool_reached");
public static CmsError MAX_MULTITOOL_LOCATION_REACHED_ERROR = new CmsError(CMS_ERROR_CODES.MAX_MULTITOOL_LOCATION_REACHED, "error_max_multitools_location_reached");
public static CmsError MAGAZINE_POSITION_OCCUPIED_ERROR = new CmsError(CMS_ERROR_CODES.MAG_POS_OCCUPIED, "error_magazine_position_occupied");
public static CmsError MAGAZINE_BUSY_ERROR = new CmsError(CMS_ERROR_CODES.MAGAZINE_OCCUPIED, "error_magazine_occupied");
public static CmsError TOOL_IS_MOUNTED_ERROR = new CmsError(CMS_ERROR_CODES.TOOL_IS_MOUNTED, "error_tool_mounted");
public static CmsError TOOL_AND_POSITION_NOT_MATCHING_ERROR = new CmsError(CMS_ERROR_CODES.TOOL_IS_MOUNTED, "error_tool_and_position_not_matching");
public static CmsError FILE_NOT_FOUND_ERROR = new CmsError(CMS_ERROR_CODES.FILE_NOT_FOUND, "error_file_not_found");
#endregion Cms Errors Codes
#endregion Constants
}
}
+173
View File
@@ -0,0 +1,173 @@
namespace CMS_CORE_Library.Models
{
public class ToolManagerOptionsModel
{
public bool FamilyOpt { get; set; }
public bool ShankOpt { get; set; }
public bool MagPosTypeOpt { get; set; }
public bool OffsetOpt { get; set; }
public bool ReviveOpt { get; set; }
public bool GammaOpt { get; set; }
public bool LifeOpt { get; set; }
public bool TcpOpt { get; set; }
public bool CoolingOpt { get; set; }
public bool MultidimensionalShankOpt { get; set; }
public bool SelfAdaptivePathOpt { get; set; }
public bool DynamicCompensationOpt { get; set; }
public bool BallufOpt { get; set; }
}
public class OffsetModel
{
public short Id { get; set; }
public double Length { get; set; }
public double Radius { get; set; }
public double WearLength { get; set; }
public double WearRadius { get; set; }
}
public class NcShankModel
{
public int ShankId { get; set; }
public int Balluf { get; set; }
public byte MagazineId { get; set; }
public byte PositionId { get; set; }
public byte MagazinePositionType { get; set; }
}
public class NcToolModel
{
public int ToolId { get; set; }
public int FamilyId { get; set; }
public int ShankId { get; set; }
public byte Status { get; set; }
public int OffsetLength { get; set; }
public int ResidualLife { get; set; }
public int OffsetId1 { get; set; }
public int OffsetId2 { get; set; }
public int OffsetId3 { get; set; }
public int ResidualRevive { get; set; }
}
public class NcFamilyModel
{
public int FamilyId { get; set; }
public byte ToolType { get; set; }
public byte TcpTable { get; set; }
public byte Gamma { get; set; }
public byte RotationType { get; set; }
public byte CoolingByte { get; set; }
public ushort MaxSpeed { get; set; }
public byte MaxLoad { get; set; }
public byte MinLoadPctAutoload { get; set; }
public byte MaxLoadPctAutoload { get; set; }
public ushort DynamicCompensation { get; set; }
public byte MinLoadDynamicCompensation { get; set; }
public byte MaxLoadDynamicCompensation { get; set; }
public byte LifeType { get; set; }
public int NominalLife { get; set; }
public ushort ReviveDelta { get; set; }
public byte RightSize { get; set; }
public byte LeftSize { get; set; }
}
internal class NcFamilyFileModel
{
public int Id { get; set; }
public byte ToolType { get; set; }
public byte TcpTable { get; set; }
public byte Gamma { get; set; }
public byte RotationType { get; set; }
public byte CoolingByte { get; set; }
public ushort MaxSpeed { get; set; }
public byte MaxLoad { get; set; }
public byte MinLoadPctAutoload { get; set; }
public byte MaxLoadPctAutoload { get; set; }
public ushort DynamicCompensation { get; set; }
public byte MinLoadDynamicCompensation { get; set; }
public byte MaxLoadDynamicCompensation { get; set; }
public byte LifeType { get; set; }
public int NominalLife { get; set; }
public ushort ReviveDelta { get; set; }
public static explicit operator NcFamilyFileModel(NcFamilyModel obj)
{
return new NcFamilyFileModel()
{
Id = obj.FamilyId,
ToolType = obj.ToolType,
TcpTable = obj.TcpTable,
Gamma = obj.Gamma,
RotationType = obj.RotationType,
CoolingByte = obj.CoolingByte,
MaxSpeed = obj.MaxSpeed,
MaxLoad = obj.MaxLoad,
MinLoadDynamicCompensation = obj.MinLoadDynamicCompensation,
MaxLoadDynamicCompensation = obj.MaxLoadDynamicCompensation,
MaxLoadPctAutoload = obj.MaxLoadPctAutoload,
MinLoadPctAutoload = obj.MinLoadPctAutoload,
DynamicCompensation = obj.DynamicCompensation,
LifeType = obj.LifeType,
NominalLife = obj.NominalLife,
ReviveDelta = obj.ReviveDelta
};
}
}
internal class NcFamilySizeFileModel
{
public int Id { get; set; }
public byte RightSize { get; set; }
public byte LeftSize { get; set; }
public static explicit operator NcFamilySizeFileModel(NcFamilyModel obj)
{
return new NcFamilySizeFileModel()
{
Id = obj.FamilyId,
RightSize = obj.RightSize,
LeftSize = obj.LeftSize
};
}
}
public class NcMagazinePositionModel
{
public byte MagazineId { get; set; }
public byte PositionId { get; set; }
public byte Type { get; set; }
public byte Disabled { get; set; }
}
}
@@ -0,0 +1,142 @@
namespace CMS_CORE_Library.Models
{
#region Pre and Post Power on Models
public class PreAndPostPowerOnModel
{
public PrePowerOnModel PrePowerOn { get; set; }
public PostPowerOnModel PostPowerOn { get; set; }
public PreAndPostPowerOnModel()
{
PrePowerOn = new PrePowerOnModel();
PostPowerOn = new PostPowerOnModel();
}
public override bool Equals(object obj)
{
var item = obj as PreAndPostPowerOnModel;
if (item == null)
return false;
if (!PrePowerOn.Equals(item.PrePowerOn) || !PostPowerOn.Equals(item.PostPowerOn))
return false;
return true;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
}
public class PrePowerOnModel
{
public PowerOnDataModel PowerOn { get; set; }
public PowerOnDataModel AirPressure { get; set; }
public PowerOnDataModel ProtectionStatus { get; set; }
public PowerOnDataModel EmergencyButtons { get; set; }
public PowerOnDataModel SettingMode { get; set; }
public PowerOnDataModel StartingKey { get; set; }
public PrePowerOnModel()
{
PowerOn = new PowerOnDataModel();
AirPressure = new PowerOnDataModel();
ProtectionStatus = new PowerOnDataModel();
EmergencyButtons = new PowerOnDataModel();
SettingMode = new PowerOnDataModel();
StartingKey = new PowerOnDataModel();
}
public override bool Equals(object obj)
{
var item = obj as PrePowerOnModel;
if (item == null)
return false;
if (!PowerOn.Equals(item.PowerOn) ||
!AirPressure.Equals(item.AirPressure) ||
!ProtectionStatus.Equals(item.ProtectionStatus) ||
!EmergencyButtons.Equals(item.EmergencyButtons) ||
!SettingMode.Equals(item.SettingMode) ||
!StartingKey.Equals(item.StartingKey))
return false;
return true;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
}
public class PostPowerOnModel
{
public PowerOnDataModel AxisReset { get; set; }
public PowerOnDataModel WaterjetPump { get; set; }
public PostPowerOnModel()
{
AxisReset = new PowerOnDataModel();
WaterjetPump = new PowerOnDataModel();
}
public override bool Equals(object obj)
{
var item = obj as PostPowerOnModel;
if (item == null)
return false;
if (!AxisReset.Equals(item.AxisReset) ||
!WaterjetPump.Equals(item.WaterjetPump))
return false;
return true;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
}
public class PowerOnDataModel
{
public uint Id { get; set; }
public bool Active { get; set; }
public bool Clickable { get; set; }
public PowerOnDataModel()
{
Id = 0;
Active = false;
Clickable = false;
}
public override bool Equals(object obj)
{
var item = obj as PowerOnDataModel;
if (item == null)
return false;
if (Id != item.Id || Active != item.Active || Clickable != item.Clickable)
return false;
return true;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
}
#endregion Pre and Post Power on Models
}
@@ -0,0 +1,222 @@
using System.Collections.Generic;
using static CMS_CORE_Library.Models.DataStructures;
namespace CMS_CORE_Library.Models
{
public class SiemensToolModel
{
public int Id;
public string FamilyName;
public int ChildId;
public SIEMENS_LIFE_TYPE LifeType;
public int MagazinePositionType;
public int ToolType;
public int LeftSize;
public int RightSize;
public ROTATION Rotation;
public bool Cooling1;
public bool Cooling2;
public bool IsEnabled;
public bool IsActive;
public bool InFixedPlace;
public bool IsInhibited;
public bool IsMeasured;
public bool InChangeTool;
public bool IsInUse;
public bool PreAlarm;
public double MaxSpeed;
public double MaxAcceleration;
public int MagazineId;
public int PositionId;
public int MultitoolId;
public List<EdgeModel> EdgesData;
public SiemensToolModel()
{
EdgesData = new List<EdgeModel>();
}
}
public class EdgeModel
{
public int Id;
public double ResidualLife;
public double NominalLife;
public double PreAlmLife;
public Dictionary<string, double> EdgeAdditionalParams;
public EdgeModel()
{
EdgeAdditionalParams = new Dictionary<string, double>();
}
}
public class ShankModel
{
public int Id;
public string Name;
public bool IsEnabled;
public bool IsInhibited;
public bool InChangeTool;
public bool InFixedPlace;
public bool InUse;
public int LeftSize;
public int RightSize;
public int MagazinePositionType;
public int MaxChilds;
public int MagazineId;
public int PositionId;
public List<ShankChildModel> ChildsTools;
public ShankModel()
{
ChildsTools = new List<ShankChildModel>();
}
}
public class ShankChildModel
{
public int Id;
public int MultitoolId;
public string FamilyName;
public int ToolType;
}
public class FamilyModel
{
public string Name;
public List<FamilyChildModel> ChildTools;
public FamilyModel()
{
ChildTools = new List<FamilyChildModel>();
}
}
public class FamilyChildModel
{
public int Id;
public int ChildId;
public int ToolType;
}
public class PositionModel
{
public int PositionId;
public int MagazineId;
public POSITION_TYPE PhysicalType;
public int Type;
public bool Disabled;
}
public class EdgeConfigModel
{
public string Name;
public string Path;
public int Number;
}
public class MountedToolModel
{
public int PositionId;
public int MagazineId;
public int ToolId;
public SiemensToolModel ChildTool;
public ShankModel ChildShank;
}
public class NewToolInMagazineModel
{
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;
}
///////////////// Tools Configuration
public class FieldsConfiguration
{
public string Name;
public string Type;
public string Category;
public bool ReadOnly;
public Dictionary<int, string> SelectValues;
public uint MinValue;
public uint MaxValue;
}
public class FamiliesConfiguration
{
public List<FieldsConfiguration> FamilyConfiguration;
public List<FieldsConfiguration> FamilyReadOnlyConfiguration;
public List<FieldsConfiguration> ToolsConfiguration;
}
public class ShanksConfiguration
{
public List<FieldsConfiguration> ShankConfiguration;
public List<FieldsConfiguration> ToolsConfiguration;
}
public class EdgesConfiguration
{
public List<FieldsConfiguration> EdgeConfiguration;
public Dictionary<int, List<string>> EdgesAdditionalParamsConfiguration;
}
public class NcMagazineConfigModel
{
public byte Id;
public NC_MAGAZINE_TYPE Type;
public int MaxPositions;
}
public class SiemensMagazineConfigModel
{
public byte Id;
public SIEMENS_MAGAZINE_TYPE Type;
public int MaxPositions;
public string Name;
public bool LoadingIsActive;
public int LoadPosition;
}
public class ToolTableConfiguration
{
public int MaxTools;
public int MaxEdgesPerTools;
public int MaxToolsPerFamily;
public int MaxMultitools;
public int MaxToolsPerMultitools;
public int MaxOffsets;
public bool MultitoolOptionActive;
public bool FamilyOptionActive;
public bool MagPositionOptionActive;
public bool OffsetOptionActive;
public List<SiemensMagazineConfigModel> Magazines;
public List<FieldsConfiguration> ToolsConfiguration;
public FamiliesConfiguration FamiliesConfiguration;
public ShanksConfiguration ShanksConfiguration;
public List<FieldsConfiguration> MagazinePosConfiguration;
public EdgesConfiguration EdgesConfiguration;
}
}
+12 -10
View File
@@ -1,12 +1,13 @@
using System;
using CMS_CORE_Library.Models;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using static CMS_CORE_Library.DataStructures;
using static CMS_CORE_Library.Models.DataStructures;
namespace CMS_CORE
namespace CMS_CORE_Library
{
public abstract partial class Nc
{
@@ -320,6 +321,7 @@ namespace CMS_CORE
* */
public abstract CmsError NC_RLanguage(ref CultureInfo Language);
/**
* <summary>
* Write the configured language of the NC
@@ -362,8 +364,6 @@ namespace CMS_CORE
public abstract CmsError NC_GetTranslatedPlcMessages(string language, ref Dictionary<int, string> messages);
/**
* <summary>
* Set the screen page visible of the NC
@@ -377,7 +377,6 @@ namespace CMS_CORE
public abstract CmsError NC_SetScreenVisible(SCREEN_PAGE screen);
#endregion NC High-level data (to override)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1373,9 +1372,8 @@ namespace CMS_CORE
public abstract CmsError FILES_WStartQueue();
public abstract CmsError FILES_WStopQueue();
public abstract CmsError FILES_WLoadNextPartProgram(string localPath, string ncFileName);
public abstract CmsError FILES_WLoadNextPartProgram(string localPath, string ncFileName);
#endregion File Management (To override)
@@ -1692,6 +1690,7 @@ namespace CMS_CORE
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#region Nc Tool Manager
public abstract CmsError TOOLS_WOptions(ToolManagerOptionsModel options);
public abstract CmsError TOOLS_ROffset(short offsetId, ref OffsetModel offset);
@@ -1861,12 +1860,13 @@ namespace CMS_CORE
internal const ushort OSAI_DISTTOGO = 5;
internal const ushort OSAI_MACHINEPOS = 6;
/** <summary>Nc Screen</summary> */
public enum SCREEN_PAGE
{
//Siemens
Siemens_Machine = 100,
Siemens_Parameter = 101,
Siemens_Program = 102,
Siemens_ProgramManager = 103,
@@ -1875,6 +1875,7 @@ namespace CMS_CORE
//Fanuc
Fanuc_Pos = 201,
Fanuc_Prog = 202,
Fanuc_Offset = 203,
Fanuc_Message = 204,
@@ -1882,8 +1883,8 @@ namespace CMS_CORE
Fanuc_Custom1 = 206,
Fanuc_Custom2 = 207,
Fanuc_System = 208
}
#endregion CONSTANTS (Struct and Enum are Static for definition)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1893,6 +1894,7 @@ namespace CMS_CORE
// TODO REMOVE
//Lingua CN
internal MEMORY_CELL PARAM_LING_FANUC = new MEMORY_CELL(MEMORY_TYPE.Null, 3281, 0, 1);
internal MEMORY_CELL PARAM_LING_FANUC_W = new MEMORY_CELL(MEMORY_TYPE.Fanuc_G, 581, 0, 1);
//Matricola Macchina
+33 -40
View File
@@ -1,6 +1,7 @@
using CMS_CORE.Exceptions;
using CMS_CORE.Utils;
using CMS_CORE_Library.Exceptions;
using CMS_CORE_Library.Models;
using CMS_CORE_Library.OPENControl;
using CMS_CORE_Library.Utils;
using CndexLinkDotNet;
using System;
using System.Collections;
@@ -9,17 +10,16 @@ using System.ComponentModel;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.ServiceModel;
using System.Text;
using System.Threading;
using static CMS_CORE.Nc;
using static CMS_CORE.Osai.MEMORY_ADDRESS;
using static CMS_CORE_Library.DataStructures;
using static CMS_CORE_Library.Models.DataStructures;
using static CMS_CORE_Library.Nc;
using static CMS_CORE_Library.Osai.MEMORY_ADDRESS;
using static CMS_CORE_Library.ToolConfigurations;
using static CMS_CORE.Utils.Nc_Utils;
using static CMS_CORE_Library.Utils.Nc_Utils;
namespace CMS_CORE.Osai
namespace CMS_CORE_Library.Osai
{
public class Nc_Osai : Nc
{
@@ -39,8 +39,10 @@ namespace CMS_CORE.Osai
private static Dictionary<int, string> PlcMessages;
private const string TOOL_MANAGER_DIRECTORY_PATH = @"STEP\";
// private const string TOOL_MANAGER_DIRECTORY_PATH = @"test\OEM\CMS\SYS\STEP\";
private const string NC_PROGRAM_PATH = @"CAMBIO\";
private const string NC_PROGRAM_UPLOAD_PATH = @"CAMBIO\UPLOADED_PP\";
private static List<string> EXT_PP = new List<string>() { "", "TXT", "CNC", "INI" };
private static List<string> EXT_IMG = new List<string>() { "PNG", "JPG", "JPEG" };
@@ -116,7 +118,6 @@ namespace CMS_CORE.Osai
Connected = true;
else
Connected = false;
}
catch (Exception ex)
{
@@ -130,9 +131,9 @@ namespace CMS_CORE.Osai
public override CmsError NC_Disconnect()
{
//Set Connected to FALSE and close the session
if(Connected)
if (Connected)
OpenNC.Close();
Connected = false;
Connected = false;
return NO_ERROR;
}
@@ -1223,7 +1224,6 @@ namespace CMS_CORE.Osai
//Fill all the List
foreach (GETINTDATA ax in Pos)
{
if (ax.AxisName > 0)
{
AxName = ((char)ax.AxisName).ToString();
@@ -1282,7 +1282,6 @@ namespace CMS_CORE.Osai
//Fill all the List
foreach (GETINTDATA ax in Pos)
{
if (ax.AxisName > 0)
{
AxName = ((char)ax.AxisName).ToString();
@@ -1341,7 +1340,6 @@ namespace CMS_CORE.Osai
//Fill all the List
foreach (GETINTDATA ax in Pos)
{
if (ax.AxisName > 0)
{
AxName = ((char)ax.AxisName).ToString();
@@ -1400,7 +1398,6 @@ namespace CMS_CORE.Osai
//Fill all the List
foreach (GETINTDATA ax in Pos)
{
if (ax.AxisName > 0)
{
AxName = ((char)ax.AxisName).ToString();
@@ -1459,7 +1456,6 @@ namespace CMS_CORE.Osai
//Fill all the List
foreach (GETINTDATA ax in Pos)
{
if (ax.AxisName > 0)
{
AxName = ((char)ax.AxisName).ToString();
@@ -1948,7 +1944,6 @@ namespace CMS_CORE.Osai
public override CmsError FILES_RGetFileList(string path, ref List<PreviewFileModel> files)
{
ushort nReturn;
String temppath;
uint findHandler;
@@ -1986,15 +1981,12 @@ namespace CMS_CORE.Osai
//If there's an error
if (errorClass != 0 || errorNum != 0 || nReturn == 0)
return GetNCError(errorClass, errorNum);
} while (found);
nReturn = OpenNC.LogFSFindClose(findHandler, out errorClass, out errorNum);
//If there's an error
if (errorClass != 0 || errorNum != 0 || nReturn == 0)
return GetNCError(errorClass, errorNum);
}
return NO_ERROR;
}
@@ -2057,11 +2049,11 @@ namespace CMS_CORE.Osai
CmsError cmsError = CheckConnection();
if (cmsError.IsError())
return cmsError;
//Fix the Path
temppath = filePath;
temppath = temppath.TrimStart('\\');
ushort nReturn;
try
{
@@ -2098,7 +2090,6 @@ namespace CMS_CORE.Osai
//If there's an error launch exception
if (errorClass != 0 || errorNum != 0 || nReturn == 0)
return GetNCError(errorClass, errorNum);
}
catch (Exception ex)
{
@@ -2106,7 +2097,6 @@ namespace CMS_CORE.Osai
}
return NO_ERROR;
}
public override CmsError FILES_RActiveProgramData(int processId, ref ActiveProgramDataModel data)
@@ -2371,12 +2361,18 @@ namespace CMS_CORE.Osai
if (cmsError.IsError())
return cmsError;
// Get magazine status
Dictionary<int, bool> magazineStatus = new Dictionary<int, bool>();
cmsError = TOOLS_RMagazineStatus(ref magazineStatus);
if (cmsError.IsError())
return cmsError;
config.Magazines = conf.Select(x => new SiemensMagazineConfigModel()
{
Id = x.Id,
Type = (SIEMENS_MAGAZINE_TYPE) x.Type,
Type = (SIEMENS_MAGAZINE_TYPE)x.Type,
Name = x.Id.ToString(),
LoadingIsActive = true,
LoadingIsActive = magazineStatus[x.Id],
MaxPositions = x.MaxPositions
}).ToList();
@@ -2544,7 +2540,7 @@ namespace CMS_CORE.Osai
public override CmsError TOOLS_WOptions(ToolManagerOptionsModel options)
{
// Convert class into a single ushort
bool[] boolValues = new bool[13]
bool[] boolValues = new bool[13]
{
options.FamilyOpt,
options.ShankOpt,
@@ -2646,7 +2642,7 @@ namespace CMS_CORE.Osai
bool[] bits = IntToBool(status);
for(int i = 0; i < bits.Length; i++)
for (int i = 0; i < bits.Length; i++)
{
magazineStatus.Add(i + 1, bits[i]);
}
@@ -2736,7 +2732,7 @@ namespace CMS_CORE.Osai
return cmsError;
}
if(File.Exists(string.Format(backupFilePath, MAG_POSITION_FILE_NAME)))
if (File.Exists(string.Format(backupFilePath, MAG_POSITION_FILE_NAME)))
{
fileContent = File.ReadAllText(string.Format(backupFilePath, MAG_POSITION_FILE_NAME));
cmsError = FILES_WProgram(string.Format(filePath, MAG_POSITION_FILE_NAME), fileContent);
@@ -2991,7 +2987,7 @@ namespace CMS_CORE.Osai
// Insert into the new lives list
updatedLives.Add(toolId, life);
// Setup ack/strobe indexes
// Setup ack/strobe indexes
// if i > (32) + 15 then index = next word
strobeByteIndex = i > 47 ? TOOL_LIFE_UPDATED_CMD.Address + 1 : TOOL_LIFE_UPDATED_CMD.Address;
ackByteIndex = i > 47 ? TOOL_LIFE_UPDATED_ACK.Address + 1 : TOOL_LIFE_UPDATED_CMD.Address;
@@ -3043,13 +3039,12 @@ namespace CMS_CORE.Osai
.Where(x => x != String.Empty)
.Select(x => x.Split(';')) // Split line
.Select(x => new NcFamilySizeFileModel // Setup new model for each line
{
{
Id = ushort.Parse(x[0]),
RightSize = byte.Parse(x[1]),
LeftSize = byte.Parse(x[2]),
}).ToList();
List<NcToolModel> tools = File.ReadAllLines(string.Format(backupFilePath, TOOLS_FILE_NAME))
.Where(x => x != String.Empty)
.Select(x => x.Split(';'))
@@ -3514,7 +3509,7 @@ namespace CMS_CORE.Osai
//private CmsError FILE_PPImage(string PP_Name, ref string base64Image)
//{
// base64Image = "";
// //Check if exists the file
// DirectoryInfo DirToSearch = new DirectoryInfo(IMAGES_PATH);
// FileInfo[] filesInDir = DirToSearch.GetFiles(PP_Name + ".*");
@@ -3523,22 +3518,21 @@ namespace CMS_CORE.Osai
// {
// if(EXT_IMG.Contains(foundFile.Extension.TrimStart('.').ToUpper()))
// {
// base64Image = "data:image/" + foundFile.Extension + ";base64," + Convert.ToBase64String(System.IO.File.ReadAllBytes(foundFile.FullName));
// break;
// }
// }
// return NO_ERROR;
//}
//Get Program Path without extension
private string GetFilepathWithoutExt(string path)
{
String name = path.Split('\\').LastOrDefault();
String ext = name.Split('.').LastOrDefault();
if (String.IsNullOrWhiteSpace(ext) || name==ext)
if (String.IsNullOrWhiteSpace(ext) || name == ext)
return path;
else
return path.Remove(path.LastIndexOf("." + ext));
@@ -3738,7 +3732,6 @@ 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);
@@ -3784,9 +3777,9 @@ namespace CMS_CORE.Osai
// Tool manager areas
internal static MEMORY_CELL TOOL_MANAGER_COMMAND = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 13000, 2);
internal static MEMORY_CELL TOOL_MANAGER_STATUS = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 13001, 2);
internal static MEMORY_CELL TOOL_MANAGER_OPTIONS = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 13002, 2);
internal static MEMORY_CELL MAGAZINE_TYPES = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 13062, 4);
+1 -1
View File
@@ -7,7 +7,7 @@ using System.Text;
using System.Threading.Tasks;
using CMS_CORE_Library.OPENControl;
namespace CMS_CORE.Osai
namespace CMS_CORE_Library.Osai
{
partial class NativeConstants
{
+15 -21
View File
@@ -1,4 +1,5 @@
using CMS_CORE_Library;
using CMS_CORE_Library.Models;
using CMS_CORE_Library.Siemens;
using Siemens.Sinumerik.Operate.Services;
using System;
@@ -11,14 +12,14 @@ using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Xml.Linq;
using static CMS_CORE.Nc;
using static CMS_CORE.Siemens.MEMORY_ADDRESS;
using static CMS_CORE.Utils.Nc_Utils;
using static CMS_CORE_Library.DataStructures;
using static CMS_CORE_Library.Siemens.MEMORY_ADDRESS;
using static CMS_CORE_Library.Utils.Nc_Utils;
using static CMS_CORE_Library.Models.DataStructures;
using static CMS_CORE_Library.Nc;
using static CMS_CORE_Library.ToolConfigurations;
using static Siemens.Sinumerik.Operate.Services.ToolMngmntSvc;
namespace CMS_CORE.Siemens
namespace CMS_CORE_Library.Siemens
{
public class Nc_Siemens : Nc
{
@@ -407,7 +408,6 @@ namespace CMS_CORE.Siemens
return NO_ERROR;
}
//Set the NC Language
public override CmsError NC_WLanguage(CultureInfo Language)
{
@@ -530,8 +530,6 @@ namespace CMS_CORE.Siemens
return NO_ERROR;
}
#endregion High level methods
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1961,10 +1959,10 @@ namespace CMS_CORE.Siemens
return FILE_NOT_FOUND_ERROR;
// Check if file is stored on NC
if(filePath.StartsWith(BASE_FILE_PATH))
if (filePath.StartsWith(BASE_FILE_PATH))
fileSvc.Select(selectedNode, processId);
else
fileSvc.SelectExtern(selectedNode, processId);
fileSvc.SelectExtern(selectedNode, processId);
return FILES_RActiveProgramData(processId, ref data);
}
@@ -2150,7 +2148,6 @@ namespace CMS_CORE.Siemens
public override CmsError FILES_RQueueDataByProcess(ref QueueStatusModel status, int processId)
{ return NO_ERROR; }
public override CmsError FILES_WStartQueue()
{
return NO_ERROR;
@@ -2166,7 +2163,6 @@ namespace CMS_CORE.Siemens
return NO_ERROR;
}
private IEnumerable<string> GetLinesFromString(string text)
{
string line;
@@ -2721,7 +2717,7 @@ namespace CMS_CORE.Siemens
List<int> ids = Enumerable.Range(1, MAX_EDGES_PER_TOOL).ToList();
foreach(var edgeVal in tool.EdgesData)
foreach (var edgeVal in tool.EdgesData)
{
ids.Remove(edgeVal.Id);
}
@@ -3558,7 +3554,7 @@ namespace CMS_CORE.Siemens
{
return language.ThreeLetterWindowsLanguageName;
}
private int SwapIntEndianFormat(int value)
{
var b1 = (value >> 0) & 0xff;
@@ -3624,8 +3620,6 @@ namespace CMS_CORE.Siemens
// }
//}
private string ConvertStepToSiemensScreen(SCREEN_PAGE page)
{
switch (page)
@@ -4157,11 +4151,11 @@ namespace CMS_CORE.Siemens
// If Exist
if (paramConfig != null)
{
// Add additional param
tool
.EdgesData[edgeIndex]
.EdgeAdditionalParams
.Add(paramConfig.Name, Convert.ToDouble(actualString.Split('=').LastOrDefault(), numberFormat));
// Add additional param
tool
.EdgesData[edgeIndex]
.EdgeAdditionalParams
.Add(paramConfig.Name, Convert.ToDouble(actualString.Split('=').LastOrDefault(), numberFormat));
}
}
}
@@ -1,5 +1,5 @@
using System.Collections.Generic;
using static CMS_CORE_Library.DataStructures;
using CMS_CORE_Library.Models;
using System.Collections.Generic;
namespace CMS_CORE_Library.Siemens
{
+3 -2
View File
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using static CMS_CORE_Library.DataStructures;
using CMS_CORE_Library.Models;
using System.Collections.Generic;
using static CMS_CORE_Library.Models.DataStructures;
namespace CMS_CORE_Library
{
+2 -2
View File
@@ -3,9 +3,9 @@ using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static CMS_CORE_Library.DataStructures;
using static CMS_CORE_Library.Models.DataStructures;
namespace CMS_CORE.Utils
namespace CMS_CORE_Library.Utils
{
public static class Nc_Utils
{