/// <summary> /// Actually writes to the motor. /// Used when running and stopping the motor. /// </summary> public void UpdateMotor() { ushort ID = 8; ushort StartAddress = 4; byte unit = 0; if (MBmaster == null) { Logger.LogError("Attempting to write to null motor. Write failed."); return; } MBmaster.ReadWriteMultipleRegister(ID, unit, StartAddress, 12, StartAddress, ManualMotor.InputData.GetValues(), ref result); ManualMotor.OutputData.SetValues(result); }
// ------------------------------------------------------------------------ /// <summary>Sychnronous read register data.</summary> /// <param name="module_nr">The position of the module.</param> /// <param name="register">Configuration register to read.</param> /// <returns>The method always returns 2 integer values with low and high word of the register.</returns> public int[] ReadRegister(byte module_nr, int register) { byte[] values = { }; int[] swap = { 0, 0 }; int[] reg = { module_nr, register }; MBmaster.ReadWriteMultipleRegister(ID_register, 0, 0x1286, 2, 0x1284, WordArray2WordByte(reg), ref values); if ((values == null) && (OnBCexception != null)) { OnBCexception(excDataEmptyAnswer); } else if (values.Length == 4) { swap[0] = Byte2Word(values[2], values[3]); swap[1] = Byte2Word(values[0], values[1]); return(swap); } return(null); }