/// <summary> /// 获取板实际温度 /// </summary> /// <param name="num">0,1</param> /// <returns></returns> public double GetTemperature(int num, int sensor_num = -1) { if (!connected) { throw new Exception("服务器未连接,尝试连接至服务器"); } uint address = 0xff71 + (uint)num; var re = WriteReadReg(address); if (sensor_num == -1) { return(TEMPERATUE.cal(BitConverter.ToUInt32(re.data, 8))); } else { var sensor = sensors.Find(delegate(Sensor s) { return(s.sensor_num == sensor_num); }); if (sensor == null) { throw new Exception("未在配置文件中找到编号为" + sensor_num.ToString() + "的Sensor,请检查config文件和填写的传感器编号"); } return(TEMPERATUE.cal_by_pts(BitConverter.ToUInt32(re.data, 8), sensor.temperature_paras)); } }
/// <summary> /// 获取/设置板设定温度 /// </summary> /// <param name="num">0,1</param> /// <param name="set"></param> /// <param name="temperature">Unit:℃</param> /// <returns></returns> public double GetSetTemperature(int num, bool set = false, double temperature = -20) { if (!connected) { throw new Exception("服务器未连接,尝试连接至服务器,尝试连接至服务器"); } uint address = 0xff73 + (uint)num; Client.ReceiveEventArgs re; if (set) { re = WriteReadReg(address, false, (uint)TEMPERATUE.cal_inv(temperature)); } else { re = WriteReadReg(address); } return(TEMPERATUE.cal(BitConverter.ToUInt32(re.data, 8))); }