public void UseRealArch() { //controller. //1.从控制器接收数据 //2.判断控制器当前设置的状态:上传或下载 //3.得到控制器类型 //4.加载“具体的控制器处理类”,执行数据处理,及回复66确认 DeviceInfo8036 deviceInfo = new DeviceInfo8036(); //1.取得当前操作的控制器数据 SCA.BusinessLib.ModelOperation.ControllerModelOperation cModelOperation = new SCA.BusinessLib.ModelOperation.ControllerModelOperation(); ControllerModel controllerModel = cModelOperation.GetControllersBySpecificID(1); //2.判断当前控制器的连接状态 //ICom com=Substitute.For<ICom>(); IControllerCommunication controller = Substitute.For <IControllerCommunication>(); controller.PortName.Returns <string>("Com1"); controller.BaudRate.Returns <int>(38400); controller.OpenPort().Returns <bool>(true); //打开端口 controller.TestControllerStatus().Returns <bool>(true); //获取控制器状态<收到巡检命令 CA> //controller. //3.执行下传数据指令 //controller.Received IControllerOperation operation = Substitute.For <IControllerOperation>(); // operation.GetControllerType().Returns<ControllerType>(ControllerType.NT8036); // SCA.BusinessLib.BusinessLogic.ControllerManager controllerManager = new SCA.BusinessLib.BusinessLogic.ControllerManager(); // controllerManager.AddController(controllerModel.ID,operation);//一个Controller对应一个Operation }
public bool GetDevicesByLoopForControllerType8036(ref LoopModel loop) { List <DeviceInfo8036> lstDeviceInfo8036 = new List <DeviceInfo8036>(); string strDeviceQuerySQL = "select bianhao,leixing,geli,yanshi,shuchu1,shuchu2,nongdu,yjnongdu,louhao,quhao,cenghao,fangjianhao,didian from "; strDeviceQuerySQL += loop.Code; DataTable dtDevices = _databaseService.GetDataTableBySQL(new StringBuilder(strDeviceQuerySQL)); int dtDevicesRowsCount = dtDevices.Rows.Count; for (int j = 0; j < dtDevicesRowsCount; j++) //器件信息 { DeviceInfo8036 device = new DeviceInfo8036(); device.Code = dtDevices.Rows[j]["bianhao"].ToString(); device.Disable = dtDevices.Rows[j]["geli"].ToString().ToNullable <bool>(); Int16?intTypeCode = dtDevices.Rows[j]["leixing"].ToString().Substring(0, 3).ToNullable <Int16>(); device.TypeCode = (short)intTypeCode; device.DelayValue = dtDevices.Rows[j]["yanshi"].ToString().ToNullable <Int16>(); device.LinkageGroup1 = dtDevices.Rows[j]["shuchu1"].ToString(); device.LinkageGroup2 = dtDevices.Rows[j]["shuchu2"].ToString(); device.AlertValue = dtDevices.Rows[j]["nongdu"].ToString().ToNullable <float>(); device.ForcastValue = dtDevices.Rows[j]["yjnongdu"].ToString().ToNullable <float>(); device.BuildingNo = dtDevices.Rows[j]["louhao"].ToString().ToNullable <Int16>(); device.ZoneNo = dtDevices.Rows[j]["quhao"].ToString().ToNullable <Int16>(); device.FloorNo = dtDevices.Rows[j]["cenghao"].ToString().ToNullable <Int16>(); device.RoomNo = dtDevices.Rows[j]["fangjianhao"].ToString().ToNullable <Int16>(); device.Location = dtDevices.Rows[j]["didian"].ToString(); device.Loop = loop; loop.SetDevice <DeviceInfo8036>(device); lstDeviceInfo8036.Add(device); } return(true); }
public static void Get8036DevInfo(out List <DeviceInfo8036> lstDevInfo) { ControllerModel cModel = new ControllerModel(1, "8036", ControllerType.NT8036, 3); cModel.MachineNumber = "001"; LoopModel lModel = new LoopModel(); lModel.Controller = cModel; lModel.Code = "01"; lstDevInfo = new List <DeviceInfo8036>(); DeviceInfo8036 dev = new DeviceInfo8036(); dev.ID = 1; dev.Loop = lModel; dev.Code = "00101001"; dev.TypeCode = 36; dev.Disable = 0; dev.LinkageGroup1 = "1"; dev.LinkageGroup2 = "2"; dev.AlertValue = 0; dev.ForcastValue = 0; dev.DelayValue = 0; dev.BuildingNo = 5; dev.ZoneNo = 6; dev.FloorNo = 7; dev.RoomNo = 8; dev.Location = "仙鹤哈里发9"; lstDevInfo.Add(dev); }
public DeviceInfo8036 Builder() { DeviceInfo8036 device = new DeviceInfo8036 { ID = _id, //SimpleCode=_simpleCode,//Commented at 2017-04-05 ,后续需要修改单元测试,改为Code TypeCode = _type, Disable = _disable, LoopID = _loopID }; return(device); }
public EditableDeviceInfo8036(DeviceInfo8036 deviceInfo8036) { this.Loop = deviceInfo8036.Loop; this.LoopID = deviceInfo8036.LoopID; this.ID = deviceInfo8036.ID; this.Code = deviceInfo8036.Code; // this.SimpleCode = deviceInfo8036.SimpleCode; this.TypeCode = deviceInfo8036.TypeCode; this.Disable = deviceInfo8036.Disable; this.LinkageGroup1 = deviceInfo8036.LinkageGroup1; this.LinkageGroup2 = deviceInfo8036.LinkageGroup2; this.AlertValue = deviceInfo8036.AlertValue; this.ForcastValue = deviceInfo8036.ForcastValue; this.DelayValue = deviceInfo8036.DelayValue; this.BuildingNo = deviceInfo8036.BuildingNo; this.ZoneNo = deviceInfo8036.ZoneNo; this.FloorNo = deviceInfo8036.FloorNo; this.RoomNo = deviceInfo8036.RoomNo; this.Location = deviceInfo8036.Location; }
public bool GetDevicesInLoop(ref LoopModel loop, Dictionary <string, string> dictDeviceMappingManualControlBoard) { try { List <DeviceInfo8036> lstDeviceInfo = new List <DeviceInfo8036>(); StringBuilder sbQuerySQL = new StringBuilder("select bianhao,leixing,geli,shuchu1,shuchu2,nongdu,yjnongdu,yanshi,louhao,quhao,cenghao,fangjianhao,didian from " + loop.Code); DataTable dtDevices = _databaseService.GetDataTableBySQL(sbQuerySQL); int dtRowsCount = dtDevices.Rows.Count; for (int j = 0; j < dtRowsCount; j++) { DeviceInfo8036 device = new DeviceInfo8036(); device.Code = dtDevices.Rows[j]["bianhao"].ToString(); device.TypeCode = Convert.ToInt16(dtDevices.Rows[j]["leixing"].ToString()); device.Disable = dtDevices.Rows[j]["geli"].ToString().ToNullable <Int16>(); device.LinkageGroup1 = dtDevices.Rows[j]["shuchu1"].ToString(); device.LinkageGroup2 = dtDevices.Rows[j]["shuchu2"].ToString(); device.AlertValue = dtDevices.Rows[j]["nongdu"].ToString().ToNullable <float>(); device.ForcastValue = dtDevices.Rows[j]["yjnongdu"].ToString().ToNullable <float>(); device.DelayValue = dtDevices.Rows[j]["yanshi"].ToString().ToNullable <Int16>(); device.BuildingNo = dtDevices.Rows[j]["louhao"].ToString().ToNullable <Int16>(); device.ZoneNo = dtDevices.Rows[j]["quhao"].ToString().ToNullable <Int16>(); device.FloorNo = dtDevices.Rows[j]["cenghao"].ToString().ToNullable <Int16>(); device.RoomNo = dtDevices.Rows[j]["fangjianhao"].ToString().ToNullable <Int16>(); device.Location = dtDevices.Rows[j]["didian"].ToString(); device.Loop = loop; loop.SetDevice <DeviceInfo8036>(device); lstDeviceInfo.Add(device); } if (lstDeviceInfo.Count > 0) { _deviceAddressLength = lstDeviceInfo[0].Code.Length; } } catch { return(false); } return(true); }
public DeviceInfo8036 ToDeviceInfo8036() { DeviceInfo8036 deviceInfo8036 = new DeviceInfo8036(); deviceInfo8036.Loop = this.Loop; deviceInfo8036.LoopID = this.LoopID; deviceInfo8036.ID = this.ID; deviceInfo8036.Code = this.Code; //deviceInfo8036.SimpleCode = this.SimpleCode; deviceInfo8036.TypeCode = this.TypeCode; deviceInfo8036.Disable = this.Disable; deviceInfo8036.LinkageGroup1 = this.LinkageGroup1; deviceInfo8036.LinkageGroup2 = this.LinkageGroup2; deviceInfo8036.AlertValue = this.AlertValue; deviceInfo8036.ForcastValue = this.ForcastValue; deviceInfo8036.DelayValue = this.DelayValue; deviceInfo8036.BuildingNo = this.BuildingNo; deviceInfo8036.ZoneNo = this.ZoneNo; deviceInfo8036.FloorNo = this.FloorNo; deviceInfo8036.RoomNo = this.RoomNo; deviceInfo8036.Location = this.Location; return(deviceInfo8036); }
public int AddDeviceForControllerType8036(DeviceInfo8036 deviceInfo) { throw new NotImplementedException(); }
/// <summary> /// 解析收到的器件数据包 /// </summary> /// <param name="standardLinkagePackage"></param> /// <returns></returns> private Model.DeviceInfo8036 ParsePackageCC(byte[] devicePackage) { ControllerModel cModel = new ControllerModel(2, "8036", ControllerType.NT8036, 3); cModel.MachineNumber = "00"; //第7字节作为基址 //采用GB18030编码 System.Text.Encoding ascii = System.Text.Encoding.GetEncoding(54936); //器件总数 int tempDeviceAmount = Convert.ToInt16(devicePackage[7]); //机号 string tempMachineNo = Convert.ToInt16(devicePackage[8]).ToString(); switch (base.ControllerModel.DeviceAddressLength) { case 7: tempMachineNo = tempMachineNo.PadLeft(2, '0'); break; case 8: tempMachineNo = tempMachineNo.PadLeft(3, '0'); break; default: //默认7位,但此分支不应该走,此时应该知道编码位数 tempMachineNo = tempMachineNo.PadLeft(2, '0'); break; } cModel.MachineNumber = tempMachineNo; //#---------start //将“器件总数”及"回路号"存入系统设置表中-->机号+路号作为回路号 //回路号作为"存储器件的表名": 表名的规则为“路号+编号" // //#----------end //回路信息 Model.LoopModel loop = new LoopModel(); loop.Code = Convert.ToInt16(devicePackage[9]).ToString(); loop.DeviceAmount = tempDeviceAmount; DeviceInfo8036 deviceInfo = new DeviceInfo8036(); deviceInfo.Loop = loop; deviceInfo.LoopID = Convert.ToInt16(devicePackage[9]); //器件编码 deviceInfo.Code = Convert.ToInt16(devicePackage[10]).ToString(); //deviceInfo.MachineNo = tempMachineNo; //.Fields("geli") = CStr((m_arrInputData(nStartPos + 4) Mod 8) \ 4) //.Fields("lingmd") = CStr(m_arrInputData(nStartPos + 4) Mod 4 + 1) //屏蔽 deviceInfo.Disable = Convert.ToInt16((devicePackage[11] % 8) / 4); //灵敏度 // deviceInfo.SensitiveLevel = Convert.ToInt16((devicePackage[11] % 4) + 1); //设备类型 short tempType = Convert.ToInt16(devicePackage[12]); //根据设备类型的取值,决定是否需要特性字段信息 //if (tempType > 36 && tempType < 66) //{ // int tempSubType = Convert.ToInt16((devicePackage[11] + 4) / 8); // switch (tempSubType) // { // case 23: // deviceInfo.Feature = 1; // break; // case 31: // deviceInfo.Feature = 2; // break; // case 30: // deviceInfo.Feature = 3; // break; // default: // deviceInfo.Feature = 0; // break; // } //} deviceInfo.TypeCode = tempType; //.ToString().PadLeft(3,'0'); int tempValue; //临时变量 tempValue = devicePackage[13]; // *256 + devicePackage[14]; //联动组1 deviceInfo.LinkageGroup1 = tempValue == 0 ? "" : tempValue.ToString().PadLeft(3, '0'); tempValue = devicePackage[14]; //* 256 + devicePackage[16]; //联动组2 deviceInfo.LinkageGroup2 = tempValue == 0 ? "" : tempValue.ToString().PadLeft(3, '0'); //tempValue = devicePackage[17] * 256 + devicePackage[18]; ////联动组3 //deviceInfo.LinkageGroup3 = tempValue == 0 ? "" : tempValue.ToString().PadLeft(4, '0'); //延时 //yanshis = Format(m_arrInputData(nStartPos + 8), "00#") tempValue = devicePackage[15]; deviceInfo.DelayValue = Convert.ToInt16(tempValue);//== 0 ? "" : tempValue.ToString().PadLeft(2, '0'); byte[] bLocation = new byte[17]; for (int i = 17; i < 34; i++) { bLocation[i - 17] = devicePackage[i]; } deviceInfo.Location = ascii.GetString(bLocation); deviceInfo.BuildingNo = devicePackage[35]; deviceInfo.ZoneNo = devicePackage[36]; deviceInfo.FloorNo = devicePackage[37]; deviceInfo.RoomNo = devicePackage[38]; return(deviceInfo); }
private bool GenerateDeviceID(ControllerType controllerType, ref LoopModel loop) { bool resultFlag = false; try { switch (controllerType) { case ControllerType.NT8001: { int maxDeviceID = ProjectManager.GetInstance.MaxDeviceIDInController8001; List <DeviceInfo8001> lstDeviceInfo = loop.GetDevices <DeviceInfo8001>(); for (int i = 0; i < lstDeviceInfo.Count; i++) { maxDeviceID++; DeviceInfo8001 deviceInfo = lstDeviceInfo[i]; deviceInfo.ID = maxDeviceID; lstDeviceInfo[i] = deviceInfo; } ProjectManager.GetInstance.MaxDeviceIDInController8001 = maxDeviceID; } break; case ControllerType.NT8007: { int maxDeviceID = ProjectManager.GetInstance.MaxDeviceIDInController8007; List <DeviceInfo8007> lstDeviceInfo = loop.GetDevices <DeviceInfo8007>(); foreach (var device in lstDeviceInfo) { maxDeviceID++; device.ID = maxDeviceID; } ProjectManager.GetInstance.MaxDeviceIDInController8007 = maxDeviceID; } break; case ControllerType.NT8021: { int maxDeviceID = ProjectManager.GetInstance.MaxDeviceIDInController8021; List <DeviceInfo8021> lstDeviceInfo = loop.GetDevices <DeviceInfo8021>(); for (int i = 0; i < lstDeviceInfo.Count; i++) { maxDeviceID++; DeviceInfo8021 deviceInfo = lstDeviceInfo[i]; deviceInfo.ID = maxDeviceID; lstDeviceInfo[i] = deviceInfo; } ProjectManager.GetInstance.MaxDeviceIDInController8021 = maxDeviceID; } break; case ControllerType.NT8036: { int maxDeviceID = ProjectManager.GetInstance.MaxDeviceIDInController8036; List <DeviceInfo8036> lstDeviceInfo = loop.GetDevices <DeviceInfo8036>(); for (int i = 0; i < lstDeviceInfo.Count; i++) { maxDeviceID++; DeviceInfo8036 deviceInfo = lstDeviceInfo[i]; deviceInfo.ID = maxDeviceID; lstDeviceInfo[i] = deviceInfo; } ProjectManager.GetInstance.MaxDeviceIDInController8036 = maxDeviceID; } break; case ControllerType.FT8000: { int maxDeviceID = ProjectManager.GetInstance.MaxDeviceIDInController8000; List <DeviceInfo8000> lstDeviceInfo = loop.GetDevices <DeviceInfo8000>(); for (int i = 0; i < lstDeviceInfo.Count; i++) { maxDeviceID++; DeviceInfo8000 deviceInfo = lstDeviceInfo[i]; deviceInfo.ID = maxDeviceID; lstDeviceInfo[i] = deviceInfo; } ProjectManager.GetInstance.MaxDeviceIDInController8000 = maxDeviceID; } break; case ControllerType.FT8003: { int maxDeviceID = ProjectManager.GetInstance.MaxDeviceIDInController8003; List <DeviceInfo8003> lstDeviceInfo = loop.GetDevices <DeviceInfo8003>(); for (int i = 0; i < lstDeviceInfo.Count; i++) { maxDeviceID++; DeviceInfo8003 deviceInfo = lstDeviceInfo[i]; deviceInfo.ID = maxDeviceID; lstDeviceInfo[i] = deviceInfo; } ProjectManager.GetInstance.MaxDeviceIDInController8003 = maxDeviceID; } break; } resultFlag = true; } catch { } return(resultFlag); }