} //SplitDataPacket /// <summary> /// 向通讯管理机写入的数据(调用WriteDataToCmeAndGetReturnValInCell),并且取得通讯管理机的值 /// </summary> /// <param name="pointRTModel">要向通讯管理机写入的数据</param> /// <returns>通讯管理机的值:null 表示没有用取到通许管理机的值</returns> private double?GetControlReturnValue(PointRTModel pointRTModel) { double?returnVal = null; //null 表示没有用取到通许管理机的值 int devID = pointRTModel.ID.DevID; UpDataBase.RTWriteProxy.MType type = pointRTModel.ID.Type; int pointID = pointRTModel.ID.PointID; double pointVal = pointRTModel.Value; IDModel idModel = new IDModel(devID, type, pointID); IDEquipRes idEquipRes = null; //idModel对应的IDEquipRes if (_dictionMToE.ContainsKey(idModel.ToULongForIndex())) //判断_dictionMToE字典中是否存在idModel { idEquipRes = _dictionMToE[idModel.ToULongForIndex()]; } else { return(null); //没有用取到通许管理机的值 } CmeManager cmeMagr = _dicEquipIdToCmeManager[idEquipRes.EquipID]; //根据IDEquipRes找到对用的CmeManager DataPoint dataPiont = cmeMagr.CmEquipment.DicResIdToDataPoint[idEquipRes.RegID]; //根据idEquipRes.RegID找到对用的CmeManager上DataPoint //新创建的dataPiont的PointValue 默认值为null,不要漏了赋新值pointVal dataPiont.PointValue = pointVal; returnVal = cmeMagr.WriteDataToCmeAndGetReturnValInCell(dataPiont); return(returnVal); }
/// <summary> /// 由ModBus列表创建IDEquipRes[,]---IDModel[, , , ]相互索引 /// </summary> /// <param name="modbusList">ModBus列表</param> public void SetDictionaryWithXml(string xmlPath) { System.Xml.XmlDataDocument xmlDoc = new System.Xml.XmlDataDocument(); xmlDoc.Load(xmlPath); IDEquipRes tmpIDEqu; IDModel tmpIDMod; foreach (XmlNode node1 in xmlDoc.ChildNodes) { foreach (XmlNode node2 in node1.ChildNodes) { if (node2.Name == "Point") { int equId = Convert.ToInt32(node2.Attributes["MachineID"].Value); int resId = Convert.ToInt32(node2.Attributes["RegID"].Value); int devId = Convert.ToInt32(node2.Attributes["DevID"].Value); int pointId = Convert.ToInt32(node2.Attributes["PointID"].Value); string strType = node2.Attributes["Type"].Value.Trim(); tmpIDEqu = new IDEquipRes(equId, resId); tmpIDMod = new IDModel(devId, strType, pointId); //IDEquipRes --> IDModel dictionEToM.Add(tmpIDEqu.ToULongForIndex(), tmpIDMod); //IDModel --> IDEquipRes dictionMToE.Add(tmpIDMod.ToULongForIndex(), tmpIDEqu); } } } } //end of SetIndexWithXml