using System.Threading; using QModules.Controller.Serial; namespace QModules.Controller.Devices { public interface QMotorInterface { QDeviceOperationStatus Command(byte Motor, byte Direction, byte Pwm); } public class QMotorDevice : QSyncDevice, QMotorInterface { public QMotorDevice(int timeout) : base(timeout) { } public QDeviceOperationStatus Command(byte Motor, byte Direction, byte Pwm) { byte[] buffer = new byte[4]; buffer[0] = 0x01; buffer[1] = Motor; buffer[2] = Pwm; buffer[3] = Direction; buffer = QGateParser.Request(buffer, QGateParser.GateAddress, 0x04); QDeviceOperationStatus s = SyncSend(buffer); if (s != QDeviceOperationStatus.Done) return s; QGatePacket r = QGateParser.Response(Response); if (r.result == QGateParser.GateResponse) return QDeviceOperationStatus.Done; return (QDeviceOperationStatus.Error); } } }