public override COMMUNICATERESULT SetData(CommandClass SetInfo) { int BytestoRec = 8; byte[] RecBytes; byte[] SendCommand; COMMUNICATERESULT ret; SendCommand = SetInfo.Command; if (!USBWrapper.USBConnectState()) { if (USBWrapper.connect() == COMMUNICATERESULT.OK) { ret = USBWrapper.SendAndReceive(SendCommand, BytestoRec, out RecBytes); } else { return(COMMUNICATERESULT.PortOpenFail); } } else { ret = USBWrapper.SendAndReceive(SendCommand, BytestoRec, out RecBytes); } if (ret == COMMUNICATERESULT.OK) { ret = CheckData(RecBytes, SendCommand); } return(ret); }
public override COMMUNICATERESULT GetData(DeviceBll Device, ref List <byte> AnalogDate, ref List <byte> DigitalData, ref List <string> CharacterData) { COMMUNICATERESULT ret = new COMMUNICATERESULT(); ret = COMMUNICATERESULT.OK; byte[] SendCommand = null; byte[] RecByte = null; byte[] RecData = null; int BytesToRec = 0; foreach (CommandClass AnalogCommand in Device.Device.AnalogCommandList) { SendCommand = AnalogCommand.Command; BytesToRec = AnalogCommand.RecLen; ret = USBWrapper.SendAndReceive(SendCommand, BytesToRec, out RecByte); if (ret != COMMUNICATERESULT.OK) { return(ret); } ret = CheckData(RecByte, SendCommand); if (ret != COMMUNICATERESULT.OK) { return(ret); } RecData = GetRecDataFromRecByte(RecByte); AnalogDate.AddRange(RecData); } foreach (CommandClass DigitalCommand in Device.Device.DigitalCommandList) { SendCommand = DigitalCommand.Command; BytesToRec = DigitalCommand.RecLen; ret = USBWrapper.SendAndReceive(SendCommand, BytesToRec, out RecByte); if (ret != COMMUNICATERESULT.OK) { return(ret); } ret = CheckData(RecByte, SendCommand); if (ret != COMMUNICATERESULT.OK) { return(ret); } RecData = GetRecDataFromRecByte(RecByte); DigitalData.AddRange(RecData); } return(COMMUNICATERESULT.OK); }