private void convert(object data) { try { string[] arr = (string[])data; int id = Convert.ToInt32(arr[0]); string HexData = arr[1]; int DataLen = Convert.ToInt32(arr[2]); string Decode = arr[3]; string ss = arr[1].Substring(6, DataLen); string Value = string.Empty; switch (Decode) { case "FLOAT-0.001": Value = Convert.ToDouble(Convert.ToInt32(ss, 16) * 0.001).ToString(); break; case "FLOAT-0.01": Value = Convert.ToDouble(Convert.ToInt32(ss, 16) * 0.01).ToString(); break; case "FLOAT-0.1": Value = Convert.ToDouble(Convert.ToInt32(ss, 16) * 0.1).ToString(); break; case "INT-10": Value = (Convert.ToInt32(ss, 16) * 10).ToString(); break; case "INT": Value = Convert.ToInt32(ss, 16).ToString(); break; case "STRING": Value = ConvertUtilClass.HexToChar(ss); break; case "FLOAT-IEEE754": Value = ConvertUtilClass.HexToFloat(ss).ToString(); break; default: Value = (Convert.ToInt32(ss, 16)).ToString(); break; } GlobalData.DevicesDataStorage[0][id]["Value"] = Value; GlobalData.DevicesDataStorage[0][id]["HexData"] = HexData; GlobalData.DevicesDataStorage[0][id]["RefTime"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");//更新时间 }catch (Exception ex) { string msg = "数据转存错误:" + ex.ToString(); UIAction.AppendLog(msg); Log.Fatal(msg); } }