private void SetNozzleParamToDll() { int structLenth = Marshal.SizeOf(typeof(struNozzleRecog)); struNozzleRecog[] nozzleRecog = new struNozzleRecog[Global.nozzleList.Count]; byte[] ipp = new byte[10000]; int offset = 0; for (int i = 0; i < Global.nozzleList.Count; i++) { nozzleRecog[i].nozzleNo = Global.nozzleList[i].nozzleNo; nozzleRecog[i].areas = new struArea[8]; nozzleRecog[i].areaCount = Global.nozzleList[i].linkedMainAreaList.Count; for (int j = 0; j < nozzleRecog[i].areaCount; j++) { if (Global.areaMap.ContainsKey(Global.nozzleList[i].linkedMainAreaList[j])) { int index = Global.areaMap[Global.nozzleList[i].linkedMainAreaList[j]]; nozzleRecog[i].videoChan = Global.areaList[index].videoChannel; nozzleRecog[i].areas[j].areaNo = Global.areaList[index].id; nozzleRecog[i].areas[j].left = (int)(Global.areaList[index].left * Global.nDefaultWidth); nozzleRecog[i].areas[j].right = (int)(Global.areaList[index].right * Global.nDefaultWidth); nozzleRecog[i].areas[j].top = (int)(Global.areaList[index].top * Global.nDefaultHeight); nozzleRecog[i].areas[j].bottom = (int)(Global.areaList[index].bottom * Global.nDefaultHeight); nozzleRecog[i].areas[j].videoLaneNo = Global.areaList[index].videoLaneNo; } // foreach (ClsRecogArea area in Global.areaList) // { // if (Global.nozzleList[i].linkedMainAreaList[j] == area.id) // { // nozzleRecog[i].videoChan = area.videoChannel; // nozzleRecog[i].areas[j].areaNo = area.id; // nozzleRecog[i].areas[j].left = (int)(area.left * Global.nDefaultWidth); // nozzleRecog[i].areas[j].right = (int)(area.right * Global.nDefaultWidth); // nozzleRecog[i].areas[j].top = (int)(area.top * Global.nDefaultHeight); // nozzleRecog[i].areas[j].bottom = (int)(area.bottom * Global.nDefaultHeight); // nozzleRecog[i].areas[j].videoLaneNo = area.videoLaneNo; // } // } } byte[] bNozzle = SystemUnit.StrutsToBytesArray(nozzleRecog[i]); Buffer.BlockCopy(bNozzle, 0, ipp, offset, structLenth); offset += structLenth; } SPlate.SP_InitRunParam_Nozzle(ipp, Global.nozzleList.Count); Global.LogServer.Add(new LogInfo("Debug", "Main->InitDev->SetNozzleParamToDll 油枪参数传入动态库完成,油枪数:" + Global.nozzleList.Count.ToString(), (int)EnumLogLevel.DEBUG)); }
private void SetVideoChanParamToDll() { int structLenth = Marshal.SizeOf(typeof(struVideoChan)); //IntPtr ip = Marshal.AllocHGlobal(Global.nozzleList.Count* structLenth); struVideoChan[] videoChan = new struVideoChan[Global.videoChanList.Count]; byte[] ipp = new byte[10000]; int offset = 0; for (int i = 0; i < Global.videoChanList.Count; i++) { videoChan[i].chanNo = Global.videoChanList[i].channelNo; videoChan[i].areaCount = Global.videoChanList[i].areaNoList.Count; videoChan[i].videoType = Global.videoChanList[i].videoType; videoChan[i].areas = new struArea[8]; for (int j = 0; j < videoChan[i].areaCount; j++) { if (Global.areaMap.ContainsKey(Global.videoChanList[i].areaNoList[j])) { int index = Global.areaMap[Global.videoChanList[i].areaNoList[j]]; videoChan[i].areas[j].areaNo = Global.areaList[index].id; videoChan[i].areas[j].left = (int)(Global.areaList[index].left * Global.nDefaultWidth); videoChan[i].areas[j].right = (int)(Global.areaList[index].right * Global.nDefaultWidth); videoChan[i].areas[j].top = (int)(Global.areaList[index].top * Global.nDefaultHeight); videoChan[i].areas[j].bottom = (int)(Global.areaList[index].bottom * Global.nDefaultHeight); videoChan[i].areas[j].videoChanNo = videoChan[i].chanNo; videoChan[i].areas[j].videoLaneNo = Global.areaList[index].videoLaneNo; } } byte[] byVideo = SystemUnit.StrutsToBytesArray(videoChan[i]); Buffer.BlockCopy(byVideo, 0, ipp, offset, structLenth); offset += structLenth; } SPlate.SP_InitRunParam_Video(ipp, Global.videoChanList.Count); Global.LogServer.Add(new LogInfo("Debug", "Main->InitDev->SetVideoParamToDll 视频通道参数传入动态库完成,油枪数:" + Global.videoChanList.Count.ToString(), (int)EnumLogLevel.DEBUG)); }