// *********************************************************************** // Module : ModbusRTUHelper for C# // Author : Lei Youbing // Created : 12-27-2017 // // Last Modified By : Lei Youbing // Last Modified On : 2020-08-18 // *********************************************************************** // Copyright (c) Shanghai AMP & MOONS' Automation Co., Ltd.. All rights reserved. // *********************************************************************** using System; using System.Collections.Generic; using System.Runtime.InteropServices; namespace SHJX.Service.ServerClient.Modbus { public delegate void CSCallback(); public struct StructRegisterValue { public int Count; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2048)] public int[] Values; }; public struct StructCommand { public int Count; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4096)] public byte[] Values; }; public struct ErrorInfo { public int ErrorCode; public string Command; public string ErrorMessage; } public enum SCLCommandEncodingTable { AlarmReset = 0xBA, StartJogging = 0x96, StopJogging = 0xD8, EncoderFunction = 0xD6, EncoderPosition = 0x98, FeedtoDoubleSensor = 0x69, FollowEncoder = 0xCC, FeedtoLength = 0x66, FeedtoSensorwithMaskDistance = 0x6A, FeedandSetOutput = 0x68, FeedtoPosition = 0x67, FeedtoSensor = 0x6B, FeedtoSensorwithSafetyDistance = 0x6C, JogDisable = 0xA3, JogEnable = 0xA2, MotorDisable = 0x9E, MotorEnable = 0x9F, SeekHome = 0x6E, SetPosition = 0xA5, FilterInput = 0xC0, FilterSelectInputs = 0xD3, StepFilterFreq = 0x06, WriteAnalogDeadband = 0xD2, WriteAlarmResetInput = 0x46, WriteAlarmOutput = 0x47, WriteAnalogScaling = 0xD1, WriteDefineLimits = 0x42, SetOutput = 0x8B, WriteWaitforInput = 0x70, QueueLoadAndExecute = 0x78, WriteWaitTime = 0x6F, StopAndKill = 0xE1, StopAndKillWithNormalDecel = 0xE2, } public class ModbusRTU { //if (Environment.Is64BitOperatingSystem) //? "Resources/ModbusRTU_x86.dll" : private const string DLL_FILENAME = "Lib/ModbusRTU_x86.dll"; // for 64-bit windows, please comment this line and uncomment next line //private const string DLL_FILENAME = "ModbusRTU_x64.dll"; // for 32-bit windows,, please comment this line and uncomment previous line private byte m_COMPort = 1; public byte COMPort { get { return m_COMPort; } } #region public fields //standard specific public int MBERROR_ILLEGAL_FUNCTION = 0x01; public int MBERROR_ILLEGAL_DATA_ADDRESS = 0x02; public int MBERROR_ILLEGAL_DATA_VALUE = 0x03; public int MBERROR_SLAVE_DEVICE_FAILURE = 0x04; public int MBERROR_ACKNOWLEDGE = 0x05; public int MBERROR_SLAVE_DEVICE_BUSY = 0x06; public int MBERROR_NEGATIVE_ACKNOWLEDGE = 0x07; public int MBERROR_MEMORY_PARITY_ERROR = 0x08; public int MBERROR_GATEWAY_PATH_UNAVAILABLE = 0x0A; public int MBERROR_GATEWAY_TARGET_DEVICE_FAILED_TO_RESPOND = 0x0B; //manufacture specific public int MBERROR_CAN_NOT_READ = 0x11; public int MBERROR_CAN_NOT_WRITE = 0x12; public int MBERROR_DATA_RANG = 0x13; //other public int MBERROR_FAIL_TO_OPEN_PORT = 0x100; public int MBERROR_PORT_IS_CLOSED = 0x101; public int MBERROR_SEND_FAILED = 0x102; public int MBERROR_THREAD_ERROR = 0x103; public int MBERROR_NO_RESPONSE = 0x104; public int MBERROR_DATA_NOT_ENOUGH = 0x105; public int MBERROR_CRC_ERROR = 0x106; public int MBERROR_SCLREGISTER_NOTFOUND = 0x107; public int MBERROR_UNKNOWN_EXCEPTION = 0xFFFF; #endregion #region DllImport // Trigger when send data to drive [DllImport(DLL_FILENAME, EntryPoint = "OnDataSend", CharSet = CharSet.Auto)] private static extern void _OnDataSend(CSCallback func); // Trigger when received data from drive [DllImport(DLL_FILENAME, EntryPoint = "OnDataReceive", CharSet = CharSet.Auto)] private static extern void _OnDataReceive(CSCallback func); // Get the port is open or closed [DllImport(DLL_FILENAME, EntryPoint = "IsOpen", CharSet = CharSet.Auto)] private static extern bool _IsOpen(byte nCOMPort); // Open serial port communication [DllImport(DLL_FILENAME, EntryPoint = "Open", CharSet = CharSet.Auto)] private static extern bool _Open(byte nCOMPort, int nBaudRate, bool bBigEndian); // Close serial port communication [DllImport(DLL_FILENAME, EntryPoint = "Close", CharSet = CharSet.Auto)] private static extern bool _Close(byte nCOMPort); // Set endian type [DllImport(DLL_FILENAME, EntryPoint = "SetEndianType", CharSet = CharSet.Auto)] private static extern void _SetEndianType(byte nCOMPort, bool bBigEndian); // Return it is big endian type or not [DllImport(DLL_FILENAME, EntryPoint = "IsBigEndian", CharSet = CharSet.Auto)] private static extern bool _IsBigEndian(byte nCOMPort); // Get execute time out [DllImport(DLL_FILENAME, EntryPoint = "GetExecuteTimeOut", CharSet = CharSet.Auto)] private static extern uint _GetExecuteTimeOut(byte nCOMPort); // Set execute time out [DllImport(DLL_FILENAME, EntryPoint = "SetExecuteTimeOut", CharSet = CharSet.Auto)] private static extern void _SetExecuteTimeOut(byte nCOMPort, uint nExecuteTimeOut); // Set it will trigger send event or not when sending command [DllImport(DLL_FILENAME, EntryPoint = "SetTriggerSendEvent", CharSet = CharSet.Auto)] private static extern void _SetTriggerSendEvent(bool bTriggerSendEvent); // Set it will trigger received event or not when receive data [DllImport(DLL_FILENAME, EntryPoint = "SetTriggerReceiveEvent", CharSet = CharSet.Auto)] private static extern void _SetTriggerReceiveEvent(bool bTriggerReceiveEvent); // Clear send buffer [DllImport(DLL_FILENAME, EntryPoint = "ClearSendBuffer", CharSet = CharSet.Auto)] private static extern void _ClearSendBuffer(byte nCOMPort); // Clear received buffer [DllImport(DLL_FILENAME, EntryPoint = "ClearReceivedBuffer", CharSet = CharSet.Auto)] private static extern void _ClearReceivedBuffer(byte nCOMPort); // Clear send and received Buffer [DllImport(DLL_FILENAME, EntryPoint = "ClearBuffer", CharSet = CharSet.Auto)] private static extern void _ClearBuffer(byte nCOMPort); // Get last error information, includes code and description [DllImport(DLL_FILENAME, EntryPoint = "GetLastErrorInfo", CharSet = CharSet.Ansi)] private static extern void _GetLastErrorInfo(ref ErrorInfo errorInfo); // Get the last command that send [DllImport(DLL_FILENAME, EntryPoint = "GetLastCommandSent", CharSet = CharSet.Auto)] private static extern bool _GetLastCommandSent(byte nCOMPort, IntPtr ptrCommandStu); // Get the last command that received [DllImport(DLL_FILENAME, EntryPoint = "GetLastCommandReceived", CharSet = CharSet.Auto)] private static extern bool _GetLastCommandReceived(byte nCOMPort, IntPtr ptrCommandStu); // Read single holding register from the drive [DllImport(DLL_FILENAME, EntryPoint = "ReadSingleHoldingRegister", CharSet = CharSet.Auto)] private static extern bool _ReadSingleHoldingRegister(byte nCOMPort, byte nNodeID, int registerNo, ref int value); // Write single holding register value to the drive [DllImport(DLL_FILENAME, EntryPoint = "WriteSingleHoldingRegister", CharSet = CharSet.Auto)] private static extern bool _WriteSingleHoldingRegister(byte nCOMPort, byte nNodeID, int registerNo, int value); // Read multiple holding register from the drive [DllImport(DLL_FILENAME, EntryPoint = "ReadMultiHoldingRegisters", CharSet = CharSet.Auto)] private static extern bool _ReadMultiHoldingRegisters(byte nCOMPort, byte nNodeID, int registerNo, int count, IntPtr ptrHoldingRegisterStu); // Write multiple holding register values to the drive [DllImport(DLL_FILENAME, EntryPoint = "WriteMultiHoldingRegisters", CharSet = CharSet.Auto)] private static extern bool _WriteMultiHoldingRegisters(byte nCOMPort, byte nNodeID, int registerNo, int count, [MarshalAs(UnmanagedType.LPArray, SizeConst = 100)] int[] valueList); // Read 16-bit int data from the drive [DllImport(DLL_FILENAME, EntryPoint = "ReadDataInt16", CharSet = CharSet.Auto)] private static extern bool _ReadDataInt16(byte nCOMPort, byte nNodeID, int nRegisterNo, ref short nValue); // Write 16-bit int data to the drive [DllImport(DLL_FILENAME, EntryPoint = "WriteDataInt16", CharSet = CharSet.Auto)] private static extern bool _WriteDataInt16(byte nCOMPort, byte nNodeID, int nRegisterNo, short nValue); // Read 16-bit unsighed int data from the drive [DllImport(DLL_FILENAME, EntryPoint = "ReadDataUInt16", CharSet = CharSet.Auto)] private static extern bool _ReadDataUInt16(byte nCOMPort, byte nNodeID, int nRegisterNo, ref ushort nValue); // Write 16-bit unsigned int data to the drive [DllImport(DLL_FILENAME, EntryPoint = "WriteDataUInt16", CharSet = CharSet.Auto)] private static extern bool _WriteDataUInt16(byte nCOMPort, byte nNodeID, int nRegisterNo, ushort nValue); // Read 32-bit int data from the drive [DllImport(DLL_FILENAME, EntryPoint = "ReadDataInt32", CharSet = CharSet.Auto)] private static extern bool _ReadDataInt32(byte nCOMPort, byte nNodeID, int nRegisterNo, ref int nValue); // Write 32-bit int data to the drive [DllImport(DLL_FILENAME, EntryPoint = "WriteDataInt32", CharSet = CharSet.Auto)] private static extern bool _WriteDataInt32(byte nCOMPort, byte nNodeID, int nRegisterNo, int nValue); // Read 32-bit unsighed int data from the drive [DllImport(DLL_FILENAME, EntryPoint = "ReadDataUInt32", CharSet = CharSet.Auto)] private static extern bool _ReadDataUInt32(byte nCOMPort, byte nNodeID, int nRegisterNo, ref uint nValue); // Write 32-bit unsigned int data to the drive [DllImport(DLL_FILENAME, EntryPoint = "WriteDataUInt32", CharSet = CharSet.Auto)] private static extern bool _WriteDataUInt32(byte nCOMPort, byte nNodeID, int nRegisterNo, uint nValue); // Execute command with opcode [DllImport(DLL_FILENAME, EntryPoint = "ExecuteCommandWithOpcode", CharSet = CharSet.Auto)] private static extern bool _ExecuteCommandWithOpcode(byte nCOMPort, byte nNodeID, int nOpCode, int nParam1, int nParam2, int nParam3, int nParam4, int nParam5); [DllImport(DLL_FILENAME, EntryPoint = "ExecuteSCLCommand", CharSet = CharSet.Ansi)] private static extern bool _ExecuteSCLCommand(byte nCOMPort, byte nNodeID, int registerNo, byte[] arrCommand, ref IntPtr ptrResponse); // Set P2P profile arguments [DllImport(DLL_FILENAME, EntryPoint = "SetP2PProfile", CharSet = CharSet.Auto)] private static extern bool _SetP2PProfile(byte nCOMPort, byte nNodeID, IntPtr dVelocity, IntPtr dAccel, IntPtr dDecel); // Set Jog profile arguments [DllImport(DLL_FILENAME, EntryPoint = "SetJogProfile", CharSet = CharSet.Auto)] private static extern bool _SetJogProfile(byte nCOMPort, byte nNodeID, IntPtr dVelocity, IntPtr dAccel, IntPtr dDecel); // Set the drive enabled or disabled [DllImport(DLL_FILENAME, EntryPoint = "DriveEnable", CharSet = CharSet.Auto)] private static extern bool _DriveEnable(byte nCOMPort, byte nNodeID, bool bEnable); // Reset drive's dlarm [DllImport(DLL_FILENAME, EntryPoint = "AlarmReset", CharSet = CharSet.Auto)] private static extern bool _AlarmReset(byte nCOMPort, byte nNodeID); // Launch feed to position move [DllImport(DLL_FILENAME, EntryPoint = "FeedtoPosition", CharSet = CharSet.Auto)] private static extern bool _FeedtoPosition(byte nCOMPort, byte nNodeID, IntPtr nDistance); // Launch feed to length move [DllImport(DLL_FILENAME, EntryPoint = "FeedtoLength", CharSet = CharSet.Auto)] private static extern bool _FeedtoLength(byte nCOMPort, byte nNodeID, IntPtr nDistance); [DllImport(DLL_FILENAME, EntryPoint = "AbsMove")] public static extern bool _AbsMove(byte nCOMPort, byte nNodeID, int nDistance, IntPtr dVelocity, IntPtr dAccel, IntPtr dDecel); [DllImport(DLL_FILENAME, EntryPoint = "RelMove")] public static extern bool _RelMove(byte nCOMPort, byte nNodeID, int nDistance, IntPtr dVelocity, IntPtr dAccel, IntPtr dDecel); // Launch feed to sensor move [DllImport(DLL_FILENAME, EntryPoint = "FeedtoSensor", CharSet = CharSet.Auto)] private static extern bool _FeedtoSensor(byte nCOMPort, byte nNodeID, byte nInputSensor, char chInputStatus); // Lanuch feed to sensor move with safety distance [DllImport(DLL_FILENAME, EntryPoint = "FeedtoSensorwithSafetyDistance", CharSet = CharSet.Auto)] private static extern bool _FeedtoSensorwithSafetyDistance(byte nCOMPort, byte nNodeID, byte nInputSensor, char chInputStatus); // Launch feed to double sensor move with mask distance [DllImport(DLL_FILENAME, EntryPoint = "FeedtoSensorwithMaskDistance", CharSet = CharSet.Auto)] private static extern bool _FeedtoSensorwithMaskDistance(byte nCOMPort, byte nNodeID, byte nInputSensor, char chInputStatus); // Launch Point to Point Move and set output [DllImport(DLL_FILENAME, EntryPoint = "FeedandSetOutput", CharSet = CharSet.Auto)] private static extern bool _FeedandSetOutput(byte nCOMPort, byte nNodeID, byte nOutput, char chOutputStatus); // Launch feed to double sensor move [DllImport(DLL_FILENAME, EntryPoint = "FeedtoDoubleSensor", CharSet = CharSet.Auto)] private static extern bool _FeedtoDoubleSensor(byte nCOMPort, byte nNodeID, byte nInput1, char chInputStatus1, byte nInput2, char chInputStatus2); // Launch follow encoder move [DllImport(DLL_FILENAME, EntryPoint = "FollowEncoder", CharSet = CharSet.Auto)] private static extern bool _FollowEncoder(byte nCOMPort, byte nNodeID, byte nInputSensor, char chInputStatus); // Commence Jogging [DllImport(DLL_FILENAME, EntryPoint = "StartJogging", CharSet = CharSet.Auto)] private static extern bool _StartJogging(byte nCOMPort, byte nNodeID); // Stop Jogging [DllImport(DLL_FILENAME, EntryPoint = "StopJogging", CharSet = CharSet.Auto)] private static extern bool _StopJogging(byte nCOMPort, byte nNodeID); // Set encoder function to the stepper drives with encoder feedback [DllImport(DLL_FILENAME, EntryPoint = "SetEncoderFunction", CharSet = CharSet.Auto)] private static extern bool _SetEncoderFunction(byte nCOMPort, byte nNodeID, byte nFunc); // Set encoder position [DllImport(DLL_FILENAME, EntryPoint = "SetEncoderPosition", CharSet = CharSet.Auto)] private static extern bool _SetEncoderPosition(byte nCOMPort, byte nNodeID, int nPosition); // Jog disable [DllImport(DLL_FILENAME, EntryPoint = "JogDisable", CharSet = CharSet.Auto)] private static extern bool _JogDisable(byte nCOMPort, byte nNodeID); // Jog enable [DllImport(DLL_FILENAME, EntryPoint = "JogEnable", CharSet = CharSet.Auto)] private static extern bool _JogEnable(byte nCOMPort, byte nNodeID); // Launch seek home move [DllImport(DLL_FILENAME, EntryPoint = "SeekHome", CharSet = CharSet.Auto)] private static extern bool _SeekHome(byte nCOMPort, byte nNodeID, byte nInputSensor, char chInputStatus); // Set position [DllImport(DLL_FILENAME, EntryPoint = "SetPosition", CharSet = CharSet.Auto)] private static extern bool _SetPosition(byte nCOMPort, byte nNodeID, int nPosition); // Set filter input [DllImport(DLL_FILENAME, EntryPoint = "SetFilterInput", CharSet = CharSet.Auto)] private static extern bool _SetFilterInput(byte nCOMPort, byte nNodeID, byte nInputSensor, int nFilterTime); // Write analog deadband [DllImport(DLL_FILENAME, EntryPoint = "WriteAnalogDeadband", CharSet = CharSet.Auto)] private static extern bool _WriteAnalogDeadband(byte nCOMPort, byte nNodeID, byte nDeadband); // Set output of the drive [DllImport(DLL_FILENAME, EntryPoint = "SetOutput", CharSet = CharSet.Auto)] private static extern bool _SetOutput(byte nCOMPort, byte nNodeID, byte nOutput, char nCondition); // Write wait for input [DllImport(DLL_FILENAME, EntryPoint = "WriteWaitforInput", CharSet = CharSet.Auto)] private static extern bool _WriteWaitforInput(byte nCOMPort, byte nNodeID, byte nInputSensor, char nCondition); // Queue Load and Execute [DllImport(DLL_FILENAME, EntryPoint = "QueueLoadAndExecute", CharSet = CharSet.Auto)] private static extern bool _QueueLoadAndExecute(byte nCOMPort, byte nNodeID, byte nSegment); // Write wait time [DllImport(DLL_FILENAME, EntryPoint = "WriteWaitTime", CharSet = CharSet.Auto)] private static extern bool _WriteWaitTime(byte nCOMPort, byte nNodeID, ushort nTime); // Stop and kill current move [DllImport(DLL_FILENAME, EntryPoint = "StopAndKill", CharSet = CharSet.Auto)] private static extern bool _StopAndKill(byte nCOMPort, byte nNodeID); // Stop and kill current move with normal deceleration [DllImport(DLL_FILENAME, EntryPoint = "StopAndKillwithNormalDecel", CharSet = CharSet.Auto)] private static extern bool _StopAndKillwithNormalDecel(byte nCOMPort, byte nNodeID); // Set P2P profile arguments [DllImport(DLL_FILENAME, EntryPoint = "SetP2PProfile_M3", CharSet = CharSet.Auto)] private static extern bool _SetP2PProfile_M3(byte nCOMPort, byte nNodeID, IntPtr dVelocity, IntPtr dAccel, IntPtr dDecel); // Set Jog profile arguments [DllImport(DLL_FILENAME, EntryPoint = "SetJogProfile_M3", CharSet = CharSet.Auto)] private static extern bool _SetJogProfile_M3(byte nCOMPort, byte nNodeID, IntPtr dVelocity, IntPtr dAccel, IntPtr dDecel); // Set the drive enabled or disabled [DllImport(DLL_FILENAME, EntryPoint = "DriveEnable_M3", CharSet = CharSet.Auto)] private static extern bool _DriveEnable_M3(byte nCOMPort, byte nNodeID, bool bEnable); // Reset drive's dlarm [DllImport(DLL_FILENAME, EntryPoint = "AlarmReset_M3", CharSet = CharSet.Auto)] private static extern bool _AlarmReset_M3(byte nCOMPort, byte nNodeID); // Launch feed to position move [DllImport(DLL_FILENAME, EntryPoint = "FeedtoPosition_M3", CharSet = CharSet.Auto)] private static extern bool _FeedtoPosition_M3(byte nCOMPort, byte nNodeID, IntPtr nDistance); // Launch feed to length move [DllImport(DLL_FILENAME, EntryPoint = "FeedtoLength_M3", CharSet = CharSet.Auto)] private static extern bool _FeedtoLength_M3(byte nCOMPort, byte nNodeID, IntPtr nDistance); [DllImport(DLL_FILENAME, EntryPoint = "AbsMove_M3")] public static extern bool _AbsMove_M3(byte nCOMPort, byte nNodeID, int nDistance, IntPtr dVelocity, IntPtr dAccel, IntPtr dDecel); [DllImport(DLL_FILENAME, EntryPoint = "RelMove_M3")] public static extern bool _RelMove_M3(byte nCOMPort, byte nNodeID, int nDistance, IntPtr dVelocity, IntPtr dAccel, IntPtr dDecel); // Set Home profile [DllImport(DLL_FILENAME, EntryPoint = "SetHomeProfile", CharSet = CharSet.Auto)] private static extern bool _SetHomeProfile(byte nCOMPort, byte nNodeID, IntPtr dVelocity1, IntPtr dVelocity2, IntPtr dAccel, IntPtr nHomingOffset); // Set Home method [DllImport(DLL_FILENAME, EntryPoint = "SetHomeMethod", CharSet = CharSet.Auto)] private static extern bool _SetHomeMethod(byte nCOMPort, byte nNodeID, sbyte nHomeMethod); // Launch feed home move [DllImport(DLL_FILENAME, EntryPoint = "FeedHome", CharSet = CharSet.Auto)] private static extern bool _FeedHome(byte nCOMPort, byte nNodeID, sbyte nHomeMethod, IntPtr dVelocity1, IntPtr dVelocity2, IntPtr dAccel, IntPtr nHomingOffset); // Read alarm code [DllImport(DLL_FILENAME, EntryPoint = "ReadAlarmCode", CharSet = CharSet.Auto)] private static extern bool _ReadAlarmCode(byte nCOMPort, byte nNodeID, ref uint nAlarmCode); // Read status code [DllImport(DLL_FILENAME, EntryPoint = "ReadStatusCode", CharSet = CharSet.Auto)] private static extern bool _ReadStatusCode(byte nCOMPort, byte nNodeID, ref uint nStatusCode); // Read immediate expanded inputs [DllImport(DLL_FILENAME, EntryPoint = "ReadImmediateExpandedInputs", CharSet = CharSet.Auto)] private static extern bool _ReadImmediateExpandedInputs(byte nCOMPort, byte nNodeID, ref ushort nInputsStatus); // Read driver board inputs [DllImport(DLL_FILENAME, EntryPoint = "ReadDriverBoardInputs", CharSet = CharSet.Auto)] private static extern bool _ReadDriverBoardInputs(byte nCOMPort, byte nNodeID, ref ushort nInputsStatus); // Read encoder position [DllImport(DLL_FILENAME, EntryPoint = "ReadEncoderPosition", CharSet = CharSet.Auto)] private static extern bool _ReadEncoderPosition(byte nCOMPort, byte nNodeID, ref int nEncoderPosition); // Read immediate absolute position [DllImport(DLL_FILENAME, EntryPoint = "ReadImmediateAbsolutePosition", CharSet = CharSet.Auto)] private static extern bool _ReadImmediateAbsolutePosition(byte nCOMPort, byte nNodeID, ref int nImmediateAbsolutePosition); // Read immediate actual velocity [DllImport(DLL_FILENAME, EntryPoint = "ReadImmediateActualVelocity", CharSet = CharSet.Auto)] private static extern bool _ReadImmediateActualVelocity(byte nCOMPort, byte nNodeID, ref double dImmediateActualVelocity); // Read immediate target velocity [DllImport(DLL_FILENAME, EntryPoint = "ReadImmediateTargetVelocity", CharSet = CharSet.Auto)] private static extern bool _ReadImmediateTargetVelocity(byte nCOMPort, byte nNodeID, ref double dImmediateTargetVelocity); // Read immediate drive temperature [DllImport(DLL_FILENAME, EntryPoint = "ReadImmediateDriveTemperature", CharSet = CharSet.Auto)] private static extern bool _ReadImmediateDriveTemperature(byte nCOMPort, byte nNodeID, ref double dImmediateDriveTemperature); // Read immediate bus voltage [DllImport(DLL_FILENAME, EntryPoint = "ReadImmediateBusVoltage", CharSet = CharSet.Auto)] private static extern bool _ReadImmediateBusVoltage(byte nCOMPort, byte nNodeID, ref double dImmediateBusVoltage); // Read immediate position error [DllImport(DLL_FILENAME, EntryPoint = "ReadImmediatePositionError", CharSet = CharSet.Auto)] private static extern bool _ReadImmediatePositionError(byte nCOMPort, byte nNodeID, ref int nImmediatePositionError); // Read immediate analog input value [DllImport(DLL_FILENAME, EntryPoint = "ReadImmediateAnalogInputValue", CharSet = CharSet.Auto)] private static extern bool _ReadImmediateAnalogInputValue(byte nCOMPort, byte nNodeID, ref short nImmediateAnalogInputValue); // Read immediate analog input1 Value [DllImport(DLL_FILENAME, EntryPoint = "ReadImmediateAnalogInput1Value", CharSet = CharSet.Auto)] private static extern bool _ReadImmediateAnalogInput1Value(byte nCOMPort, byte nNodeID, ref short nImmediateAnalogInputValue); // Read immediate analog input2 Value [DllImport(DLL_FILENAME, EntryPoint = "ReadImmediateAnalogInput2Value", CharSet = CharSet.Auto)] private static extern bool _ReadImmediateAnalogInput2Value(byte nCOMPort, byte nNodeID, ref short nImmediateAnalogInputValue); // Read Q program line number [DllImport(DLL_FILENAME, EntryPoint = "ReadQProgramLineNumber", CharSet = CharSet.Auto)] private static extern bool _ReadQProgramLineNumber(byte nCOMPort, byte nNodeID, ref ushort nQProgramLineNumber); // Read immediate current command [DllImport(DLL_FILENAME, EntryPoint = "ReadImmediateCurrentCommand", CharSet = CharSet.Auto)] private static extern bool _ReadImmediateCurrentCommand(byte nCOMPort, byte nNodeID, ref short nImmediateCurrentCommand); // Read relative distance [DllImport(DLL_FILENAME, EntryPoint = "ReadRelativeDistance", CharSet = CharSet.Auto)] private static extern bool _ReadRelativeDistance(byte nCOMPort, byte nNodeID, ref int nRelativeDistance); // Read sensor position [DllImport(DLL_FILENAME, EntryPoint = "ReadSensorPosition", CharSet = CharSet.Auto)] private static extern bool _ReadSensorPosition(byte nCOMPort, byte nNodeID, ref int nSensorPosition); // Read condition code [DllImport(DLL_FILENAME, EntryPoint = "ReadConditionCode", CharSet = CharSet.Auto)] private static extern bool _ReadConditionCode(byte nCOMPort, byte nNodeID, ref ushort nConditionCode); // Read command mode [DllImport(DLL_FILENAME, EntryPoint = "ReadCommandMode", CharSet = CharSet.Auto)] private static extern bool _ReadCommandMode(byte nCOMPort, byte nNodeID, ref ushort nCommandMode); // Read distance or position [DllImport(DLL_FILENAME, EntryPoint = "ReadDistanceOrPosition", CharSet = CharSet.Auto)] private static extern bool _ReadDistanceOrPosition(byte nCOMPort, byte nNodeID, ref int nDistanceOrPosition); // Write distance or position [DllImport(DLL_FILENAME, EntryPoint = "WriteDistanceOrPosition", CharSet = CharSet.Auto)] private static extern bool _WriteDistanceOrPosition(byte nCOMPort, byte nNodeID, int nDistanceOrPosition); // Read change distance [DllImport(DLL_FILENAME, EntryPoint = "ReadChangeDistance", CharSet = CharSet.Auto)] private static extern bool _ReadChangeDistance(byte nCOMPort, byte nNodeID, ref int nChangeDistance); // Write change distance [DllImport(DLL_FILENAME, EntryPoint = "WriteChangeDistance", CharSet = CharSet.Auto)] private static extern bool _WriteChangeDistance(byte nCOMPort, byte nNodeID, int nChangeDistance); // Read change velocity [DllImport(DLL_FILENAME, EntryPoint = "ReadChangeVelocity", CharSet = CharSet.Auto)] private static extern bool _ReadChangeVelocity(byte nCOMPort, byte nNodeID, ref double dChangeVelocity); // Write change velocity [DllImport(DLL_FILENAME, EntryPoint = "WriteChangeVelocity", CharSet = CharSet.Auto)] private static extern bool _WriteChangeVelocity(byte nCOMPort, byte nNodeID, double dChangeVelocity); // Read velocity move state [DllImport(DLL_FILENAME, EntryPoint = "ReadVelocityMoveState", CharSet = CharSet.Auto)] private static extern bool _ReadVelocityMoveState(byte nCOMPort, byte nNodeID, ref ushort nVelocityMoveState); // Read P2P move state [DllImport(DLL_FILENAME, EntryPoint = "ReadP2PMoveState", CharSet = CharSet.Auto)] private static extern bool _ReadP2PMoveState(byte nCOMPort, byte nNodeID, ref ushort nP2PMoveState); // Read Q program segment number [DllImport(DLL_FILENAME, EntryPoint = "ReadQProgramSegmentNumber", CharSet = CharSet.Auto)] private static extern bool _ReadQProgramSegmentNumber(byte nCOMPort, byte nNodeID, ref ushort nQProgramSegmentNumber); // Read position offset [DllImport(DLL_FILENAME, EntryPoint = "ReadPositionOffset", CharSet = CharSet.Auto)] private static extern bool _ReadPositionOffset(byte nCOMPort, byte nNodeID, ref int nPositionOffset); // Write position offset [DllImport(DLL_FILENAME, EntryPoint = "WritePositionOffset", CharSet = CharSet.Auto)] private static extern bool _WritePositionOffset(byte nCOMPort, byte nNodeID, int nPositionOffset); // Read running current [DllImport(DLL_FILENAME, EntryPoint = "ReadRunningCurrent", CharSet = CharSet.Auto)] private static extern bool _ReadRunningCurrent(byte nCOMPort, byte nNodeID, ref double dRunningCurrent); // Write running current [DllImport(DLL_FILENAME, EntryPoint = "WriteRunningCurrent", CharSet = CharSet.Auto)] private static extern bool _WriteRunningCurrent(byte nCOMPort, byte nNodeID, double dRunningCurrent); // Read electronic gearing [DllImport(DLL_FILENAME, EntryPoint = "ReadElectronicGearing", CharSet = CharSet.Auto)] private static extern bool _ReadElectronicGearing(byte nCOMPort, byte nNodeID, ref ushort nElectronicGearing); // Write electronic gearing [DllImport(DLL_FILENAME, EntryPoint = "WriteElectronicGearing", CharSet = CharSet.Auto)] private static extern bool _WriteElectronicGearing(byte nCOMPort, byte nNodeID, ushort nElectronicGearing); // Read pulse counter [DllImport(DLL_FILENAME, EntryPoint = "ReadPulseCounter", CharSet = CharSet.Auto)] private static extern bool _ReadPulseCounter(byte nCOMPort, byte nNodeID, ref int nPulseCounter); // Write pulse counter [DllImport(DLL_FILENAME, EntryPoint = "WritePulseCounter", CharSet = CharSet.Auto)] private static extern bool _WritePulseCounter(byte nCOMPort, byte nNodeID, int nPulseCounter); // Read analog position gain [DllImport(DLL_FILENAME, EntryPoint = "ReadAnalogPositionGain", CharSet = CharSet.Auto)] private static extern bool _ReadAnalogPositionGain(byte nCOMPort, byte nNodeID, ref ushort nAnalogPositionGain); // Write analog position gain [DllImport(DLL_FILENAME, EntryPoint = "WriteAnalogPositionGain", CharSet = CharSet.Auto)] private static extern bool _WriteAnalogPositionGain(byte nCOMPort, byte nNodeID, ushort nAnalogPositionGain); // Read analog threshold [DllImport(DLL_FILENAME, EntryPoint = "ReadAnalogThreshold", CharSet = CharSet.Auto)] private static extern bool _ReadAnalogThreshold(byte nCOMPort, byte nNodeID, ref ushort nAnalogThreshold); // Write analog threshold [DllImport(DLL_FILENAME, EntryPoint = "WriteAnalogThreshold", CharSet = CharSet.Auto)] private static extern bool _WriteAnalogThreshold(byte nCOMPort, byte nNodeID, ushort nAnalogThreshold); // Read analogoffset [DllImport(DLL_FILENAME, EntryPoint = "ReadAnalogOffset", CharSet = CharSet.Auto)] private static extern bool _ReadAnalogOffset(byte nCOMPort, byte nNodeID, ref ushort nAnalogOffset); // Write analog offset [DllImport(DLL_FILENAME, EntryPoint = "WriteAnalogOffset", CharSet = CharSet.Auto)] private static extern bool _WriteAnalogOffset(byte nCOMPort, byte nNodeID, ushort nAnalogOffset); // Read accumulator [DllImport(DLL_FILENAME, EntryPoint = "ReadAccumulator", CharSet = CharSet.Auto)] private static extern bool _ReadAccumulator(byte nCOMPort, byte nNodeID, ref int nAccumulator); // Read user defined register [DllImport(DLL_FILENAME, EntryPoint = "ReadUserDefinedRegister", CharSet = CharSet.Auto)] private static extern bool _ReadUserDefinedRegister(byte nCOMPort, byte nNodeID, char chRegister, ref int nValue); // Write user defined register [DllImport(DLL_FILENAME, EntryPoint = "WriteUserDefinedRegister", CharSet = CharSet.Auto)] private static extern bool _WriteUserDefinedRegister(byte nCOMPort, byte nNodeID, char chRegister, int nValue); // Read brake release delay [DllImport(DLL_FILENAME, EntryPoint = "ReadBrakeReleaseDelay", CharSet = CharSet.Auto)] private static extern bool _ReadBrakeReleaseDelay(byte nCOMPort, byte nNodeID, ref double dBrakeReleaseDelay); // Write brake release delay [DllImport(DLL_FILENAME, EntryPoint = "WriteBrakeReleaseDelay", CharSet = CharSet.Auto)] private static extern bool _WriteBrakeReleaseDelay(byte nCOMPort, byte nNodeID, double dBrakeReleaseDelay); // Read brake engage delay [DllImport(DLL_FILENAME, EntryPoint = "ReadBrakeEngageDelay", CharSet = CharSet.Auto)] private static extern bool _ReadBrakeEngageDelay(byte nCOMPort, byte nNodeID, ref double dBrakeEngageDelay); // Write brake engage delay [DllImport(DLL_FILENAME, EntryPoint = "WriteBrakeEngageDelay", CharSet = CharSet.Auto)] private static extern bool _WriteBrakeEngageDelay(byte nCOMPort, byte nNodeID, double dBrakeEngageDelay); // Read analog filter gain [DllImport(DLL_FILENAME, EntryPoint = "ReadAnalogFilterGain", CharSet = CharSet.Auto)] private static extern bool _ReadAnalogFilterGain(byte nCOMPort, byte nNodeID, ref ushort nAnalogFilterGain); // Write analog filter gain [DllImport(DLL_FILENAME, EntryPoint = "WriteAnalogFilterGain", CharSet = CharSet.Auto)] private static extern bool _WriteAnalogFilterGain(byte nCOMPort, byte nNodeID, ushort nAnalogFilterGain); // Read alarm code [DllImport(DLL_FILENAME, EntryPoint = "ReadAlarmCode_M3", CharSet = CharSet.Auto)] private static extern bool _ReadAlarmCode_M3(byte nCOMPort, byte nNodeID, ref uint nAlarmCode); // Read status code [DllImport(DLL_FILENAME, EntryPoint = "ReadStatusCode_M3", CharSet = CharSet.Auto)] private static extern bool _ReadStatusCode_M3(byte nCOMPort, byte nNodeID, ref uint nStatusCode); // Read driver board inputs [DllImport(DLL_FILENAME, EntryPoint = "ReadDriverBoardInputs_M3", CharSet = CharSet.Auto)] private static extern bool _ReadDriverBoardInputs_M3(byte nCOMPort, byte nNodeID, ref ushort nInputsStatus); // Read driver board Outputs [DllImport(DLL_FILENAME, EntryPoint = "ReadDriverBoardOutputs_M3", CharSet = CharSet.Auto)] private static extern bool _ReadDriverBoardOutputs_M3(byte nCOMPort, byte nNodeID, ref ushort nOutputsStatus); // Read encoder position [DllImport(DLL_FILENAME, EntryPoint = "ReadEncoderPosition_M3", CharSet = CharSet.Auto)] private static extern bool _ReadEncoderPosition_M3(byte nCOMPort, byte nNodeID, ref int nEncoderPosition); // Read encoder position [DllImport(DLL_FILENAME, EntryPoint = "Read2ndEncoderPosition_M3", CharSet = CharSet.Auto)] private static extern bool _Read2ndEncoderPosition_M3(byte nCOMPort, byte nNodeID, ref int nEncoderPosition); // Read immediate absolute position [DllImport(DLL_FILENAME, EntryPoint = "ReadImmediateAbsolutePosition_M3", CharSet = CharSet.Auto)] private static extern bool _ReadImmediateAbsolutePosition_M3(byte nCOMPort, byte nNodeID, ref int nImmediateAbsolutePosition); // Read immediate actual velocity [DllImport(DLL_FILENAME, EntryPoint = "ReadImmediateActualVelocity_M3", CharSet = CharSet.Auto)] private static extern bool _ReadImmediateActualVelocity_M3(byte nCOMPort, byte nNodeID, ref double dImmediateActualVelocity); // Read immediate target velocity [DllImport(DLL_FILENAME, EntryPoint = "ReadImmediateTargetVelocity_M3", CharSet = CharSet.Auto)] private static extern bool _ReadImmediateTargetVelocity_M3(byte nCOMPort, byte nNodeID, ref double dImmediateTargetVelocity); // Read immediate drive temperature [DllImport(DLL_FILENAME, EntryPoint = "ReadImmediateDriveTemperature_M3", CharSet = CharSet.Auto)] private static extern bool _ReadImmediateDriveTemperature_M3(byte nCOMPort, byte nNodeID, ref double dImmediateDriveTemperature); // Read immediate bus voltage [DllImport(DLL_FILENAME, EntryPoint = "ReadImmediateBusVoltage_M3", CharSet = CharSet.Auto)] private static extern bool _ReadImmediateBusVoltage_M3(byte nCOMPort, byte nNodeID, ref double dImmediateBusVoltage); // Read immediate position error [DllImport(DLL_FILENAME, EntryPoint = "ReadImmediatePositionError_M3", CharSet = CharSet.Auto)] private static extern bool _ReadImmediatePositionError_M3(byte nCOMPort, byte nNodeID, ref int nImmediatePositionError); // Read immediate analog input1 Value [DllImport(DLL_FILENAME, EntryPoint = "ReadImmediateAnalogInput1Value_M3", CharSet = CharSet.Auto)] private static extern bool _ReadImmediateAnalogInput1Value_M3(byte nCOMPort, byte nNodeID, ref short nImmediateAnalogInputValue); // Read immediate analog input2 Value [DllImport(DLL_FILENAME, EntryPoint = "ReadImmediateAnalogInput2Value_M3", CharSet = CharSet.Auto)] private static extern bool _ReadImmediateAnalogInput2Value_M3(byte nCOMPort, byte nNodeID, ref short nImmediateAnalogInputValue); // Read immediate analog Output1 Value [DllImport(DLL_FILENAME, EntryPoint = "ReadImmediateAnalogOutput1Value_M3", CharSet = CharSet.Auto)] private static extern bool _ReadImmediateAnalogOutput1Value_M3(byte nCOMPort, byte nNodeID, ref short nImmediateAnalogOutputValue); // Write immediate analog Output1 Value [DllImport(DLL_FILENAME, EntryPoint = "WriteImmediateAnalogOutput1Value_M3", CharSet = CharSet.Auto)] private static extern bool _WriteImmediateAnalogOutput1Value_M3(byte nCOMPort, byte nNodeID, short nImmediateAnalogOutputValue); // Read immediate analog Output2 Value [DllImport(DLL_FILENAME, EntryPoint = "ReadImmediateAnalogOutput2Value_M3", CharSet = CharSet.Auto)] private static extern bool _ReadImmediateAnalogOutput2Value_M3(byte nCOMPort, byte nNodeID, ref short nImmediateAnalogOutputValue); // Write immediate analog Output2 Value [DllImport(DLL_FILENAME, EntryPoint = "WriteImmediateAnalogOutput2Value_M3", CharSet = CharSet.Auto)] private static extern bool _WriteImmediateAnalogOutput2Value_M3(byte nCOMPort, byte nNodeID, short nImmediateAnalogOutputValue); // Read Q program line number [DllImport(DLL_FILENAME, EntryPoint = "ReadQProgramLineNumber_M3", CharSet = CharSet.Auto)] private static extern bool _ReadQProgramLineNumber_M3(byte nCOMPort, byte nNodeID, ref ushort nQProgramLineNumber); // Read immediate current command [DllImport(DLL_FILENAME, EntryPoint = "ReadImmediateCurrentCommand_M3", CharSet = CharSet.Auto)] private static extern bool _ReadImmediateCurrentCommand_M3(byte nCOMPort, byte nNodeID, ref short nImmediateCurrentCommand); // Read relative distance [DllImport(DLL_FILENAME, EntryPoint = "ReadRelativeDistance_M3", CharSet = CharSet.Auto)] private static extern bool _ReadRelativeDistance_M3(byte nCOMPort, byte nNodeID, ref int nRelativeDistance); // Read sensor position [DllImport(DLL_FILENAME, EntryPoint = "ReadSensorPosition_M3", CharSet = CharSet.Auto)] private static extern bool _ReadSensorPosition_M3(byte nCOMPort, byte nNodeID, ref int nSensorPosition); // Read condition code [DllImport(DLL_FILENAME, EntryPoint = "ReadConditionCode_M3", CharSet = CharSet.Auto)] private static extern bool _ReadConditionCode_M3(byte nCOMPort, byte nNodeID, ref ushort nConditionCode); // Read command mode [DllImport(DLL_FILENAME, EntryPoint = "ReadCommandMode_M3", CharSet = CharSet.Auto)] private static extern bool _ReadCommandMode_M3(byte nCOMPort, byte nNodeID, ref ushort nCommandMode); // Read distance or position [DllImport(DLL_FILENAME, EntryPoint = "ReadDistanceOrPosition_M3", CharSet = CharSet.Auto)] private static extern bool _ReadDistanceOrPosition_M3(byte nCOMPort, byte nNodeID, ref int nDistanceOrPosition); // Write distance or position [DllImport(DLL_FILENAME, EntryPoint = "WriteDistanceOrPosition_M3", CharSet = CharSet.Auto)] private static extern bool _WriteDistanceOrPosition_M3(byte nCOMPort, byte nNodeID, int nDistanceOrPosition); // Read change distance [DllImport(DLL_FILENAME, EntryPoint = "ReadChangeDistance_M3", CharSet = CharSet.Auto)] private static extern bool _ReadChangeDistance_M3(byte nCOMPort, byte nNodeID, ref int nChangeDistance); // Write change distance [DllImport(DLL_FILENAME, EntryPoint = "WriteChangeDistance_M3", CharSet = CharSet.Auto)] private static extern bool _WriteChangeDistance_M3(byte nCOMPort, byte nNodeID, int nChangeDistance); // Read change velocity [DllImport(DLL_FILENAME, EntryPoint = "ReadChangeVelocity_M3", CharSet = CharSet.Auto)] private static extern bool _ReadChangeVelocity_M3(byte nCOMPort, byte nNodeID, ref double dChangeVelocity); // Write change velocity [DllImport(DLL_FILENAME, EntryPoint = "WriteChangeVelocity_M3", CharSet = CharSet.Auto)] private static extern bool _WriteChangeVelocity_M3(byte nCOMPort, byte nNodeID, double dChangeVelocity); // Read velocity move state [DllImport(DLL_FILENAME, EntryPoint = "ReadVelocityMoveState_M3", CharSet = CharSet.Auto)] private static extern bool _ReadVelocityMoveState_M3(byte nCOMPort, byte nNodeID, ref ushort nVelocityMoveState); // Read P2P move state [DllImport(DLL_FILENAME, EntryPoint = "ReadP2PMoveState_M3", CharSet = CharSet.Auto)] private static extern bool _ReadP2PMoveState_M3(byte nCOMPort, byte nNodeID, ref ushort nP2PMoveState); // Read Q program segment number [DllImport(DLL_FILENAME, EntryPoint = "ReadQProgramSegmentNumber_M3", CharSet = CharSet.Auto)] private static extern bool _ReadQProgramSegmentNumber_M3(byte nCOMPort, byte nNodeID, ref ushort nQProgramSegmentNumber); // Read Command current [DllImport(DLL_FILENAME, EntryPoint = "ReadCommandCurrent_M3", CharSet = CharSet.Auto)] private static extern bool _ReadCommandCurrent_M3(byte nCOMPort, byte nNodeID, ref double dCommandCurrent); // Write Command current [DllImport(DLL_FILENAME, EntryPoint = "WriteCommandCurrent_M3", CharSet = CharSet.Auto)] private static extern bool _WriteCommandCurrent_M3(byte nCOMPort, byte nNodeID, double dCommandCurrent); // Read Max current [DllImport(DLL_FILENAME, EntryPoint = "ReadMaximumCurrent_M3", CharSet = CharSet.Auto)] private static extern bool _ReadMaximumCurrent_M3(byte nCOMPort, byte nNodeID, ref double dMaximumCurrent); // Write Max current [DllImport(DLL_FILENAME, EntryPoint = "WriteMaximumCurrent_M3", CharSet = CharSet.Auto)] private static extern bool _WriteMaximumCurrent_M3(byte nCOMPort, byte nNodeID, double dMaximumCurrent); // Read electronic gearing [DllImport(DLL_FILENAME, EntryPoint = "ReadElectronicGearing_M3", CharSet = CharSet.Auto)] private static extern bool _ReadElectronicGearing_M3(byte nCOMPort, byte nNodeID, ref uint nElectronicGearing); // Write electronic gearing [DllImport(DLL_FILENAME, EntryPoint = "WriteElectronicGearing_M3", CharSet = CharSet.Auto)] private static extern bool _WriteElectronicGearing_M3(byte nCOMPort, byte nNodeID, uint nElectronicGearing); // Read pulse counter [DllImport(DLL_FILENAME, EntryPoint = "ReadPulseCounter_M3", CharSet = CharSet.Auto)] private static extern bool _ReadPulseCounter_M3(byte nCOMPort, byte nNodeID, ref int nPulseCounter); // Write pulse counter [DllImport(DLL_FILENAME, EntryPoint = "WritePulseCounter_M3", CharSet = CharSet.Auto)] private static extern bool _WritePulseCounter_M3(byte nCOMPort, byte nNodeID, int nPulseCounter); // Read analog position gain [DllImport(DLL_FILENAME, EntryPoint = "ReadAnalogPositionGain_M3", CharSet = CharSet.Auto)] private static extern bool _ReadAnalogPositionGain_M3(byte nCOMPort, byte nNodeID, ref int nAnalogPositionGain); // Write analog position gain [DllImport(DLL_FILENAME, EntryPoint = "WriteAnalogPositionGain_M3", CharSet = CharSet.Auto)] private static extern bool _WriteAnalogPositionGain_M3(byte nCOMPort, byte nNodeID, int nAnalogPositionGain); // Read analog velocity gain [DllImport(DLL_FILENAME, EntryPoint = "ReadAnalogVelocityGain_M3", CharSet = CharSet.Auto)] private static extern bool _ReadAnalogVelocityGain_M3(byte nCOMPort, byte nNodeID, ref double nAnalogVelocityGain); // Write analog velocity gain [DllImport(DLL_FILENAME, EntryPoint = "WriteAnalogVelocityGain_M3", CharSet = CharSet.Auto)] private static extern bool _WriteAnalogVelocityGain_M3(byte nCOMPort, byte nNodeID, double nAnalogVelocityGain); // Read analog torque gain [DllImport(DLL_FILENAME, EntryPoint = "ReadAnalogTorqueGain_M3", CharSet = CharSet.Auto)] private static extern bool _ReadAnalogTorqueGain_M3(byte nCOMPort, byte nNodeID, ref double nAnalogTorqueGain); // Write analog torque gain [DllImport(DLL_FILENAME, EntryPoint = "WriteAnalogTorqueGain_M3", CharSet = CharSet.Auto)] private static extern bool _WriteAnalogTorqueGain_M3(byte nCOMPort, byte nNodeID, double nAnalogTorqueGain); // Read analog threshold [DllImport(DLL_FILENAME, EntryPoint = "ReadAnalogThreshold1_M3", CharSet = CharSet.Auto)] private static extern bool _ReadAnalogThreshold1_M3(byte nCOMPort, byte nNodeID, ref int nAnalogThreshold); // Write analog threshold [DllImport(DLL_FILENAME, EntryPoint = "WriteAnalogThreshold1_M3", CharSet = CharSet.Auto)] private static extern bool _WriteAnalogThreshold1_M3(byte nCOMPort, byte nNodeID, int nAnalogThreshold); // Read analog threshold [DllImport(DLL_FILENAME, EntryPoint = "ReadAnalogThreshold2_M3", CharSet = CharSet.Auto)] private static extern bool _ReadAnalogThreshold2_M3(byte nCOMPort, byte nNodeID, ref int nAnalogThreshold); // Write analog threshold [DllImport(DLL_FILENAME, EntryPoint = "WriteAnalogThreshold2_M3", CharSet = CharSet.Auto)] private static extern bool _WriteAnalogThreshold2_M3(byte nCOMPort, byte nNodeID, int nAnalogThreshold); // Read analogoffset [DllImport(DLL_FILENAME, EntryPoint = "ReadAnalogOffset1_M3", CharSet = CharSet.Auto)] private static extern bool _ReadAnalogOffset1_M3(byte nCOMPort, byte nNodeID, ref int nAnalogOffset); // Write analog offset [DllImport(DLL_FILENAME, EntryPoint = "WriteAnalogOffset1_M3", CharSet = CharSet.Auto)] private static extern bool _WriteAnalogOffset1_M3(byte nCOMPort, byte nNodeID, int nAnalogOffset); // Read analogoffset [DllImport(DLL_FILENAME, EntryPoint = "ReadAnalogOffset2_M3", CharSet = CharSet.Auto)] private static extern bool _ReadAnalogOffset2_M3(byte nCOMPort, byte nNodeID, ref int nAnalogOffset); // Write analog offset [DllImport(DLL_FILENAME, EntryPoint = "WriteAnalogOffset2_M3", CharSet = CharSet.Auto)] private static extern bool _WriteAnalogOffset2_M3(byte nCOMPort, byte nNodeID, int nAnalogOffset); // Read accumulator [DllImport(DLL_FILENAME, EntryPoint = "ReadAccumulator_M3", CharSet = CharSet.Auto)] private static extern bool _ReadAccumulator_M3(byte nCOMPort, byte nNodeID, ref int nAccumulator); // Read user defined register [DllImport(DLL_FILENAME, EntryPoint = "ReadUserDefinedRegister_M3", CharSet = CharSet.Auto)] private static extern bool _ReadUserDefinedRegister_M3(byte nCOMPort, byte nNodeID, char chRegister, ref int nValue); // Write user defined register [DllImport(DLL_FILENAME, EntryPoint = "WriteUserDefinedRegister_M3", CharSet = CharSet.Auto)] private static extern bool _WriteUserDefinedRegister_M3(byte nCOMPort, byte nNodeID, char chRegister, int nValue); // Read brake release delay [DllImport(DLL_FILENAME, EntryPoint = "ReadBrakeReleaseDelay_M3", CharSet = CharSet.Auto)] private static extern bool _ReadBrakeReleaseDelay_M3(byte nCOMPort, byte nNodeID, ref double dBrakeReleaseDelay); // Write brake release delay [DllImport(DLL_FILENAME, EntryPoint = "WriteBrakeReleaseDelay_M3", CharSet = CharSet.Auto)] private static extern bool _WriteBrakeReleaseDelay_M3(byte nCOMPort, byte nNodeID, double dBrakeReleaseDelay); // Read brake engage delay [DllImport(DLL_FILENAME, EntryPoint = "ReadBrakeEngageDelay_M3", CharSet = CharSet.Auto)] private static extern bool _ReadBrakeEngageDelay_M3(byte nCOMPort, byte nNodeID, ref double dBrakeEngageDelay); // Write brake engage delay [DllImport(DLL_FILENAME, EntryPoint = "WriteBrakeEngageDelay_M3", CharSet = CharSet.Auto)] private static extern bool _WriteBrakeEngageDelay_M3(byte nCOMPort, byte nNodeID, double dBrakeEngageDelay); // Read analog filter gain [DllImport(DLL_FILENAME, EntryPoint = "ReadAnalogFilterGain1_M3", CharSet = CharSet.Auto)] private static extern bool _ReadAnalogFilterGain1_M3(byte nCOMPort, byte nNodeID, ref ushort nAnalogFilterGain); // Write analog filter gain [DllImport(DLL_FILENAME, EntryPoint = "WriteAnalogFilterGain1_M3", CharSet = CharSet.Auto)] private static extern bool _WriteAnalogFilterGain1_M3(byte nCOMPort, byte nNodeID, ushort nAnalogFilterGain); // Read analog filter gain [DllImport(DLL_FILENAME, EntryPoint = "ReadAnalogFilterGain2_M3", CharSet = CharSet.Auto)] private static extern bool _ReadAnalogFilterGain2_M3(byte nCOMPort, byte nNodeID, ref ushort nAnalogFilterGain); // Write analog filter gain [DllImport(DLL_FILENAME, EntryPoint = "WriteAnalogFilterGain2_M3", CharSet = CharSet.Auto)] private static extern bool _WriteAnalogFilterGain2_M3(byte nCOMPort, byte nNodeID, ushort nAnalogFilterGain); // Write broadcast command [DllImport(DLL_FILENAME, EntryPoint = "WriteBroadcastCommand", CharSet = CharSet.Auto)] private static extern bool _WriteBroadcastCommand(byte nCOMPort, byte nNodeIDCount, [MarshalAs(UnmanagedType.LPArray, SizeConst = 32)] byte[] aNodeIDArr, byte nFunctionCode); // Execute multi-axes linear interpolation move [DllImport(DLL_FILENAME, EntryPoint = "ExecuteLinearInterpolationMove", CharSet = CharSet.Auto)] private static extern bool _ExecuteLinearInterpolationMove(byte nCOMPort, byte nNodeIDCount, [MarshalAs(UnmanagedType.LPArray, SizeConst = 4)] byte[] aNodeIDArr, [MarshalAs(UnmanagedType.LPArray, SizeConst = 4)] int[] aPosArr, uint nMaxLineSpeed, uint nAccelTimeInMs, bool bRelMove, bool bValidParamLimit); #endregion #region Public Methods private static CSCallback m_DataSendCallback; private static CSCallback m_DataReceivedCallback; public delegate void OnDataSendOrReceivedEventHandler(EventArgs e); public event OnDataSendOrReceivedEventHandler DataSend; public event OnDataSendOrReceivedEventHandler DataReceived; public void DataSendCallbackFunction() { if (DataSend != null) { EventArgs e = new EventArgs(); DataSend(e); } } public void DataReceivedCallbackFunction() { if (DataReceived != null) { EventArgs e = new EventArgs(); DataReceived(e); } } public ModbusRTU() { m_DataSendCallback = DataSendCallbackFunction; _OnDataSend(m_DataSendCallback); m_DataReceivedCallback = DataReceivedCallbackFunction; _OnDataReceive(m_DataReceivedCallback); } public bool IsOpen() { return _IsOpen(m_COMPort); } public bool Open(byte nCOMPort, int baudRate, bool bigEndian = true) { m_COMPort = nCOMPort; return _Open(m_COMPort, baudRate, bigEndian); } public bool Close() { return _Close(m_COMPort); } ~ModbusRTU() { Close(); } // Set when send data, trigger Send event or not public void SetEndianType(bool bBigEndian) { _SetEndianType(m_COMPort, bBigEndian); } // Set when received data, trigger Send event or not public bool IsBigEndian() { return _IsBigEndian(m_COMPort); } // Set when received data, trigger Send event or not public uint GetExecuteTimeOut() { return _GetExecuteTimeOut(m_COMPort); } // Set when send data, trigger Send event or not public void SetExecuteTimeOut(uint nExecuteTimeOut) { _SetExecuteTimeOut(m_COMPort, nExecuteTimeOut); } // Set it will trigger send event or not when sending command public void SetTriggerSendEvent(bool bTriggerSendEvent) { _SetTriggerSendEvent(bTriggerSendEvent); } // Set it will trigger received event or not when receive data public void SetTriggerReceiveEvent(bool bTriggerReceiveEvent) { _SetTriggerReceiveEvent(bTriggerReceiveEvent); } // Clear send buffer public void ClearSendBuffer(byte nCOMPort) { _ClearSendBuffer(nCOMPort); } // Clear received buffer public void ClearReceivedBuffer(byte nCOMPort) { _ClearReceivedBuffer(nCOMPort); } // Clear send and received Buffer public void ClearBuffer(byte nCOMPort) { _ClearBuffer(nCOMPort); } // Get last error information, includes code and description public void GetLastErrorInfo(ref ErrorInfo errorInfo) { _GetLastErrorInfo(ref errorInfo); } // Get the last command that send public void GetLastCommandSent(ref List commandList) { IntPtr ptrCommandStu = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(StructCommand))); bool ret = _GetLastCommandSent(m_COMPort, ptrCommandStu); StructCommand commandStu = (StructCommand)Marshal.PtrToStructure((IntPtr)((UInt32)ptrCommandStu), typeof(StructCommand)); for (int i = 0; i < commandStu.Count; i++) { commandList.Add(commandStu.Values[i]); } Marshal.FreeHGlobal(ptrCommandStu); } // Get the last command that received public void GetLastCommandReceived(ref List commandList) { IntPtr ptrCommandStu = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(StructCommand))); bool ret = _GetLastCommandReceived(m_COMPort, ptrCommandStu); StructCommand commandStu = (StructCommand)Marshal.PtrToStructure((IntPtr)((UInt32)ptrCommandStu), typeof(StructCommand)); for (int i = 0; i < commandStu.Count; i++) { commandList.Add(commandStu.Values[i]); } Marshal.FreeHGlobal(ptrCommandStu); } // Read single holding register from the drive public bool ReadSingleHoldingRegister(byte nNodeID, int registerNo, ref int value) { return _ReadSingleHoldingRegister(m_COMPort, nNodeID, registerNo, ref value); } // Write single holding register value to the drive public bool WriteSingleHoldingRegister(byte nNodeID, int registerNo, int value) { return _WriteSingleHoldingRegister(m_COMPort, nNodeID, registerNo, value); } // Read multiple holding register from the drive public bool ReadMultiHoldingRegisters(byte nNodeID, int registerNo, int count, ref List valueList) { IntPtr ptrHoldingRegisterStu = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(StructRegisterValue))); bool ret = _ReadMultiHoldingRegisters(m_COMPort, nNodeID, registerNo, count, ptrHoldingRegisterStu); StructRegisterValue holdingRegisterStu = (StructRegisterValue)Marshal.PtrToStructure((IntPtr)((UInt32)ptrHoldingRegisterStu), typeof(StructRegisterValue)); for (int i = 0; i < holdingRegisterStu.Count; i++) { valueList.Add(holdingRegisterStu.Values[i]); } Marshal.FreeHGlobal(ptrHoldingRegisterStu); return ret; } // Write multiple holding register values to the drive public bool WriteMultiHoldingRegisters(byte nNodeID, int registerNo, int count, List lstValue) { int[] valueList = lstValue.ToArray(); bool ret = _WriteMultiHoldingRegisters(m_COMPort, nNodeID, registerNo, count, valueList); return ret; } // Read 16-bit int data from the drive public bool ReadDataInt16(byte nNodeID, int nRegisterNo, ref short nValue) { return _ReadDataInt16(m_COMPort, nNodeID, nRegisterNo, ref nValue); } // Write 16-bit int data to the drive public bool WriteDataInt16(byte nNodeID, int nRegisterNo, short nValue) { return _WriteDataInt16(m_COMPort, nNodeID, nRegisterNo, nValue); } // Read 16-bit unsighed int data from the drive public bool ReadDataUInt16(byte nNodeID, int nRegisterNo, ref ushort nValue) { return _ReadDataUInt16(m_COMPort, nNodeID, nRegisterNo, ref nValue); } // Write 16-bit unsigned int data to the drive public bool WriteDataUInt16(byte nNodeID, int nRegisterNo, ushort nValue) { return _WriteDataUInt16(m_COMPort, nNodeID, nRegisterNo, nValue); } // Read 32-bit int data from the drive public bool ReadDataInt32(byte nNodeID, int nRegisterNo, ref int nValue) { return _ReadDataInt32(m_COMPort, nNodeID, nRegisterNo, ref nValue); } // Write 32-bit int data to the drive public bool WriteDataInt32(byte nNodeID, int nRegisterNo, int nValue) { return _WriteDataInt32(m_COMPort, nNodeID, nRegisterNo, nValue); } // Read 32-bit unsighed int data from the drive public bool ReadDataUInt32(byte nNodeID, int nRegisterNo, ref uint nValue) { return _ReadDataUInt32(m_COMPort, nNodeID, nRegisterNo, ref nValue); } // Write 32-bit unsigned int data to the drive public bool WriteDataUInt32(byte nNodeID, int nRegisterNo, uint nValue) { return _WriteDataUInt32(m_COMPort, nNodeID, nRegisterNo, nValue); } // Execute command with opcode public bool ExecuteCommandWithOpcode(byte nNodeID, SCLCommandEncodingTable commandCode, int p1 = 0, int p2 = 0, int p3 = 0, int p4 = 0, int p5 = 0) { return _ExecuteCommandWithOpcode(m_COMPort, nNodeID, (int)commandCode, p1, p2, p3, p4, p5); } // Write multiple holding register values to the drive public bool ExecuteSCLCommand(byte nNodeID, int registerNo, byte[] command, ref string strResponse) { IntPtr strIntPtr = IntPtr.Zero; bool ret = _ExecuteSCLCommand(m_COMPort, nNodeID, registerNo, command, ref strIntPtr); strResponse = Marshal.PtrToStringAnsi(strIntPtr); return ret; } public bool ExecuteSCLCommand(byte nNodeID, int registerNo, string command, ref string strResponse) { byte[] buf = System.Text.ASCIIEncoding.ASCII.GetBytes(command); return ExecuteSCLCommand(nNodeID, registerNo, buf, ref strResponse); } // Set P2P profile arguments public bool SetP2PProfile(byte nNodeID, double? dVelocity, double? dAccel, double? dDecel) { IntPtr ptrAccel = IntPtr.Zero; if (dAccel != null) { ptrAccel = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(dAccel.Value, ptrAccel, true); } IntPtr ptrDecel = IntPtr.Zero; if (dDecel != null) { ptrDecel = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(dDecel.Value, ptrDecel, true); } IntPtr ptrVelocity = IntPtr.Zero; if (dVelocity != null) { ptrVelocity = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(dVelocity.Value, ptrVelocity, true); } bool ret = _SetP2PProfile(m_COMPort, nNodeID, ptrVelocity, ptrAccel, ptrDecel); Marshal.FreeHGlobal(ptrAccel); Marshal.FreeHGlobal(ptrDecel); Marshal.FreeHGlobal(ptrVelocity); return ret; } // Set Jog profile arguments public bool SetJogProfile(byte nNodeID, double? dVelocity, double? dAccel, double? dDecel) { IntPtr ptrAccel = IntPtr.Zero; if (dAccel != null) { ptrAccel = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(dAccel.Value, ptrAccel, true); } IntPtr ptrDecel = IntPtr.Zero; if (dDecel != null) { ptrDecel = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(dDecel.Value, ptrDecel, true); } IntPtr ptrVelocity = IntPtr.Zero; if (dVelocity != null) { ptrVelocity = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(dVelocity.Value, ptrVelocity, true); } bool ret = _SetJogProfile(m_COMPort, nNodeID, ptrVelocity, ptrAccel, ptrDecel); Marshal.FreeHGlobal(ptrAccel); Marshal.FreeHGlobal(ptrDecel); Marshal.FreeHGlobal(ptrVelocity); return ret; } // Set the drive enabled or disabled public bool DriveEnable(byte nNodeID, bool bEnable) { return _DriveEnable(m_COMPort, nNodeID, bEnable); } // Reset drive's dlarm public bool AlarmReset(byte nNodeID) { return _AlarmReset(m_COMPort, nNodeID); } // Launch feed to position move public bool FeedtoPosition(byte nNodeID, int? nPosition = null) { IntPtr ptrPosition = IntPtr.Zero; if (nPosition.HasValue) { ptrPosition = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(nPosition.Value, ptrPosition, true); } bool ret = _FeedtoPosition(m_COMPort, nNodeID, ptrPosition); Marshal.FreeHGlobal(ptrPosition); return ret; } // Launch feed to length move public bool FeedtoLength(byte nNodeID, int? nDistance = null) { IntPtr ptrPosition = IntPtr.Zero; if (nDistance.HasValue) { ptrPosition = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(nDistance.Value, ptrPosition, true); } bool ret = _FeedtoLength(m_COMPort, nNodeID, ptrPosition); Marshal.FreeHGlobal(ptrPosition); return ret; } // Launch absolute move public bool AbsMove(byte nNodeID, int nDistance, double? dVelocity, double? dAccel, double? dDecel) { IntPtr ptrAccel = IntPtr.Zero; if (dAccel != null) { ptrAccel = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(dAccel.Value, ptrAccel, true); } IntPtr ptrDecel = IntPtr.Zero; if (dDecel != null) { ptrDecel = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(dDecel.Value, ptrDecel, true); } IntPtr ptrVelocity = IntPtr.Zero; if (dVelocity != null) { ptrVelocity = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(dVelocity.Value, ptrVelocity, true); } bool ret = _AbsMove(m_COMPort, nNodeID, nDistance, ptrVelocity, ptrAccel, ptrDecel); Marshal.FreeHGlobal(ptrAccel); Marshal.FreeHGlobal(ptrDecel); Marshal.FreeHGlobal(ptrVelocity); return ret; } // Launch relative move public bool RelMove(byte nNodeID, int nDistance, double? dVelocity, double? dAccel, double? dDecel) { IntPtr ptrAccel = IntPtr.Zero; if (dAccel != null) { ptrAccel = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(dAccel.Value, ptrAccel, true); } IntPtr ptrDecel = IntPtr.Zero; if (dDecel != null) { ptrDecel = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(dDecel.Value, ptrDecel, true); } IntPtr ptrVelocity = IntPtr.Zero; if (dVelocity != null) { ptrVelocity = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(dVelocity.Value, ptrVelocity, true); } bool ret = _RelMove(m_COMPort, nNodeID, nDistance, ptrVelocity, ptrAccel, ptrDecel); Marshal.FreeHGlobal(ptrAccel); Marshal.FreeHGlobal(ptrDecel); Marshal.FreeHGlobal(ptrVelocity); return ret; } // Launch feed to sensor move public bool FeedtoSensor(byte nNodeID, byte nInputSensor, char chInputStatus) { return _FeedtoSensor(m_COMPort, nNodeID, nInputSensor, chInputStatus); } // Lanuch feed to sensor move with safety distance public bool FeedtoSensorwithSafetyDistance(byte nNodeID, byte nInputSensor, char chInputStatus) { return _FeedtoSensorwithSafetyDistance(m_COMPort, nNodeID, nInputSensor, chInputStatus); } // Launch feed to double sensor move with mask distance public bool FeedtoSensorwithMaskDistance(byte nNodeID, byte nInputSensor, char chInputStatus) { return _FeedtoSensorwithMaskDistance(m_COMPort, nNodeID, nInputSensor, chInputStatus); } // Launch Point to Point Move and set output public bool FeedandSetOutput(byte nNodeID, byte nOutput, char chOutputStatus) { return _FeedandSetOutput(m_COMPort, nNodeID, nOutput, chOutputStatus); } // Launch feed to double sensor move public bool FeedtoDoubleSensor(byte nNodeID, byte nInput1, char chInputStatus1, byte nInput2, char chInputStatus2) { return _FeedtoDoubleSensor(m_COMPort, nNodeID, nInput1, chInputStatus1, nInput2, chInputStatus2); } // Launch follow encoder move public bool FollowEncoder(byte nNodeID, byte nInputSensor, char chInputStatus) { return _FollowEncoder(m_COMPort, nNodeID, nInputSensor, chInputStatus); } // Commence Jogging public bool StartJogging(byte nNodeID) { return _StartJogging(m_COMPort, nNodeID); } // Stop Jogging public bool StopJogging(byte nNodeID) { return _StopJogging(m_COMPort, nNodeID); } // Set encoder function to the stepper drives with encoder feedback public bool SetEncoderFunction(byte nNodeID, byte nFunc) { return _SetEncoderFunction(m_COMPort, nNodeID, nFunc); } // Set encoder position public bool SetEncoderPosition(byte nNodeID, int nPosition) { return _SetEncoderPosition(m_COMPort, nNodeID, nPosition); } // Jog disable public bool JogDisable(byte nNodeID) { return _JogDisable(m_COMPort, nNodeID); } // Jog enable public bool JogEnable(byte nNodeID) { return _JogEnable(m_COMPort, nNodeID); } // Launch seek home move public bool SeekHome(byte nNodeID, byte nInputSensor, char chInputStatus) { return _SeekHome(m_COMPort, nNodeID, nInputSensor, chInputStatus); } // Set position public bool SetPosition(byte nNodeID, int nPosition) { return _SetPosition(m_COMPort, nNodeID, nPosition); } // Set filter input public bool SetFilterInput(byte nNodeID, byte nInputSensor, int nFilterTime) { return _SetFilterInput(m_COMPort, nNodeID, nInputSensor, nFilterTime); } // Analog deadband public bool WriteAnalogDeadband(byte nNodeID, byte nDeadband) { return _WriteAnalogDeadband(m_COMPort, nNodeID, nDeadband); } // Set output of the drive public bool SetOutput(byte nNodeID, byte nOutput, char nCondition) { return _SetOutput(m_COMPort, nNodeID, nOutput, nCondition); } // Wait for input public bool WriteWaitforInput(byte nNodeID, byte nInputSensor, char nCondition) { return _WriteWaitforInput(m_COMPort, nNodeID, nInputSensor, nCondition); } // Queue Load and Execute public bool QueueLoadAndExecute(byte nNodeID, byte nSegment) { return _QueueLoadAndExecute(m_COMPort, nNodeID, nSegment); } // Wait time public bool WriteWaitTime(byte nNodeID, ushort nTime) { return _WriteWaitTime(m_COMPort, nNodeID, nTime); } // Stop and kill current move public bool StopAndKill(byte nNodeID) { return _StopAndKill(m_COMPort, nNodeID); } // Stop and kill current move with normal deceleration public bool StopAndKillwithNormalDecel(byte nNodeID) { return _StopAndKillwithNormalDecel(m_COMPort, nNodeID); } // Set P2P profile arguments public bool SetP2PProfile_M3(byte nNodeID, double? dVelocity, double? dAccel, double? dDecel) { IntPtr ptrAccel = IntPtr.Zero; if (dAccel != null) { ptrAccel = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(dAccel.Value, ptrAccel, true); } IntPtr ptrDecel = IntPtr.Zero; if (dDecel != null) { ptrDecel = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(dDecel.Value, ptrDecel, true); } IntPtr ptrVelocity = IntPtr.Zero; if (dVelocity != null) { ptrVelocity = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(dVelocity.Value, ptrVelocity, true); } bool ret = _SetP2PProfile_M3(m_COMPort, nNodeID, ptrVelocity, ptrAccel, ptrDecel); Marshal.FreeHGlobal(ptrAccel); Marshal.FreeHGlobal(ptrDecel); Marshal.FreeHGlobal(ptrVelocity); return ret; } // Set Jog profile arguments public bool SetJogProfile_M3(byte nNodeID, double? dVelocity, double? dAccel, double? dDecel) { IntPtr ptrAccel = IntPtr.Zero; if (dAccel != null) { ptrAccel = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(dAccel.Value, ptrAccel, true); } IntPtr ptrDecel = IntPtr.Zero; if (dDecel != null) { ptrDecel = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(dDecel.Value, ptrDecel, true); } IntPtr ptrVelocity = IntPtr.Zero; if (dVelocity != null) { ptrVelocity = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(dVelocity.Value, ptrVelocity, true); } bool ret = _SetJogProfile_M3(m_COMPort, nNodeID, ptrVelocity, ptrAccel, ptrDecel); Marshal.FreeHGlobal(ptrAccel); Marshal.FreeHGlobal(ptrDecel); Marshal.FreeHGlobal(ptrVelocity); return ret; } // Set the drive enabled or disabled public bool DriveEnable_M3(byte nNodeID, bool bEnable) { return _DriveEnable_M3(m_COMPort, nNodeID, bEnable); } // Launch feed to position move public bool FeedtoPosition_M3(byte nNodeID, int? nPosition = null) { IntPtr ptrPosition = IntPtr.Zero; if (nPosition.HasValue) { ptrPosition = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(nPosition.Value, ptrPosition, true); } bool ret = _FeedtoPosition_M3(m_COMPort, nNodeID, ptrPosition); Marshal.FreeHGlobal(ptrPosition); return ret; } // Launch feed to length move public bool FeedtoLength_M3(byte nNodeID, int? nDistance = null) { IntPtr ptrPosition = IntPtr.Zero; if (nDistance.HasValue) { ptrPosition = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(nDistance.Value, ptrPosition, true); } bool ret = _FeedtoLength_M3(m_COMPort, nNodeID, ptrPosition); Marshal.FreeHGlobal(ptrPosition); return ret; } // Reset drive's dlarm public bool AlarmReset_M3(byte nNodeID) { return _AlarmReset_M3(m_COMPort, nNodeID); } // Launch absolute move public bool AbsMove_M3(byte nNodeID, int nDistance, double? dVelocity, double? dAccel, double? dDecel) { IntPtr ptrAccel = IntPtr.Zero; if (dAccel != null) { ptrAccel = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(dAccel.Value, ptrAccel, true); } IntPtr ptrDecel = IntPtr.Zero; if (dDecel != null) { ptrDecel = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(dDecel.Value, ptrDecel, true); } IntPtr ptrVelocity = IntPtr.Zero; if (dVelocity != null) { ptrVelocity = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(dVelocity.Value, ptrVelocity, true); } bool ret = _AbsMove_M3(m_COMPort, nNodeID, nDistance, ptrVelocity, ptrAccel, ptrDecel); Marshal.FreeHGlobal(ptrAccel); Marshal.FreeHGlobal(ptrDecel); Marshal.FreeHGlobal(ptrVelocity); return ret; } // Launch relative move public bool RelMove_M3(byte nNodeID, int nDistance, double? dVelocity, double? dAccel, double? dDecel) { IntPtr ptrAccel = IntPtr.Zero; if (dAccel != null) { ptrAccel = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(dAccel.Value, ptrAccel, true); } IntPtr ptrDecel = IntPtr.Zero; if (dDecel != null) { ptrDecel = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(dDecel.Value, ptrDecel, true); } IntPtr ptrVelocity = IntPtr.Zero; if (dVelocity != null) { ptrVelocity = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(dVelocity.Value, ptrVelocity, true); } bool ret = _RelMove_M3(m_COMPort, nNodeID, nDistance, ptrVelocity, ptrAccel, ptrDecel); Marshal.FreeHGlobal(ptrAccel); Marshal.FreeHGlobal(ptrDecel); Marshal.FreeHGlobal(ptrVelocity); return ret; } // Set Home profile arguments public bool SetHomeProfile(byte nNodeID, double? dVelocity1, double? dVelocity2, double? dAccel, int? nHomingOffset = null) { IntPtr ptrVelocity1 = IntPtr.Zero; if (dVelocity1 != null) { ptrVelocity1 = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(dVelocity1.Value, ptrVelocity1, true); } IntPtr ptrVelocity2 = IntPtr.Zero; if (dVelocity2 != null) { ptrVelocity2 = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(dVelocity2.Value, ptrVelocity2, true); } IntPtr ptrAccel = IntPtr.Zero; if (dAccel != null) { ptrAccel = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(dAccel.Value, ptrAccel, true); } IntPtr ptrHomingOffset = IntPtr.Zero; if (nHomingOffset.HasValue) { ptrHomingOffset = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(nHomingOffset.Value, ptrHomingOffset, true); } bool ret = _SetHomeProfile(m_COMPort, nNodeID, ptrVelocity1, ptrVelocity2, ptrAccel, ptrHomingOffset); Marshal.FreeHGlobal(ptrVelocity1); Marshal.FreeHGlobal(ptrVelocity2); Marshal.FreeHGlobal(ptrAccel); Marshal.FreeHGlobal(ptrHomingOffset); return ret; } // Set feed home method public bool SetHomeMethod(byte nNodeID, sbyte nHomeMethod) { return _SetHomeMethod(m_COMPort, nNodeID, nHomeMethod); } // Launch feed home move public bool FeedHome(byte nNodeID, sbyte nHomeMethod, double? dVelocity1 = null, double? dVelocity2 = null, double? dAccel = null, int? nHomingOffset = null) { IntPtr ptrVelocity1 = IntPtr.Zero; if (dVelocity1 != null) { ptrVelocity1 = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(dVelocity1.Value, ptrVelocity1, true); } IntPtr ptrVelocity2 = IntPtr.Zero; if (dVelocity2 != null) { ptrVelocity2 = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(dVelocity2.Value, ptrVelocity2, true); } IntPtr ptrAccel = IntPtr.Zero; if (dAccel != null) { ptrAccel = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(dAccel.Value, ptrAccel, true); } IntPtr ptrHomingOffset = IntPtr.Zero; if (nHomingOffset.HasValue) { ptrHomingOffset = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(double))); Marshal.StructureToPtr(nHomingOffset.Value, ptrHomingOffset, true); } bool ret = _FeedHome(m_COMPort, nNodeID, nHomeMethod, ptrVelocity1, ptrVelocity2, ptrAccel, ptrHomingOffset); Marshal.FreeHGlobal(ptrVelocity1); Marshal.FreeHGlobal(ptrVelocity2); Marshal.FreeHGlobal(ptrAccel); Marshal.FreeHGlobal(ptrHomingOffset); return ret; } // Read alarm code public bool ReadAlarmCode(byte nNodeID, ref uint nAlarmCode) { return _ReadAlarmCode(m_COMPort, nNodeID, ref nAlarmCode); } // Read status code public bool ReadStatusCode(byte nNodeID, ref uint nStatusCode) { return _ReadStatusCode(m_COMPort, nNodeID, ref nStatusCode); } // Read immediate expanded inputs public bool ReadImmediateExpandedInputs(byte nNodeID, ref ushort nInputsStatus) { return _ReadImmediateExpandedInputs(m_COMPort, nNodeID, ref nInputsStatus); } // Read driver board inputs public bool ReadDriverBoardInputs(byte nNodeID, ref ushort nInputsStatus) { return _ReadDriverBoardInputs(m_COMPort, nNodeID, ref nInputsStatus); } // Read encoder position public bool ReadEncoderPosition(byte nNodeID, ref int nEncoderPosition) { return _ReadEncoderPosition(m_COMPort, nNodeID, ref nEncoderPosition); } // Read immediate absolute position public bool ReadImmediateAbsolutePosition(byte nNodeID, ref int nImmediateAbsolutePosition) { return _ReadImmediateAbsolutePosition(m_COMPort, nNodeID, ref nImmediateAbsolutePosition); } // Read immediate actual velocity public bool ReadImmediateActualVelocity(byte nNodeID, ref double dImmediateActualVelocity) { return _ReadImmediateActualVelocity(m_COMPort, nNodeID, ref dImmediateActualVelocity); } // Read immediate target velocity public bool ReadImmediateTargetVelocity(byte nNodeID, ref double dImmediateTargetVelocity) { return _ReadImmediateTargetVelocity(m_COMPort, nNodeID, ref dImmediateTargetVelocity); } // Read immediate drive temperature public bool ReadImmediateDriveTemperature(byte nNodeID, ref double dImmediateDriveTemperature) { return _ReadImmediateDriveTemperature(m_COMPort, nNodeID, ref dImmediateDriveTemperature); } // Read immediate bus voltage public bool ReadImmediateBusVoltage(byte nNodeID, ref double dImmediateBusVoltage) { return _ReadImmediateBusVoltage(m_COMPort, nNodeID, ref dImmediateBusVoltage); } // Read immediate position error public bool ReadImmediatePositionError(byte nNodeID, ref int nImmediatePositionError) { return _ReadImmediatePositionError(m_COMPort, nNodeID, ref nImmediatePositionError); } // Read immediate analog input value public bool ReadImmediateAnalogInputValue(byte nNodeID, ref short nImmediateAnalogInputValue) { return _ReadImmediateAnalogInputValue(m_COMPort, nNodeID, ref nImmediateAnalogInputValue); } // Read immediate analog input1 Value public bool ReadImmediateAnalogInput1Value(byte nNodeID, ref short nImmediateAnalogInputValue) { return _ReadImmediateAnalogInput1Value(m_COMPort, nNodeID, ref nImmediateAnalogInputValue); } // Read immediate analog input2 Value public bool ReadImmediateAnalogInput2Value(byte nNodeID, ref short nImmediateAnalogInputValue) { return _ReadImmediateAnalogInput2Value(m_COMPort, nNodeID, ref nImmediateAnalogInputValue); } // Read Q program line number public bool ReadQProgramLineNumber(byte nNodeID, ref ushort nQProgramLineNumber) { return _ReadQProgramLineNumber(m_COMPort, nNodeID, ref nQProgramLineNumber); } // Read immediate current command public bool ReadImmediateCurrentCommand(byte nNodeID, ref short nImmediateCurrentCommand) { return _ReadImmediateCurrentCommand(m_COMPort, nNodeID, ref nImmediateCurrentCommand); } // Read relative distance public bool ReadRelativeDistance(byte nNodeID, ref int nRelativeDistance) { return _ReadRelativeDistance(m_COMPort, nNodeID, ref nRelativeDistance); } // Read sensor position public bool ReadSensorPosition(byte nNodeID, ref int nSensorPosition) { return _ReadSensorPosition(m_COMPort, nNodeID, ref nSensorPosition); } // Read condition code public bool ReadConditionCode(byte nNodeID, ref ushort nConditionCode) { return _ReadConditionCode(m_COMPort, nNodeID, ref nConditionCode); } // Read command mode public bool ReadCommandMode(byte nNodeID, ref ushort nCommandMode) { return _ReadCommandMode(m_COMPort, nNodeID, ref nCommandMode); } // Read distance or position public bool ReadDistanceOrPosition(byte nNodeID, ref int nDistanceOrPosition) { return _ReadDistanceOrPosition(m_COMPort, nNodeID, ref nDistanceOrPosition); } // Write distance or position public bool WriteDistanceOrPosition(byte nNodeID, int nDistanceOrPosition) { return _WriteDistanceOrPosition(m_COMPort, nNodeID, nDistanceOrPosition); } // Read change distance public bool ReadChangeDistance(byte nNodeID, ref int nChangeDistance) { return _ReadChangeDistance(m_COMPort, nNodeID, ref nChangeDistance); } // Write change distance public bool WriteChangeDistance(byte nNodeID, int nChangeDistance) { return _WriteChangeDistance(m_COMPort, nNodeID, nChangeDistance); } // Read change velocity public bool ReadChangeVelocity(byte nNodeID, ref double dChangeVelocity) { return _ReadChangeVelocity(m_COMPort, nNodeID, ref dChangeVelocity); } // Write change velocity public bool WriteChangeVelocity(byte nNodeID, double dChangeVelocity) { return _WriteChangeVelocity(m_COMPort, nNodeID, dChangeVelocity); } // Read velocity move state public bool ReadVelocityMoveState(byte nNodeID, ref ushort nVelocityMoveState) { return _ReadVelocityMoveState(m_COMPort, nNodeID, ref nVelocityMoveState); } // Read P2P move state public bool ReadP2PMoveState(byte nNodeID, ref ushort nP2PMoveState) { return _ReadP2PMoveState(m_COMPort, nNodeID, ref nP2PMoveState); } // Read Q program segment number public bool ReadQProgramSegmentNumber(byte nNodeID, ref ushort nQProgramSegmentNumber) { return _ReadQProgramSegmentNumber(m_COMPort, nNodeID, ref nQProgramSegmentNumber); } // Read position offset public bool ReadPositionOffset(byte nNodeID, ref int nPositionOffset) { return _ReadPositionOffset(m_COMPort, nNodeID, ref nPositionOffset); } // Write position offset public bool WritePositionOffset(byte nNodeID, int nPositionOffset) { return _WritePositionOffset(m_COMPort, nNodeID, nPositionOffset); } // Read running current public bool ReadRunningCurrent(byte nNodeID, ref double dRunningCurrent) { return _ReadRunningCurrent(m_COMPort, nNodeID, ref dRunningCurrent); } // Write running current public bool WriteRunningCurrent(byte nNodeID, double dRunningCurrent) { return _WriteRunningCurrent(m_COMPort, nNodeID, dRunningCurrent); } // Read electronic gearing public bool ReadElectronicGearing(byte nNodeID, ref ushort nElectronicGearing) { return _ReadElectronicGearing(m_COMPort, nNodeID, ref nElectronicGearing); } // Write electronic gearing public bool WriteElectronicGearing(byte nNodeID, ushort nElectronicGearing) { return _WriteElectronicGearing(m_COMPort, nNodeID, nElectronicGearing); } // Read pulse counter public bool ReadPulseCounter(byte nNodeID, ref int nPulseCounter) { return _ReadPulseCounter(m_COMPort, nNodeID, ref nPulseCounter); } // Write pulse counter public bool WritePulseCounter(byte nNodeID, int nPulseCounter) { return _WritePulseCounter(m_COMPort, nNodeID, nPulseCounter); } // Read analog position gain public bool ReadAnalogPositionGain(byte nNodeID, ref ushort nAnalogPositionGain) { return _ReadAnalogPositionGain(m_COMPort, nNodeID, ref nAnalogPositionGain); } // Write analog position gain public bool WriteAnalogPositionGain(byte nNodeID, ushort nAnalogPositionGain) { return _WriteAnalogPositionGain(m_COMPort, nNodeID, nAnalogPositionGain); } // Read analog threshold public bool ReadAnalogThreshold(byte nNodeID, ref ushort nAnalogThreshold) { return _ReadAnalogThreshold(m_COMPort, nNodeID, ref nAnalogThreshold); } // Write analog threshold public bool WriteAnalogThreshold(byte nNodeID, ushort nAnalogThreshold) { return _WriteAnalogThreshold(m_COMPort, nNodeID, nAnalogThreshold); } // Read analogoffset public bool ReadAnalogOffset(byte nNodeID, ref ushort nAnalogOffset) { return _ReadAnalogOffset(m_COMPort, nNodeID, ref nAnalogOffset); } // Write analog offset public bool WriteAnalogOffset(byte nNodeID, ushort nAnalogOffset) { return _WriteAnalogOffset(m_COMPort, nNodeID, nAnalogOffset); } // Read accumulator public bool ReadAccumulator(byte nNodeID, ref int nAccumulator) { return _ReadAccumulator(m_COMPort, nNodeID, ref nAccumulator); } // Read user defined register public bool ReadUserDefinedRegister(byte nNodeID, char chRegister, ref int nValue) { return _ReadUserDefinedRegister(m_COMPort, nNodeID, chRegister, ref nValue); } // Write user defined register public bool WriteUserDefinedRegister(byte nNodeID, char chRegister, int nValue) { return _WriteUserDefinedRegister(m_COMPort, nNodeID, chRegister, nValue); } // Read brake release delay public bool ReadBrakeReleaseDelay(byte nNodeID, ref double dBrakeReleaseDelay) { return _ReadBrakeReleaseDelay(m_COMPort, nNodeID, ref dBrakeReleaseDelay); } // Write brake release delay public bool WriteBrakeReleaseDelay(byte nNodeID, double dBrakeReleaseDelay) { return _WriteBrakeReleaseDelay(m_COMPort, nNodeID, dBrakeReleaseDelay); } // Read brake engage delay public bool ReadBrakeEngageDelay(byte nNodeID, ref double dBrakeEngageDelay) { return _ReadBrakeEngageDelay(m_COMPort, nNodeID, ref dBrakeEngageDelay); } // Write brake engage delay public bool WriteBrakeEngageDelay(byte nNodeID, double dBrakeEngageDelay) { return _WriteBrakeEngageDelay(m_COMPort, nNodeID, dBrakeEngageDelay); } // Read analog filter gain public bool ReadAnalogFilterGain(byte nNodeID, ref ushort nAnalogFilterGain) { return _ReadAnalogFilterGain(m_COMPort, nNodeID, ref nAnalogFilterGain); } // Write analog filter gain public bool WriteAnalogFilterGain(byte nNodeID, ushort nAnalogFilterGain) { return _WriteAnalogFilterGain(m_COMPort, nNodeID, nAnalogFilterGain); } // Read alarm code public bool ReadAlarmCode_M3(byte nNodeID, ref uint nAlarmCode) { return _ReadAlarmCode_M3(m_COMPort, nNodeID, ref nAlarmCode); } // Read status code public bool ReadStatusCode_M3(byte nNodeID, ref uint nStatusCode) { return _ReadStatusCode_M3(m_COMPort, nNodeID, ref nStatusCode); } // Read driver board inputs public bool ReadDriverBoardInputs_M3(byte nNodeID, ref ushort nInputsStatus) { return _ReadDriverBoardInputs_M3(m_COMPort, nNodeID, ref nInputsStatus); } // Read driver board outputs public bool ReadDriverBoardOutputs_M3(byte nNodeID, ref ushort nOutputsStatus) { return _ReadDriverBoardOutputs_M3(m_COMPort, nNodeID, ref nOutputsStatus); } // Read encoder position public bool ReadEncoderPosition_M3(byte nNodeID, ref int nEncoderPosition) { return _ReadEncoderPosition_M3(m_COMPort, nNodeID, ref nEncoderPosition); } // Read 2nd encoder position public bool Read2ndEncoderPosition_M3(byte nNodeID, ref int nEncoderPosition) { return _Read2ndEncoderPosition_M3(m_COMPort, nNodeID, ref nEncoderPosition); } // Read immediate absolute position public bool ReadImmediateAbsolutePosition_M3(byte nNodeID, ref int nImmediateAbsolutePosition) { return _ReadImmediateAbsolutePosition_M3(m_COMPort, nNodeID, ref nImmediateAbsolutePosition); } // Read immediate actual velocity public bool ReadImmediateActualVelocity_M3(byte nNodeID, ref double dImmediateActualVelocity) { return _ReadImmediateActualVelocity_M3(m_COMPort, nNodeID, ref dImmediateActualVelocity); } // Read immediate target velocity public bool ReadImmediateTargetVelocity_M3(byte nNodeID, ref double dImmediateTargetVelocity) { return _ReadImmediateTargetVelocity_M3(m_COMPort, nNodeID, ref dImmediateTargetVelocity); } // Read immediate drive temperature public bool ReadImmediateDriveTemperature_M3(byte nNodeID, ref double dImmediateDriveTemperature) { return _ReadImmediateDriveTemperature_M3(m_COMPort, nNodeID, ref dImmediateDriveTemperature); } // Read immediate bus voltage public bool ReadImmediateBusVoltage_M3(byte nNodeID, ref double dImmediateBusVoltage) { return _ReadImmediateBusVoltage_M3(m_COMPort, nNodeID, ref dImmediateBusVoltage); } // Read immediate position error public bool ReadImmediatePositionError_M3(byte nNodeID, ref int nImmediatePositionError) { return _ReadImmediatePositionError_M3(m_COMPort, nNodeID, ref nImmediatePositionError); } // Read immediate analog input1 Value public bool ReadImmediateAnalogInput1Value_M3(byte nNodeID, ref short nImmediateAnalogInputValue) { return _ReadImmediateAnalogInput1Value_M3(m_COMPort, nNodeID, ref nImmediateAnalogInputValue); } // Read immediate analog input2 Value public bool ReadImmediateAnalogInput2Value_M3(byte nNodeID, ref short nImmediateAnalogInputValue) { return _ReadImmediateAnalogInput2Value_M3(m_COMPort, nNodeID, ref nImmediateAnalogInputValue); } // Read immediate analog Output1 Value public bool ReadImmediateAnalogOutput1Value_M3(byte nNodeID, ref short nImmediateAnalogOutputValue) { return _ReadImmediateAnalogOutput1Value_M3(m_COMPort, nNodeID, ref nImmediateAnalogOutputValue); } // Write immediate analog Output1 Value public bool WriteImmediateAnalogOutput1Value_M3(byte nNodeID, short nImmediateAnalogOutputValue) { return _WriteImmediateAnalogOutput1Value_M3(m_COMPort, nNodeID, nImmediateAnalogOutputValue); } // Read immediate analog Output2 Value public bool ReadImmediateAnalogOutput2Value_M3(byte nNodeID, ref short nImmediateAnalogOutputValue) { return _ReadImmediateAnalogOutput2Value_M3(m_COMPort, nNodeID, ref nImmediateAnalogOutputValue); } // Read immediate analog Output2 Value public bool WriteImmediateAnalogOutput2Value_M3(byte nNodeID, short nImmediateAnalogOutputValue) { return _WriteImmediateAnalogOutput2Value_M3(m_COMPort, nNodeID, nImmediateAnalogOutputValue); } // Read Q program line number public bool ReadQProgramLineNumber_M3(byte nNodeID, ref ushort nQProgramLineNumber) { return _ReadQProgramLineNumber_M3(m_COMPort, nNodeID, ref nQProgramLineNumber); } // Read immediate current command public bool ReadImmediateCurrentCommand_M3(byte nNodeID, ref short nImmediateCurrentCommand) { return _ReadImmediateCurrentCommand_M3(m_COMPort, nNodeID, ref nImmediateCurrentCommand); } // Read relative distance public bool ReadRelativeDistance_M3(byte nNodeID, ref int nRelativeDistance) { return _ReadRelativeDistance_M3(m_COMPort, nNodeID, ref nRelativeDistance); } // Read sensor position public bool ReadSensorPosition_M3(byte nNodeID, ref int nSensorPosition) { return _ReadSensorPosition_M3(m_COMPort, nNodeID, ref nSensorPosition); } // Read condition code public bool ReadConditionCode_M3(byte nNodeID, ref ushort nConditionCode) { return _ReadConditionCode_M3(m_COMPort, nNodeID, ref nConditionCode); } // Read command mode public bool ReadCommandMode_M3(byte nNodeID, ref ushort nCommandMode) { return _ReadCommandMode_M3(m_COMPort, nNodeID, ref nCommandMode); } // Read distance or position public bool ReadDistanceOrPosition_M3(byte nNodeID, ref int nDistanceOrPosition) { return _ReadDistanceOrPosition_M3(m_COMPort, nNodeID, ref nDistanceOrPosition); } // Write distance or position public bool WriteDistanceOrPosition_M3(byte nNodeID, int nDistanceOrPosition) { return _WriteDistanceOrPosition_M3(m_COMPort, nNodeID, nDistanceOrPosition); } // Read change distance public bool ReadChangeDistance_M3(byte nNodeID, ref int nChangeDistance) { return _ReadChangeDistance_M3(m_COMPort, nNodeID, ref nChangeDistance); } // Write change distance public bool WriteChangeDistance_M3(byte nNodeID, int nChangeDistance) { return _WriteChangeDistance_M3(m_COMPort, nNodeID, nChangeDistance); } // Read change velocity public bool ReadChangeVelocity_M3(byte nNodeID, ref double dChangeVelocity) { return _ReadChangeVelocity_M3(m_COMPort, nNodeID, ref dChangeVelocity); } // Write change velocity public bool WriteChangeVelocity_M3(byte nNodeID, double dChangeVelocity) { return _WriteChangeVelocity_M3(m_COMPort, nNodeID, dChangeVelocity); } // Read velocity move state public bool ReadVelocityMoveState_M3(byte nNodeID, ref ushort nVelocityMoveState) { return _ReadVelocityMoveState_M3(m_COMPort, nNodeID, ref nVelocityMoveState); } // Read P2P move state public bool ReadP2PMoveState_M3(byte nNodeID, ref ushort nP2PMoveState) { return _ReadP2PMoveState_M3(m_COMPort, nNodeID, ref nP2PMoveState); } // Read Q program segment number public bool ReadQProgramSegmentNumber_M3(byte nNodeID, ref ushort nQProgramSegmentNumber) { return _ReadQProgramSegmentNumber_M3(m_COMPort, nNodeID, ref nQProgramSegmentNumber); } // Read Command current public bool ReadCommandCurrent_M3(byte nNodeID, ref double dCommandCurrent) { return _ReadCommandCurrent_M3(m_COMPort, nNodeID, ref dCommandCurrent); } // Write Command current public bool WriteCommandCurrent_M3(byte nNodeID, double dCommandCurrent) { return _WriteCommandCurrent_M3(m_COMPort, nNodeID, dCommandCurrent); } // Read Max current public bool ReadMaximumCurrent_M3(byte nNodeID, ref double dMaximumCurrent) { return _ReadMaximumCurrent_M3(m_COMPort, nNodeID, ref dMaximumCurrent); } // Write Max current public bool WriteMaximumCurrent_M3(byte nNodeID, double dMaximumCurrent) { return _WriteMaximumCurrent_M3(m_COMPort, nNodeID, dMaximumCurrent); } // Read electronic gearing public bool ReadElectronicGearing_M3(byte nNodeID, ref uint nElectronicGearing) { return _ReadElectronicGearing_M3(m_COMPort, nNodeID, ref nElectronicGearing); } // Write electronic gearing public bool WriteElectronicGearing_M3(byte nNodeID, uint nElectronicGearing) { return _WriteElectronicGearing_M3(m_COMPort, nNodeID, nElectronicGearing); } // Read pulse counter public bool ReadPulseCounter_M3(byte nNodeID, ref int nPulseCounter) { return _ReadPulseCounter_M3(m_COMPort, nNodeID, ref nPulseCounter); } // Write pulse counter public bool WritePulseCounter_M3(byte nNodeID, int nPulseCounter) { return _WritePulseCounter_M3(m_COMPort, nNodeID, nPulseCounter); } // Read analog position gain public bool ReadAnalogPositionGain_M3(byte nNodeID, ref int nAnalogPositionGain) { return _ReadAnalogPositionGain_M3(m_COMPort, nNodeID, ref nAnalogPositionGain); } // Write analog position gain public bool WriteAnalogPositionGain_M3(byte nNodeID, int nAnalogPositionGain) { return _WriteAnalogPositionGain_M3(m_COMPort, nNodeID, nAnalogPositionGain); } // Read analog position gain public bool ReadAnalogVelocityGain_M3(byte nNodeID, ref double nAnalogVelocityGain) { return _ReadAnalogVelocityGain_M3(m_COMPort, nNodeID, ref nAnalogVelocityGain); } // Write analog position gain public bool WriteAnalogVelocityGain_M3(byte nNodeID, double nAnalogVelocityGain) { return _WriteAnalogVelocityGain_M3(m_COMPort, nNodeID, nAnalogVelocityGain); } // Read analog position gain public bool ReadAnalogTorqueGain_M3(byte nNodeID, ref double nAnalogTorqueGain) { return _ReadAnalogTorqueGain_M3(m_COMPort, nNodeID, ref nAnalogTorqueGain); } // Write analog position gain public bool WriteAnalogTorqueGain_M3(byte nNodeID, double nAnalogTorqueGain) { return _WriteAnalogTorqueGain_M3(m_COMPort, nNodeID, nAnalogTorqueGain); } // Read analog threshold public bool ReadAnalogThreshold1_M3(byte nNodeID, ref int nAnalogThreshold) { return _ReadAnalogThreshold1_M3(m_COMPort, nNodeID, ref nAnalogThreshold); } // Write analog threshold public bool WriteAnalogThreshold1_M3(byte nNodeID, int nAnalogThreshold) { return _WriteAnalogThreshold1_M3(m_COMPort, nNodeID, nAnalogThreshold); } // Read analog threshold public bool ReadAnalogThreshold2_M3(byte nNodeID, ref int nAnalogThreshold) { return _ReadAnalogThreshold2_M3(m_COMPort, nNodeID, ref nAnalogThreshold); } // Write analog threshold public bool WriteAnalogThreshold2_M3(byte nNodeID, int nAnalogThreshold) { return _WriteAnalogThreshold2_M3(m_COMPort, nNodeID, nAnalogThreshold); } // Read analogoffset public bool ReadAnalogOffset1_M3(byte nNodeID, ref int nAnalogOffset) { return _ReadAnalogOffset1_M3(m_COMPort, nNodeID, ref nAnalogOffset); } // Write analog offset public bool WriteAnalogOffset1_M3(byte nNodeID, int nAnalogOffset) { return _WriteAnalogOffset1_M3(m_COMPort, nNodeID, nAnalogOffset); } // Read analogoffset public bool ReadAnalogOffset2_M3(byte nNodeID, ref int nAnalogOffset) { return _ReadAnalogOffset2_M3(m_COMPort, nNodeID, ref nAnalogOffset); } // Write analog offset public bool WriteAnalogOffset2_M3(byte nNodeID, int nAnalogOffset) { return _WriteAnalogOffset2_M3(m_COMPort, nNodeID, nAnalogOffset); } // Read accumulator public bool ReadAccumulator_M3(byte nNodeID, ref int nAccumulator) { return _ReadAccumulator_M3(m_COMPort, nNodeID, ref nAccumulator); } // Read user defined register public bool ReadUserDefinedRegister_M3(byte nNodeID, char chRegister, ref int nValue) { return _ReadUserDefinedRegister_M3(m_COMPort, nNodeID, chRegister, ref nValue); } // Write user defined register public bool WriteUserDefinedRegister_M3(byte nNodeID, char chRegister, int nValue) { return _WriteUserDefinedRegister_M3(m_COMPort, nNodeID, chRegister, nValue); } // Read brake release delay public bool ReadBrakeReleaseDelay_M3(byte nNodeID, ref double dBrakeReleaseDelay) { return _ReadBrakeReleaseDelay_M3(m_COMPort, nNodeID, ref dBrakeReleaseDelay); } // Write brake release delay public bool WriteBrakeReleaseDelay_M3(byte nNodeID, double dBrakeReleaseDelay) { return _WriteBrakeReleaseDelay_M3(m_COMPort, nNodeID, dBrakeReleaseDelay); } // Read brake engage delay public bool ReadBrakeEngageDelay_M3(byte nNodeID, ref double dBrakeEngageDelay) { return _ReadBrakeEngageDelay_M3(m_COMPort, nNodeID, ref dBrakeEngageDelay); } // Write brake engage delay public bool WriteBrakeEngageDelay_M3(byte nNodeID, double dBrakeEngageDelay) { return _WriteBrakeEngageDelay_M3(m_COMPort, nNodeID, dBrakeEngageDelay); } // Read analog filter gain public bool ReadAnalogFilterGain1_M3(byte nNodeID, ref ushort nAnalogFilterGain) { return _ReadAnalogFilterGain1_M3(m_COMPort, nNodeID, ref nAnalogFilterGain); } // Write analog filter gain public bool WriteAnalogFilterGain1_M3(byte nNodeID, ushort nAnalogFilterGain) { return _WriteAnalogFilterGain1_M3(m_COMPort, nNodeID, nAnalogFilterGain); } // Read analog filter gain public bool ReadAnalogFilterGain2_M3(byte nNodeID, ref ushort nAnalogFilterGain) { return _ReadAnalogFilterGain2_M3(m_COMPort, nNodeID, ref nAnalogFilterGain); } // Write analog filter gain public bool WriteAnalogFilterGain2_M3(byte nNodeID, ushort nAnalogFilterGain) { return _WriteAnalogFilterGain2_M3(m_COMPort, nNodeID, nAnalogFilterGain); } // Write broadcast command public bool WriteBroadcastCommand(byte nNodeIDCount, byte[] aNodeIDArr, byte nFunctionCode) { bool ret = _WriteBroadcastCommand(m_COMPort, nNodeIDCount, aNodeIDArr, nFunctionCode); return ret; } // Execute multi-axes linear interpolation move public bool ExecuteLinearInterpolationMove(byte nNodeIDCount, byte[] aNodeIDArr, int[] aPosArr, uint nMaxLineSpeed, uint nAccelTimeInMs, bool bRelMove = true, bool bValidParamLimit = true) { bool ret = _ExecuteLinearInterpolationMove(m_COMPort, nNodeIDCount, aNodeIDArr, aPosArr, nMaxLineSpeed, nAccelTimeInMs, bRelMove, bValidParamLimit); return ret; } #endregion } }