using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using static CMS_CORE_Library.DataStructures; namespace CMS_CORE { public abstract partial class Nc { //Private Global Variables internal Boolean Connected; internal String Ip; internal ushort Port; internal Boolean UseProxy; internal String LibName = "CMS_CORE_Library.dll"; //Osai Variable internal string OSAI_PlcMessagesPath = @"C:\CMS\OSAI\"; internal string OSAI_WinNbiPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\OSAI\WinNBI\"; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #region LIB Methods /** * * Get the NC IP-Address * * Compatibility: Fanuc | Osai | Demo * * * */ public String LIB_GetIpAddress() { return Ip; } /** * * Set the NC IP-Address * * Compatibility: Fanuc | Osai | Demo * * * */ public void LIB_SetIpAddress(String ip) { Ip = ip; } /** * * Get Nc Port * * Compatibility: Fanuc | Osai | Demo * * * */ public ushort LIB_GetPort() { return Port; } /** * * Set Nc Port * * Compatibility: Fanuc | Osai | Demo * * * */ public void LIB_SetPort(ushort port) { Port = port; } /** * * Get Library Version * * Compatibility: Fanuc | Osai | Demo | Siemens * * * */ public String LIB_GetLibraryVersion() { return FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ProductVersion.ToString(); } #endregion LIB Methods #region LIB Methods (OSAI) /** * * Get if the library uses Windows proxy * * Compatibility: Osai * * * */ public Boolean LIB_GetWindowsProxy() { return UseProxy; } /** * * Set if the library need to use Windows proxy * * Compatibility: Osai * * * */ public void LIB_SetWindowsProxy(Boolean proxy) { UseProxy = proxy; } /** * * Get the path of PLC Messages Folder * * Compatibility: Osai * * * */ public string LIB_GetPlcMsgsPath() { return OSAI_PlcMessagesPath; } /** * * Set the path of PLC Messages Folder * * Compatibility: Osai * * * */ public void LIB_SetPlcMsgsPath(string folder) { OSAI_PlcMessagesPath = folder; } /** * * Get the path of Win-Nbi installation * * Compatibility: Osai * * * */ public string LIB_GetWinNbiPath() { return OSAI_WinNbiPath; } /** * * Set the path of Win-Nbi installation * * Compatibility: Osai * * * */ public void LIB_SetWinNbiPath(string folder) { OSAI_WinNbiPath = folder; } #endregion LIB Methods (OSAI) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #region NC High-level data (to override) /** * * Connect the NC * * Compatibility: Fanuc | Osai | Demo | Siemens * * Returns an error when an internal or a library error occours * * */ public abstract CmsError NC_Connect(); /** * * Disconnect the NC * * Compatibility: Fanuc | Osai | Demo | Siemens * * Returns an error when an internal or a library error occours * * */ public abstract CmsError NC_Disconnect(); /** * * Read Nc Status * * Compatibility: Fanuc | Osai | Demo | Siemens * * * Returns an error when an internal or a library error occours * */ public Boolean NC_IsConnected() { return Connected; } /** * * Read actual time of the NC-Software (sometimes it can be different from NC-Operative-System) * * Compatibility: Fanuc | Osai | Demo | Siemens * * * Returns an error when an internal or a library error occours * Reference of a DateTime Variable where data will be saved * */ public abstract CmsError NC_RDateTime(ref DateTime ActualTime); /** * * Read Vendor NC Serial number * * Compatibility: Fanuc | Osai | Demo | Siemens * * * Returns an error when an internal or a library error occours * Reference of a String Variable where data will be saved * */ public abstract CmsError NC_RSerialNumber(ref String SN); /** * * Read Model name of the NC * * Compatibility: Fanuc | Osai | Demo | Siemens * * * Returns an error when an internal or a library error occours * Reference of a String Variable where data will be saved * */ public abstract CmsError NC_RModelName(ref String ModelName); /** * * Read Software Version of the Nc * * Compatibility: Fanuc | Osai | Demo | Siemens * * * Returns an error when an internal or a library error occours * Reference of a String Variable where data will be saved * */ public abstract CmsError NC_RSoftwareVersion(ref String SWV); /** * * Read CMS Serial number of the Machine * * Compatibility: Fanuc | Osai | Demo | Siemens * * * Returns an error when an internal or a library error occours * Reference of a String Variable where data will be saved * */ public abstract CmsError NC_RMachineNumber(ref String MachNumber); /** * * Read number of configured Processes/Paths * * Compatibility: Fanuc | Osai | Demo | Siemens * * * Returns an error when an internal or a library error occours * Reference of a ushort Variable where data will be saved * */ public abstract CmsError NC_RProcessesNum(ref ushort ProcNumber); /** * * Read the configured language of the NC * * Compatibility: Fanuc | Osai | Demo | Siemens * * * Returns an error when an internal or a library error occours * Reference of a CultureInfo Variable where data will be saved * */ public abstract CmsError NC_RLanguage(ref CultureInfo Language); /** * * Read active alarms of the NC (Nc-Process indipendent). For OSAI Nc the list can contain only one Message * * Compatibility: Fanuc | Osai | Demo | Siemens * * * Returns an error when an internal or a library error occours * Process to execute the action * Reference of a List of String Variables where data will be saved * */ public abstract CmsError NC_RActiveAlarms(ref List alarms); /** * * Check if the NC is in running state * * Compatibility: Fanuc | Osai | Demo | Siemens * * * Returns an error when an internal or a library error occours * Reference to boolean where running state will be saved * */ public abstract CmsError NC_RIsRunning(ref bool running); public abstract CmsError NC_GetTranslatedPlcMessages(string language, ref Dictionary messages); #endregion NC High-level data (to override) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #region NC Low-level data (to override) /** * Read Boolean Parameter Machine (Not compatible for Axis Parameter (Multiple values in a parameter) * * Compatibility: Fanuc * * * Returns an error when an internal or a library error occours * Index of the parameter * Set the Bit to Read. (0..7) * Reference of a variable with Param values * */ public abstract CmsError NC_RParam(short Index, short Bit, ref Boolean Value); /** * Read Byte Parameter Machine (Not compatible for Axis Parameter (Multiple values in a parameter) * * Compatibility: Fanuc * * * Returns an error when an internal or a library error occours * Index of the parameter * Reference of a variable with Param values * */ public abstract CmsError NC_RParam(short Index, ref byte Value); /** * Read 2 Byte (Short) Parameter Machine (Not compatible for Axis Parameter (Multiple values in a parameter) * * Compatibility: Fanuc * * * Returns an error when an internal or a library error occours * Index of the parameter * Reference of a variable with Param values * */ public abstract CmsError NC_RParam(short Index, ref short Value); /** * Read 4 Byte (Integer) Parameter Machine (Not compatible for Axis Parameter (Multiple values in a parameter) * * Compatibility: Fanuc * * * Returns an error when an internal or a library error occours * Index of the parameter * Reference of a variable with Param values * */ public abstract CmsError NC_RParam(short Index, ref int Value); /** * Read Real Parameter Machine (Not compatible for Axis Parameter (Multiple values in a parameter) * * Compatibility: Fanuc * * * Returns an error when an internal or a library error occours * Index of the parameter * Reference of a variable with Param values * */ public abstract CmsError NC_RParam(short Index, ref double Value); #endregion NC Low-level data (to override) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #region PLC High-level data (to override) /** * * Read PMC active Messages * * Compatibility: Fanuc | Osai | Demo | Siemens * * * Returns an error when an internal or a library error occours * Reference of a List of String Variables where data will be saved * */ public abstract CmsError PLC_RActiveMessages(ref List Alarms); /** * * Start refresh message procedure * * Compatibility: Fanuc | Osai | Demo | Siemens * * * Returns an error when an internal or a library error occours * Alarm id to refresh * * */ public abstract CmsError PLC_WRefreshMessage(uint id); public abstract CmsError PLC_WRefreshAllMessages(); /** * * Start restore message procedure * * Compatibility: Fanuc | Osai | Demo | Siemens * * * Returns an error when an internal or a library error occours * Alarm id to restore * * */ public abstract CmsError PLC_WRestoreMessage(uint id); /** * * Read the status of the Power on data ( Pre-Power-On / Post-Power-On ) * * Compatibility: Fanuc | Osai | Demo | Siemens * * Returns an error when an internal or a library error occours * * Reference to the structure where the power on data will be saved **/ public abstract CmsError PLC_RPowerOnData(ref PreAndPostPowerOnModel powerOnModel); /** * * Write PowerOn data and status ( Pre-Power-On / Post-Power-On ) * * Compatibility: Fanuc | Osai | Demo | Siemens * * Returns an error when an internal or a library error occours * * Id of the edited power on data * Reference to the value of the power on data **/ public abstract CmsError PLC_WPowerOnData(uint id, bool value); /** * * Read the status of the UI functionality from PLC * * Compatibility: Fanuc | Osai | Demo | Siemens * * Returns an error when an internal or a library error occours * **/ public abstract CmsError PLC_RFunctionAccess(ref List functions); /** * * Read axes reset procedure data from PLC * * Compatibility: Fanuc | Osai | Demo | Siemens * * Returns an error when an internal or a library error occours * Reference to the axes reset procedure data * **/ public abstract CmsError PLC_RAxesResetData(ref AxisResetDataModel axisResetData); /** * * Read machine counters value from PLC * * Compatibility: Fanuc | Osai | Demo | Siemens * * Returns an error when an internal or a library error occours * Reference to the counters data * **/ public abstract CmsError PLC_RMachineCounters(ref List counters); /** * * Read nc softkeys values from PLC * * Compatibility: Fanuc | Osai | Demo | Siemens * * Returns an error when an internal or a library error occours * Reference to the nc softkey data * **/ public abstract CmsError PLC_RNcSoftKeys(ref List ncSoftKeys); /** * * Read user softkeys values from PLC * * Compatibility: Fanuc | Osai | Demo | Siemens * * Returns an error when an internal or a library error occours * Reference to the softkey data * **/ public abstract CmsError PLC_RUserSoftKeys(ref List softKeys); /** * * Write Nc softkey interaction into PLC * * Compatibility: Fanuc | Osai | Demo | Siemens * * Returns an when an internal or a library error occours * Nc softkey id * **/ public abstract CmsError PLC_WNcSoftKey(uint id); /** * * Write user softkey interaction into PLC * * Compatibility: Fanuc | Osai | Demo | Siemens * * Returns an error when an internal or a library error occours * User softkey id * **/ public abstract CmsError PLC_WUserSoftKey(uint id); /** * * Read heads data from PLC * * Compatibility: Fanuc | Osai | Demo | Siemens * * Returns an error when an internal or a library error occours * Recerence to the heads data * Number of heads data that are read * **/ public abstract CmsError PLC_RHeadsData(List heads, int number); /** * * Write head override sign into PLC * * Compatibility: Fanuc | Osai | Demo | Siemens * * Returns an error when an internal or a library error occours * Head id * Type of increment of the override * **/ public abstract CmsError PLC_WHeadOverride(uint id, HEAD_OVERRIDE_SIGN sign); #endregion PLC High-level data (to override) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #region PROCESS (PATH, CHANNEL) data (to override) /** * * Read the actual status of the Process "ProcNumber" * See for information about the PROC_Status type * * Compatibility: Fanuc | Osai | Demo | Siemens * * * Returns an error when an internal or a library error occours * Process number which the data refer * Reference of a PROC_Status Variable where data will be saved * */ public abstract CmsError PROC_RStatus(ushort ProcNumber, ref PROC_STATUS Status); /** * * Read the selected Mode Process "ProcNumber" * See for information about the PROC_Status type * * Compatibility: Fanuc | Osai | Demo | Siemens * * * Returns an error when an internal or a library error occours * Process number which the data refer * Reference of a PROC_Mode Variable where data will be saved * */ public abstract CmsError PROC_RMode(ushort ProcNumber, ref PROC_MODE Mode); /** * * Read active alarms of the process "ProcNumber". For OSAI Nc the list can contain only one Message * * Compatibility: Fanuc | Osai | Demo | Siemens * * * Returns an error when an internal or a library error occours * Process number which the data refer * Reference of a List of String Variables where data will be saved * */ public abstract CmsError PROC_RActiveAlarms(ushort procNumber, ref List alarms); /** * * Read actual & Next Lines of active PP * * Compatibility: Fanuc | Osai | Siemens * * * Returns an error when an internal or a library error occours * Process number which the data refer * Reference of a List of String Variables where data will be saved * */ public abstract CmsError PROC_RPPLines(ushort procNumber, ref List Lines); /** * * Read active PP Name * * Compatibility: Fanuc | Osai | Siemens * * * Returns an error when an internal or a library error occours * Process number which the data refer * Reference of a String Variables where data will be saved * */ public abstract CmsError PROC_RPPName(ushort procNumber, ref String Name); /** * * Read active PP and generic data * * Compatibility: Fanuc | Osai | Siemens * * Process number which the data refer * Reference to part program data structure * **/ public abstract CmsError PROC_RStatusAndData(ushort procNumber, ref ProcessDataModel processData); /** * * Read selected process * * Compatibility: Fanuc | Osai | Siemens * * Reference to the process number selected * **/ public abstract CmsError PROC_RSelectedProcess(ref ushort procNumber); /** * * Change the selected process * * Compatibility: Fanuc | Osai | Siemens * * New selected process number * **/ public abstract CmsError PROC_WSelectProcess(ushort procNumber); #endregion PROCESS (PATH, CHANNEL) data (to override) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #region AXES data (to override) /** * * Read the Interpolated position of all axes in Process "ProcNumber" * * Compatibility: Fanuc | Osai | Demo * * * Returns an error when an internal or a library error occours * Process to execute the action * Reference of Dictionary "Key,Value" with: Key: Axis Name, Value: Position * */ public abstract CmsError AXES_RInterpPosition(ushort ProcNumber, ref Dictionary Axes); /** * * Read the Programmed position of all axes in Process "ProcNumber". * For Fanuc-Nc there's not "Programmed position" variables. Si it is calculated from Machine-Pos and Distance-to-go * * Compatibility: Fanuc | Osai | Demo * * * Returns an error when an internal or a library error occours * Process to execute the action * Reference of Dictionary "Key,Value" with: Key: Axis Name, Value: Position * */ public abstract CmsError AXES_RProgrPosition(ushort ProcNumber, ref Dictionary Axes); /** * * Read the Machine position of all axes in Process "ProcNumber" * * Compatibility: Fanuc | Osai | Demo * * * Returns an error when an internal or a library error occours * Process to execute the action * Reference of Dictionary "Key,Value" with: Key: Axis Name, Value: Position * */ public abstract CmsError AXES_RMachinePosition(ushort ProcNumber, ref Dictionary Axes); /** * * Read the Following-Error of all axes in Process "ProcNumber" * * Compatibility: Osai | Demo * * * Returns an error when an internal or a library error occours * Process to execute the action * Reference of Dictionary "Key,Value" with: Key: Axis Name, Value: Position * */ public abstract CmsError AXES_RFollowingError(ushort ProcNumber, ref Dictionary Axes); /** * * Read the Distance-to-go of all axes in Process "ProcNumber" * * Compatibility: Fanuc | Osai | Demo * * * Returns an error when an internal or a library error occours * Process to execute the action * Reference of Dictionary "Key,Value" with: Key: Axis Name, Value: Position * */ public abstract CmsError AXES_RDistanceToGo(ushort ProcNumber, ref Dictionary Axes); public abstract CmsError AXES_RAxesNames(ushort process, ref List axesData); public abstract CmsError AXES_RSelectedAxis(ref byte axisId); public abstract CmsError AXES_WSelectAxis(byte axisId); #endregion AXES data (to override) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #region MEMORY Low-level function: single valiable in memory (to override) /** * Read/Write Boolean variable from/into NC Memory Area * * Compatibility: Fanuc | Osai | Demo * * * Returns an error when an internal or a library error occours * Set True to Write-operation (Also Allowed /) * Process to perform operation (If the area is process-indipendent use 0 or ) * Nc Memory Area. See * Starting Index of Memory Area * Set the Bit to Read-Write. (0..7) * Reference to variable to read/Write * */ public abstract CmsError MEM_RWBoolean(Boolean bWrite, int Process, MEMORY_TYPE MemType, int MemIndex, int MemBit, ref Boolean Value); /** * Read/Write Boolean variable from/into NC Memory Area (including Siemens Nc) * * Compatibility: Fanuc | Osai | Demo | Siemens * * * Returns an error when an internal or a library error occours * Set True to Write-operation (Also Allowed /) * Process to perform operation (If the area is process-indipendent use 0 or ) * Nc Memory Area. See * Siemens Memory Table (Used only in Siemens-Nc) * Starting Index of Memory Area * Set the Bit to Read-Write. (0..7) * Reference to variable to read/Write * */ public abstract CmsError MEM_RWBoolean(Boolean bWrite, int Process, MEMORY_TYPE MemType, int MemTable, int MemIndex, int MemBit, ref Boolean Value); /** * Read/Write Byte variable from/into NC Memory Area * * Compatibility: Fanuc | Osai | Demo * * * Returns an error when an internal or a library error occours * Set True to Write-operation (Also Allowed /) * Process to perform operation (If the area is process-indipendent use 0 or ) * Nc Memory Area. See * Starting Index of Memory Area * Set to 1 if the Byte is the second of a WORD (only for OSAI Nc) * Reference to variable to read/Write * */ public abstract CmsError MEM_RWByte(Boolean bWrite, int Process, MEMORY_TYPE MemType, int MemIndex, int MemByte, ref Byte Value); /** * Read/Write Byte variable from/into NC Memory Area (including Siemens Nc) * * Compatibility: Fanuc | Osai | Demo | Siemens * * * Returns an error when an internal or a library error occours * Set True to Write-operation (Also Allowed /) * Process to perform operation (If the area is process-indipendent use 0 or ) * Nc Memory Area. See * Siemens Memory Table (Used only in Siemens-Nc) * Starting Index of Memory Area * Set to 1 if the Byte is the second of a WORD (only for OSAI Nc) * Reference to variable to read/Write * */ public abstract CmsError MEM_RWByte(Boolean bWrite, int Process, MEMORY_TYPE MemType, int MemTable, int MemIndex, int MemByte, ref Byte Value); /** * Read/Write unsigned 2 Byte (NC: Word:, .NET: ushort) variable from/into NC Memory Area * * Compatibility: Fanuc | Osai | Demo * * * Returns an error when an internal or a library error occours * Set True to Write-operation (Also Allowed /) * Process to perform operation (If the area is process-indipendent use 0 or ) * Nc Memory Area. See * Starting Index of Memory Area * Number of sequential data Read/Write. (Used only in Reading Operation) * List of values to read/Write * */ public abstract CmsError MEM_RWWord(Boolean bWrite, int Process, MEMORY_TYPE MemType, int MemIndex, ref ushort Value); /** * Read/Write unsigned 2 Byte (NC: Word:, .NET: ushort) variable from/into NC Memory Area (including Siemens Nc) * * Compatibility: Fanuc | Osai | Demo | Siemens * * * Returns an error when an internal or a library error occours * Set True to Write-operation (Also Allowed /) * Process to perform operation (If the area is process-indipendent use 0 or ) * Nc Memory Area. See * Siemens Memory Table (Used only in Siemens-Nc) * Starting Index of Memory Area * Number of sequential data Read/Write. (Used only in Reading Operation) * List of values to read/Write * */ public abstract CmsError MEM_RWWord(Boolean bWrite, int Process, MEMORY_TYPE MemType, int MemTable, int MemIndex, ref ushort Value); /** * Read/Write signed 2 Byte (NC: Word:, .NET: short) variable from/into NC Memory Area * * Compatibility: Fanuc | Osai | Demo * * * Returns an error when an internal or a library error occours * Set True to Write-operation (Also Allowed /) * Process to perform operation (If the area is process-indipendent use 0 or ) * Nc Memory Area. See * Starting Index of Memory Area * Number of sequential data Read/Write. (Used only in Reading Operation) * List of values to read/Write * */ public abstract CmsError MEM_RWShort(Boolean bWrite, int Process, MEMORY_TYPE MemType, int MemIndex, ref short Value); /** * Read/Write signed 2 Byte (NC: Word:, .NET: short) variable from/into NC Memory Area (including Siemens Nc) * * Compatibility: Fanuc | Osai | Demo | Siemens * * * Returns an error when an internal or a library error occours * Set True to Write-operation (Also Allowed /) * Process to perform operation (If the area is process-indipendent use 0 or ) * Nc Memory Area. See * Siemens Memory Table (Used only in Siemens-Nc) * Starting Index of Memory Area * Number of sequential data Read/Write. (Used only in Reading Operation) * List of values to read/Write * */ public abstract CmsError MEM_RWShort(Boolean bWrite, int Process, MEMORY_TYPE MemType, int MemTable, int MemIndex, ref short Value); /** * Read/Write signed 4 Byte (NC: DWord:, .NET: uint) variable from/into NC Memory Area * * Compatibility: Fanuc | Osai | Demo * uW * * Returns an error when an internal or a library error occours * Set True to Write-operation (Also Allowed /) * Process to perform operation (If the area is process-indipendent use 0 or ) * Nc Memory Area. See * Starting Index of Memory Area * Number of sequential data Read/Write. (Used only in Reading Operation) * List of values to read/Write * */ public abstract CmsError MEM_RWDWord(Boolean bWrite, int Process, MEMORY_TYPE MemType, int MemIndex, ref uint Value); /** * Read/Write signed 4 Byte (NC: DWord:, .NET: uint) variable from/into NC Memory Area (including Siemens Nc) * * Compatibility: Fanuc | Osai | Demo | Siemens * uW * * Returns an error when an internal or a library error occours * Set True to Write-operation (Also Allowed /) * Process to perform operation (If the area is process-indipendent use 0 or ) * Nc Memory Area. See * Siemens Memory Table (Used only in Siemens-Nc) * Starting Index of Memory Area * Number of sequential data Read/Write. (Used only in Reading Operation) * List of values to read/Write * */ public abstract CmsError MEM_RWDWord(Boolean bWrite, int Process, MEMORY_TYPE MemType, int MemTable, int MemIndex, ref uint Value); /** * Read/Write signed 4 Byte (NC: DWord:, .NET: int) variable from/into NC Memory Area * * Compatibility: Fanuc | Osai | Demo * * * Returns an error when an internal or a library error occours * Set True to Write-operation (Also Allowed /) * Process to perform operation (If the area is process-indipendent use 0 or ) * Nc Memory Area. See * Starting Index of Memory Area * Number of sequential data Read/Write. (Used only in Reading Operation) * List of values to read/Write * */ public abstract CmsError MEM_RWInteger(Boolean bWrite, int Process, MEMORY_TYPE MemType, int MemIndex, ref int Value); /** * Read/Write signed 4 Byte (NC: DWord:, .NET: int) variable from/into NC Memory Area (including Siemens Nc) * * Compatibility: Fanuc | Osai | Demo | Siemens * * * Returns an error when an internal or a library error occours * Set True to Write-operation (Also Allowed /) * Process to perform operation (If the area is process-indipendent use 0 or ) * Nc Memory Area. See * Siemens Memory Table (Used only in Siemens-Nc) * Starting Index of Memory Area * Number of sequential data Read/Write. (Used only in Reading Operation) * List of values to read/Write * */ public abstract CmsError MEM_RWInteger(Boolean bWrite, int Process, MEMORY_TYPE MemType, int MemTable, int MemIndex, ref int Value); #endregion MEMORY Low-level function: single valiable in memory (to override) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #region NC Low-level function: variables List in memory (to override) /** * Read/Write List of Byte from/into NC Memory Area * * Compatibility: Fanuc | Osai | Demo * * * Returns an error when an internal or a library error occours * Set True to Write-operation (Also Allowed /) * Process to perform operation (If the area is process-indipendent use 0 or ) * Nc Memory Area. See * Starting Index of Memory Area * Set to 1 if the starting Byte is the second of a WORD (only for OSAI Nc) * Number of sequential data Read/Write. (Used only in Reading Operation) * List of values to read/Write * */ public abstract CmsError MEM_RWByteList(Boolean bWrite, int Process, MEMORY_TYPE MemType, int MemIndex, int MemByteStart, int Number, ref List Value); /** * Read/Write List of Byte from/into NC Memory Area (including Siemens Nc) * * Compatibility: Fanuc | Osai | Demo | Siemens * * * Returns an error when an internal or a library error occours * Set True to Write-operation (Also Allowed /) * Process to perform operation (If the area is process-indipendent use 0 or ) * Nc Memory Area. See * Siemens Memory Table (Used only in Siemens-Nc) * Starting Index of Memory Area * Set to 1 if the starting Byte is the second of a WORD (only for OSAI Nc) * Number of sequential data Read/Write. (Used only in Reading Operation) * List of values to read/Write * */ public abstract CmsError MEM_RWByteList(Boolean bWrite, int Process, MEMORY_TYPE MemType, int MemTable, int MemIndex, int MemByteStart, int Number, ref List Value); /** * Read/Write List of unsigned 2 Byte (NC: Word:, .NET: ushort) from/into NC Memory Area * * Compatibility: Fanuc | Osai | Demo * * * Returns an error when an internal or a library error occours * Set True to Write-operation (Also Allowed /) * Process to perform operation (If the area is process-indipendent use 0 or ) * Nc Memory Area. See * Starting Index of Memory Area * Number of sequential data Read/Write. (Used only in Reading Operation) * List of values to read/Write * */ public abstract CmsError MEM_RWWordList(Boolean bWrite, int Process, MEMORY_TYPE MemType, int MemIndex, int Number, ref List Value); /** * Read/Write List of unsigned 2 Byte (NC: Word:, .NET: ushort) from/into NC Memory Area (including Siemens Nc) * * Compatibility: Fanuc | Osai | Demo | Siemens * * * Returns an error when an internal or a library error occours * Set True to Write-operation (Also Allowed /) * Process to perform operation (If the area is process-indipendent use 0 or ) * Nc Memory Area. See * Siemens Memory Table (Used only in Siemens-Nc) * Starting Index of Memory Area * Number of sequential data Read/Write. (Used only in Reading Operation) * List of values to read/Write * */ public abstract CmsError MEM_RWWordList(Boolean bWrite, int Process, MEMORY_TYPE MemType, int MemTable, int MemIndex, int Number, ref List Value); /** * Read/Write List of signed 2 Byte (NC: Word:, .NET: short) from/into NC Memory Area * * Compatibility: Fanuc | Osai | Demo * * * Returns an error when an internal or a library error occours * Set True to Write-operation (Also Allowed /) * Process to perform operation (If the area is process-indipendent use 0 or ) * Nc Memory Area. See * Starting Index of Memory Area * Number of sequential data Read/Write. (Used only in Reading Operation) * List of values to read/Write * */ public abstract CmsError MEM_RWShortList(Boolean bWrite, int Process, MEMORY_TYPE MemType, int MemIndex, int Number, ref List Value); /** * Read/Write List of signed 2 Byte (NC: Word:, .NET: short) from/into NC Memory Area (including Siemens Nc) * * Compatibility: Fanuc | Osai | Demo | Siemens * * * Returns an error when an internal or a library error occours * Set True to Write-operation (Also Allowed /) * Process to perform operation (If the area is process-indipendent use 0 or ) * Nc Memory Area. See * Siemens Memory Table (Used only in Siemens-Nc) * Starting Index of Memory Area * Number of sequential data Read/Write. (Used only in Reading Operation) * List of values to read/Write * */ public abstract CmsError MEM_RWShortList(Boolean bWrite, int Process, MEMORY_TYPE MemType, int MemTable, int MemIndex, int Number, ref List Value); /** * Read/Write List of unsigned 4 Byte (NC: DWord:, .NET: uint) from/into NC Memory Area * * Compatibility: Fanuc | Osai | Demo * * * Returns an error when an internal or a library error occours * Set True to Write-operation (Also Allowed /) * Process to perform operation (If the area is process-indipendent use 0 or ) * Nc Memory Area. See * Starting Index of Memory Area * Number of sequential data Read/Write. (Used only in Reading Operation) * List of values to read/Write * */ public abstract CmsError MEM_RWDWordList(Boolean bWrite, int Process, MEMORY_TYPE MemType, int MemIndex, int Number, ref List Value); /** * Read/Write List of unsigned 4 Byte (NC: DWord:, .NET: uint) from/into NC Memory Area (including Siemens Nc) * * Compatibility: Fanuc | Osai | Demo | Siemens * * * Returns an error when an internal or a library error occours * Set True to Write-operation (Also Allowed /) * Process to perform operation (If the area is process-indipendent use 0 or ) * Nc Memory Area. See * Siemens Memory Table (Used only in Siemens-Nc) * Starting Index of Memory Area * Number of sequential data Read/Write. (Used only in Reading Operation) * List of values to read/Write * */ public abstract CmsError MEM_RWDWordList(Boolean bWrite, int Process, MEMORY_TYPE MemType, int MemTable, int MemIndex, int Number, ref List Value); /** * Read/Write List of signed 4 Byte (NC: DWord:, .NET: int) from/into NC Memory Area * * Compatibility: Fanuc | Osai | Demo * * * Returns an error when an internal or a library error occours * Set True to Write-operation (Also Allowed /) * Process to perform operation (If the area is process-indipendent use 0 or Nc.) * Nc Memory Area. See * Starting Index of Memory Area * Number of sequential data Read/Write. (Used only in Reading Operation) * List of values to read/Write * */ public abstract CmsError MEM_RWIntegerList(Boolean bWrite, int Process, MEMORY_TYPE MemType, int MemIndex, int Number, ref List Value); /** * Read/Write List of signed 4 Byte (NC: DWord:, .NET: int) from/into NC Memory Area (including Siemens Nc) * * Compatibility: Fanuc | Osai | Demo | Siemens * * * Returns an error when an internal or a library error occours * Set True to Write-operation (Also Allowed /) * Process to perform operation (If the area is process-indipendent use 0 or Nc.) * Nc Memory Area. See * Siemens Memory Table (Used only in Siemens-Nc) * Starting Index of Memory Area * Number of sequential data Read/Write. (Used only in Reading Operation) * List of values to read/Write * */ public abstract CmsError MEM_RWIntegerList(Boolean bWrite, int Process, MEMORY_TYPE MemType, int MemTable, int MemIndex, int Number, ref List Value); #endregion NC Low-level function: variables List in memory (to override) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #region File Management (To override) /** * Read a Part Program by path and name * * Compatibility: Fanuc | Osai | Demo | Siemens * * * Returns an error when an internal or a library error occours * Path of the Part Program stored in the Nc * Name of the Part Program and name of new local file * Reference to the new local file where the NC Part Program data will be saved * */ public abstract CmsError FILES_RProgramToFile(string partProgramPath, FileStream localFile); /** * Write/Overwrite a Part Program by path and name * * Compatibility: Fanuc | Osai | Demo | Siemens * * * Returns an error when an internal or a library error occours * Path of the Part Program stored in the Nc * Reference to the local Part Program file * */ public abstract CmsError FILES_WProgramFromFile(string partProgramPath, FileStream localFile); /** * Copy a Part Program into another path * * Compatibility: Fanuc | Osai | Demo | Siemens * * * Returns an error when an internal or a library error occours * Path where the Part Program is saved in the NC * Path of the copy Part Program destination * * */ public abstract CmsError FILES_CopyProgram(string partProgramPath, string newPartProgramPath, bool failIfExist); /** * Delete a Nc Part Program * * Compatibility: Fanuc | Osai | Demo | Siemens * * * Returns an error when an internal or a library error occours * Path where the Nc Part Program is saved in the NC * Name of the Part Program file * */ public abstract CmsError FILES_DeleteProgram(string partProgramPath, string partProgramName); #endregion File Management (To override) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #region Tool Table /** * Read tool table configuration * * Compatibility: Fanuc | Osai | Demo | Siemens * * * Returns an error when an internal or a library error occours * Reference to the tool table configuration data **/ public abstract CmsError TOOLS_RConfiguration(ref ToolTableConfiguration config); /** * Read tools data from NC * * Compatibility: Siemens * * * Returns an error when an internal or a library error occours * Reference to the tools list data object **/ public abstract CmsError TOOLS_RToolsData(ref List toolsData); /** * Read shanks data from NC * * Compatibility: Siemens * * * Returns an error when an internal or a library error occours * Reference to the shank list data object **/ public abstract CmsError TOOLS_RShanksData(ref List shanksData); /** * Read families data * * Compatibility: Siemens * * * Returns an error when an internal or a library error occours * Reference to the tools families data object **/ public abstract CmsError TOOLS_RFamilyData(ref List families); /** * Read magazines positions data from NC * * Compatibility: Siemens * * * Returns an error when an internal or a library error occours * Reference to the tools list data object **/ public abstract CmsError TOOLS_RMagazinePositions(ref List positions); public abstract CmsError TOOLS_WAddTool(ref SiemensToolModel tool); public abstract CmsError TOOLS_WAddFamily(ref FamilyModel family); public abstract CmsError TOOLS_WAddShank(ref ShankModel shank); public abstract CmsError TOOLS_WUpdateFamilyData(string oldName, string newName); public abstract CmsError TOOLS_WUpdatePosition(PositionModel position); public abstract CmsError TOOLS_WUpdateTool(ref SiemensToolModel tool); public abstract CmsError TOOLS_WDeleteTool(int id); public abstract CmsError TOOLS_WDeleteShank(int id); public abstract CmsError TOOLS_WDeleteFamily(string name); public abstract CmsError TOOLS_WDeleteEdge(int toolId, int edgeId); public abstract CmsError TOOLS_WAddEdge(int toolId, ref EdgeModel edge); public abstract CmsError TOOLS_WUpdateEdge(int toolId, ref EdgeModel newEdge); public abstract CmsError TOOLS_WUpdateShank(ref ShankModel shank); public abstract CmsError TOOLS_RMagazineTools(int magazineId, ref List magazinePos); public abstract CmsError TOOLS_RAvailableTools(ref List multitools, ref List tools); public abstract CmsError TOOLS_WLoadToolInMagazine(int magazine, NewToolInMagazineModel newMagazineTool); public abstract CmsError TOOLS_WUnloadToolInMagazine(int magazineId, int positionId); public abstract CmsError TOOLS_WLoadToolIntoShank(int shankId, int positionId, int toolId); public abstract CmsError TOOLS_WUnloadToolFromShank(int shankId, int positionId); public abstract CmsError TOOLS_GetMagazinesStatus(ref MagazineActionModel magazineAction); #endregion Tool Table /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #region CONSTANTS (Struct and Enum are Static for definition) // Read Write type /** Write action */ public const Boolean W = true; /** Read action */ public const Boolean R = false; /** Not-Defined Process */ public const ushort UNDEF_PROC = 0; // R-W MEMORY Type /** Nc Memory Type (Table) */ public enum MEMORY_TYPE { /** Null Type */ Null = -1, /////////////////////////////////////////////////////////////////// //Fanuc Memory Type /** Fanuc G Area */ Fanuc_G = 0, /** Fanuc F Area */ Fanuc_F = 1, /** Fanuc Y Area */ Fanuc_Y = 2, /** Fanuc X Area */ Fanuc_X = 3, /** Fanuc A Area */ Fanuc_A = 4, /** Fanuc R Area */ Fanuc_R = 5, /** Fanuc T Area */ Fanuc_T = 6, /** Fanuc K Area */ Fanuc_K = 7, /** Fanuc C Area */ Fanuc_C = 8, /** Fanuc D Area */ Fanuc_D = 9, /** Fanuc M Area */ Fanuc_M = 10, /** Fanuc N Area */ Fanuc_N = 11, /** Fanuc E Area */ Fanuc_E = 12, /** Fanuc Z Area */ Fanuc_Z = 13, /** Fanuc CM Area */ Fanuc_CM = 100, /////////////////////////////////////////////////////////////////// //Osai Memory Type /** Osai I Area */ Osai_I = 0, /** Osai O Area */ Osai_O = 1, /** Osai MW Area */ Osai_MW = 20, /** Osai GW Area */ Osai_GW = 21, /** Osai SW Area */ Osai_SW = 22, /** Osai PW Area */ Osai_PW = 62, /** Osai UW Area */ Osai_UW = 63, /** Osai MD Area */ Osai_MD = 40, /** Osai GD Area */ Osai_GD = 41, /** Osai SD Area */ Osai_SD = 42, /** Osai PD Area */ Osai_PD = 43, /** Osai UD Area */ Osai_UD = 44, /** Osai L Area */ Osai_L = 145, /** Osai LS Area */ Osai_LS = 18, /** Osai AA Area */ Osai_AA = 28, /** Osai A Area */ Osai_A = 45, /** Osai SC Area */ Osai_SC = 50, /** Osai SYMO Area */ Osai_SYMO = 102, /////////////////////////////////////////////////////////////////// //Siemens Memory Type, /** Siemens DB */ Siemens_DB = 0, /////////////////////////////////////////////////////////////////// // Demo memory type /**Demo default memory **/ Demo = 0 }; // NC Memory Type Name internal const String FANUC_MEMTYPE = "Fanuc_"; internal const String SIEMENS_MEMTYPE = "Siemens_"; internal const String OSAI_MEMTYPE = "Osai_"; internal const String DEMO_MEMTYPE = "Demo_"; internal const String UNDEFINED_MEMTYPE = "Null"; // min-time to read static data (Cached values) internal const ushort NC_MIN_SEC_READ_STATIC_DATA = 10; //Fanuc Variable & Const internal const short FANUC_MAXNVAR = 5; internal const short FANUC_MAXMSGCNC = 10; internal const short FANUC_MAXMSGPMC = 5; internal const short FANUC_ABSOLUTEPOS = 0; internal const short FANUC_MACHINEPOS = 1; internal const short FANUC_RELATIVEPOS = 2; internal const short FANUC_DISTTOGO = 3; internal const short FANUC_ALLPOS = -1; internal enum FANUC_DType : short { BYTE = 0, WORD = 1, LONG = 2 }; internal const ushort OSAI_PROGRAMMEDPOS = 1; internal const ushort OSAI_INTERPOLPOS = 2; internal const ushort OSAI_TRANSDUCERPOS = 3; internal const ushort OSAI_FOLLERROR = 4; internal const ushort OSAI_DISTTOGO = 5; internal const ushort OSAI_MACHINEPOS = 6; #endregion CONSTANTS (Struct and Enum are Static for definition) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #region Nc Tool Manager public abstract CmsError TOOLS_ROffset(short offsetId, ref OffsetModel offset); public abstract CmsError TOOLS_WOffset(short offsetId, OffsetModel offset); public abstract CmsError TOOLS_WStartEdit(); public abstract CmsError TOOLS_WStopEdit(); public abstract CmsError TOOLS_WAddTool(); public abstract CmsError TOOLS_WUpdateTool(List list); #endregion Nc Tool Manager /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #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_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); #endregion Fixed memory area /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #region Helper Function internal void AddNcAlarmToList(uint id, string message, DateTime dateTime, List alarms) { alarms.Add(new AlarmModel() { Id = id, Message = message, IsWarning = false, Process = 0, DateTime = dateTime }); } internal void AddAlarmToList(uint id, string message, int process, List alarms) { alarms.Add(new AlarmModel() { Id = id, Message = message, IsWarning = false, Process = process }); } internal void AddPlcAlarmsToList(uint id, bool isWaring, bool restorationIsActive, List processes, List alarms) { alarms.Add(new PlcAlarmModel() { Id = id, IsWarning = isWaring, RestorationIsActive = restorationIsActive, Process = processes }); } #endregion Helper Function } }