public static List <WeatherEntity> WriteWeatherCount(short count, byte address, CommonConfig config, Action <string> callback) { byte[] sendb = Command.GetWiteSendByte(address, 0x00, 0x21, BitConverter.GetBytes(count).Reverse().ToArray()); callback(string.Format("W: {0}", CommandUnits.ByteToHexStr(sendb))); PLAASerialPort.Write(sendb); return(WeatherInstruction.ReadWeather(address, config, callback)); }
public static AllEntity ReadAll(byte address, CommonConfig config, Action <string> callback, Action <string> commandCallback) { AllEntity all = new AllEntity(); try { all.Normal = NormalInstruction.ReadNormal(address, config, commandCallback); callback("读取通用参数成功"); } catch (Exception ex) { log.Error(ex); callback("读取通用参数失败"); } for (int i = 1; i <= all.Normal.GasCount; i++) { try { all.GasList.Add(GasInstruction.ReadGas(i, address, config, commandCallback)); callback(string.Format("读取气体{0}成功", i)); } catch (Exception ex) { log.Error(ex); callback(string.Format("读取气体{0}失败", i)); } } try { all.WeatherList = WeatherInstruction.ReadWeather(address, config, commandCallback); callback("读取气象成功"); } catch (Exception ex) { log.Error(ex); callback("读取气象失败"); } try { all.Serial = SerialInstruction.ReadSerialParam(address, config, commandCallback); callback("读取串口参数成功"); } catch (Exception ex) { log.Error(ex); callback("读取串口参数失败"); } try { all.EquipmentDataTime = ReadRealTime(address, commandCallback); callback("读取时间成功"); } catch (Exception ex) { log.Error(ex); callback("读取时间失败"); } try { all.OutDate = ReadOutDate(address, commandCallback); callback("读取出厂日期成功"); } catch (Exception ex) { log.Error(ex); callback("读取出厂日期失败"); } return(all); }