private string BqUpdateMcuInfo_4Byte(H5BmsInfo nodeInfo, List <byte> listRecv, int nByteIndex) { //return ((listRecv[nByteIndex] << 24) | (listRecv[nByteIndex + 1] << 16) | // (listRecv[nByteIndex + 2] << 8) | (listRecv[nByteIndex + 3])).ToString(); return(((listRecv[nByteIndex + 3] << 24) | (listRecv[nByteIndex + 2] << 16) | (listRecv[nByteIndex + 1] << 8) | (listRecv[nByteIndex])).ToString()); }
private string BqUpdateMcuInfo_2Byte(H5BmsInfo nodeInfo, byte bt1, byte bt2) { byte[] byteVal = new byte[2] { bt2, bt1 }; if (nodeInfo.Description == "容量学习最低允许温度") { return(((((byteVal[0] << 8) | byteVal[1]) - 2731) / 10).ToString()); } else { return(((byteVal[0] << 8) | byteVal[1]).ToString()); } }
public static string UpdateParaStringFormat(List <byte> listRecvData, H5BmsInfo nodeInfo) { string strRet = null; int nOffset = 2; // 前两个字节为DID if (nodeInfo.Scale != "FF") { double dRecv = DataFormatConvert.GetIntData(listRecvData, nOffset, nodeInfo.RegisterNum); double dConver = DataFormatConvert.BytesToUIDataConverter(nodeInfo.Conversion, dRecv); if (nodeInfo.Scale != "1") { strRet = dConver.ToString(); } else if (nodeInfo.Scale != "0.1") { strRet = dConver.ToString("0.0"); } else if (nodeInfo.Scale != "0.01") { strRet = dConver.ToString("0.00"); } } else { byte[] btRecv = new byte[nodeInfo.RegisterNum]; for (int k = 0; k < nodeInfo.RegisterNum; k++) { btRecv[k] = listRecvData[nOffset + k]; } strRet = DataFormatConvert.BytesToHexStr(btRecv); } return(strRet); }
public static void LoadCellVoltageConfig(string strFileName, string strSubNode1, string strSubNode2, IList <H5BmsInfo> listNode, string strAddr) { try { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(strFileName); XmlElement root = xmlDoc.DocumentElement; //XmlNode subNode1 = root.SelectNodes(strSubNode1)[0]; // "master_adjust_config" int nCount = 0; //double minVal = 0; //double maxVal = 0; //string strUnit = "mV"; //string scale = "1"; //string strConversion = "y=x"; XmlNodeList nodeList = xmlDoc.SelectNodes("/root/bms_info/register_node_info/address"); foreach (XmlNode node in nodeList) // "MasterAdjustNode" { if (node.InnerText == strAddr) { string strCount = node.ParentNode.SelectSingleNode("register_num").InnerText; //if(!string.IsNullOrEmpty( nodelist2[3].InnerText)) //{ // minVal = double.Parse(nodelist2[3].InnerText); //} //if (!string.IsNullOrEmpty(nodelist2[4].InnerText)) //{ // minVal = double.Parse(nodelist2[4].InnerText); //} //strUnit = nodelist2[5].InnerText; //scale = nodelist2[6].InnerText; if (!string.IsNullOrEmpty(strCount)) { nCount = int.Parse(strCount); break; } //strConversion = nodelist2[8].InnerText; } } for (int n = 0; n < nCount; n++) { H5BmsInfo nodeInfo = new H5BmsInfo(); nodeInfo.Index = listNode.Count + 1; nodeInfo.Address = Convert.ToInt32(strAddr, 16); if (strAddr == "A210") { nodeInfo.Description = "高16组 电芯" + (n + 1).ToString() + "电压"; } else { nodeInfo.Description = "低16组 电芯" + (n + 1).ToString() + "电压"; } nodeInfo.StrValue = "0"; // nodeInfo.MinValue = 0; nodeInfo.MaxValue = 0; nodeInfo.Unit = "mV"; nodeInfo.Scale = "1"; nodeInfo.RegisterNum = 1; nodeInfo.Conversion = "y=x"; listNode.Add(nodeInfo); } //LogXmlHelp.Info("节点数 ... listAdjust: " + listMaster.Count); } catch (Exception ex) { //LogXmlHelp.Error("加载 " + strFileName + " 错误!\n" + ex.Message + ex.StackTrace); } }
public static void LoadCellVoltageConfig(string strFileName, IList <H5BmsInfo> listNode, string strAddr) { try { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(strFileName); XmlElement root = xmlDoc.DocumentElement; int nCount = 0; XmlNodeList nodeList = xmlDoc.SelectNodes("/root/bms_info/register_node_info/address"); foreach (XmlNode node in nodeList) // "MasterAdjustNode" { if (node.InnerText == strAddr) { string strCount = node.ParentNode.SelectSingleNode("register_num").InnerText; if (!string.IsNullOrEmpty(strCount)) { nCount = int.Parse(strCount); break; } } } for (int n = 0; n < nCount; n++) { H5BmsInfo nodeInfo = new H5BmsInfo(); nodeInfo.Index = listNode.Count + 1; nodeInfo.Address = Convert.ToInt32(strAddr, 16); nodeInfo.AddressStr = "0x" + strAddr; if (strAddr == "A210") { nodeInfo.Description = "高16组 电芯" + (n + 1).ToString() + "电压"; } else { nodeInfo.Description = "低16组 电芯" + (n + 1).ToString() + "电压"; } nodeInfo.StrValue = "0"; // nodeInfo.MinValue = 0; nodeInfo.MaxValue = 0; nodeInfo.Unit = "mV"; nodeInfo.Scale = "1"; nodeInfo.RegisterNum = 1; nodeInfo.Conversion = "y=x"; listNode.Add(nodeInfo); } } catch (Exception ex) { } }