.idea/.idea.HH.WCS.Mobox3.AnGang/.idea/.gitignore | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
.idea/.idea.HH.WCS.Mobox3.AnGang/.idea/.name | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
.idea/.idea.HH.WCS.Mobox3.AnGang/.idea/encodings.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
.idea/.idea.HH.WCS.Mobox3.AnGang/.idea/indexLayout.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
.idea/.idea.HH.WCS.Mobox3.AnGang/.idea/vcs.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
.vs/HH.WCS.Mobox3.AnGang/FileContentIndex/231ebe09-1be5-4df5-9128-8244b1b888a7.vsidx | 补丁 | 查看 | 原始文档 | blame | 历史 | |
.vs/HH.WCS.Mobox3.AnGang/FileContentIndex/530fbb96-4d54-44a7-b144-9b0bd20dba28.vsidx | 补丁 | 查看 | 原始文档 | blame | 历史 | |
Program.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
api/ApiHelper.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
device/SnapDevice.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
device/SnapManager.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
process/TaskProcess.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
.idea/.idea.HH.WCS.Mobox3.AnGang/.idea/.gitignore
File was deleted .idea/.idea.HH.WCS.Mobox3.AnGang/.idea/.name
File was deleted .idea/.idea.HH.WCS.Mobox3.AnGang/.idea/encodings.xml
File was deleted .idea/.idea.HH.WCS.Mobox3.AnGang/.idea/indexLayout.xml
File was deleted .idea/.idea.HH.WCS.Mobox3.AnGang/.idea/vcs.xml
File was deleted .vs/HH.WCS.Mobox3.AnGang/FileContentIndex/231ebe09-1be5-4df5-9128-8244b1b888a7.vsidxBinary files differ
.vs/HH.WCS.Mobox3.AnGang/FileContentIndex/530fbb96-4d54-44a7-b144-9b0bd20dba28.vsidxBinary files differ
Program.cs
@@ -15,7 +15,7 @@ namespace HH.WCS.Mobox3.AnGang { internal class Program { //[STAThread] // TODO SNAP //[STAThread] // SNAP 注释该行保留其他行后,程序正常运行 static void Main(string[] args) { //基础设置信息初始化 api/ApiHelper.cs
@@ -556,7 +556,7 @@ var id = SYSHelper.GetSerialNumber(snType, prefix); var date = DateTime.Now.ToString("yyMMdd"); return $"{prefix}{date}{id.ToString().PadLeft(4, '0')}"; return $"{prefix}{date}-{id.ToString().PadLeft(5, '0')}"; // 形如:CN250525-00011 } /// <summary> device/SnapDevice.cs
@@ -7,14 +7,14 @@ using System.Text; using System.Threading.Tasks; //using NetSDKCS; // TODO SNAP using NetSDKCS; // SNAP namespace HH.WCS.Mobox3.AnGang.device { public class SnapDevice { private IntPtr _LoginID = IntPtr.Zero; private IntPtr _PlayID = IntPtr.Zero; //private fSnapRevCallBack _SnapRevCallBack; //private NET_DEVICEINFO_Ex _DeviceInfo = new NET_DEVICEINFO_Ex(); // TODO SNAP private NET_DEVICEINFO_Ex _DeviceInfo = new NET_DEVICEINFO_Ex(); // SNAP private bool _IsSpanCapture = false; //private List<int> _channalList = new List<int>(); @@ -23,7 +23,7 @@ public SnapDevice() { try { //_SnapRevCallBack = new fSnapRevCallBack(SnapRevCallBack); //NETClient.Init(null, IntPtr.Zero, null); // TODO SNAP NETClient.Init(null, IntPtr.Zero, null); // SNAP //NETClient.SetSnapRevCallBack(_SnapRevCallBack, IntPtr.Zero); } catch (Exception ex) { @@ -32,134 +32,134 @@ } ~SnapDevice() { //NETClient.Cleanup(); // TODO SNAP NETClient.Cleanup(); // SNAP } //public void LoadInfo(Config.Snap snap) { // LoadInfo(snap.Ip, snap.Port, snap.Name, snap.Pwd); //} // SNAP // TODO SNAP public void LoadInfo(Config.Snap snap) { LoadInfo(snap.Ip, snap.Port, snap.Name, snap.Pwd); } //public void LoadInfo(string ip, int port, string name, string pwd) { // if (IntPtr.Zero == _LoginID) { // ushort uPort = 0; // try { // uPort = Convert.ToUInt16(port); public void LoadInfo(string ip, int port, string name, string pwd) { if (IntPtr.Zero == _LoginID) { ushort uPort = 0; try { uPort = Convert.ToUInt16(port); } catch { LogHelper.Info("加载Snap:端口号格式错误"); return; } _LoginID = NETClient.LoginWithHighLevelSecurity(ip, uPort, name, pwd, EM_LOGIN_SPAC_CAP_TYPE.TCP, IntPtr.Zero, ref _DeviceInfo); if (IntPtr.Zero == _LoginID) { LogHelper.Info("相机初始化错误:" + NETClient.GetLastError()); return; } //_channalList.Clear(); //for (int i = 0; i < _DeviceInfo.nChanNum; i++) { // _channalList.Add(i + 1); // } // catch { // LogHelper.Info("加载Snap:端口号格式错误"); // return; // } // _LoginID = NETClient.LoginWithHighLevelSecurity(ip, uPort, name, pwd, EM_LOGIN_SPAC_CAP_TYPE.TCP, IntPtr.Zero, ref _DeviceInfo); // if (IntPtr.Zero == _LoginID) { // LogHelper.Info("相机初始化错误:" + NETClient.GetLastError()); // return; // } // //_channalList.Clear(); // //for (int i = 0; i < _DeviceInfo.nChanNum; i++) { // // _channalList.Add(i + 1); // //} // _channalMax = _DeviceInfo.nChanNum; // } // else { // NETClient.Logout(_LoginID); // _LoginID = IntPtr.Zero; // if (_IsSpanCapture) { // _IsSpanCapture = false; _channalMax = _DeviceInfo.nChanNum; } else { NETClient.Logout(_LoginID); _LoginID = IntPtr.Zero; if (_IsSpanCapture) { _IsSpanCapture = false; // } // } //} } } } //public bool SnapPictureToFileOK(ref string filePath, int channelIndex = 0) { // if (channelIndex >= _channalMax) { // LogHelper.Info($"通道数 '{channelIndex}' 超出通道总数 '{_channalMax}'"); // //filePath = string.Empty; // return false; // } public bool SnapPictureToFileOK(ref string filePath, int channelIndex = 0) { if (channelIndex >= _channalMax) { LogHelper.Info($"通道数 '{channelIndex}' 超出通道总数 '{_channalMax}'"); //filePath = string.Empty; return false; } // //DateTime now = DateTime.Now; // //string path = AppDomain.CurrentDomain.BaseDirectory + "image"; // //string fileName = string.Format("{0}{1}{2}{3}{4}{5}", now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second) + ".jpg"; // //filePath = path + "\\" + fileName; // NET_SNAP_PARAMS asyncSnap = new NET_SNAP_PARAMS(); // //asyncSnap.Channel = (uint)this._channalList[channelIndex]; // asyncSnap.Channel = (uint)channelIndex; // asyncSnap.Quality = 6; // asyncSnap.ImageSize = 2; // asyncSnap.mode = 0; // asyncSnap.InterSnap = 0; // NET_IN_SNAP_PIC_TO_FILE_PARAM inParam = new NET_IN_SNAP_PIC_TO_FILE_PARAM { // dwSize = (uint)Marshal.SizeOf(typeof(NET_IN_SNAP_PIC_TO_FILE_PARAM)), // stuParam = asyncSnap, // szFilePath = filePath, // }; // NET_OUT_SNAP_PIC_TO_FILE_PARAM outParam = new NET_OUT_SNAP_PIC_TO_FILE_PARAM() { // dwSize = (uint)Marshal.SizeOf(typeof(NET_OUT_SNAP_PIC_TO_FILE_PARAM)), // dwPicBufLen = 1024000, // szPicBuf = Marshal.AllocHGlobal(1024000), // }; // bool ret = NETClient.SnapPictureToFile(_LoginID, ref inParam, ref outParam, 1000); // if (!ret) { // LogHelper.Info("抓图失败"); // } // return ret; //} //public bool SnapPictureOk(int channelIndex = 0) { // if (channelIndex >= _channalMax) { // LogHelper.Info($"通道数 '{channelIndex}' 超出通道总数 '{_channalMax}'"); // return false; // } // NET_SNAP_PARAMS asyncSnap = new NET_SNAP_PARAMS(); // //asyncSnap.Channel = (uint)this._channalList[channelIndex]; // asyncSnap.Channel = (uint)channelIndex; // asyncSnap.Quality = 6; // asyncSnap.ImageSize = 2; // asyncSnap.mode = 0; // asyncSnap.InterSnap = 0; // bool ret = NETClient.SnapPictureEx(_LoginID, asyncSnap, IntPtr.Zero); // if (!ret) { // LogHelper.Info(NETClient.GetLastError()); // return false; // } // return true; //} //private void SnapRevCallBack(IntPtr lLoginID, IntPtr pBuf, uint RevLen, uint EncodeType, uint CmdSerial, IntPtr dwUser) { // string path = AppDomain.CurrentDomain.BaseDirectory + "image"; // if (!Directory.Exists(path)) { // Directory.CreateDirectory(path); // } // if (EncodeType == 10) //.jpg // { // DateTime now = DateTime.Now; // string fileName = string.Format("{0}-{1}-{2}-{3}-{4}-{5}", now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second) + ".jpg"; // string filePath = path + "\\" + fileName; // byte[] data = new byte[RevLen]; // Marshal.Copy(pBuf, data, 0, (int)RevLen); // try { // //when the file is operate by local capture will throw expection. // using (FileStream stream = new FileStream(filePath, FileMode.OpenOrCreate)) { // stream.Write(data, 0, (int)RevLen); // stream.Flush(); // stream.Dispose(); // } // } // catch (Exception ex) { // LogHelper.Info($"发生了异常:{ex.Message}"); // return; // } // // 替代Demo程序的Frame图片展示 // LogHelper.Info($"保存图片到:{filePath}"); // Process.Start(filePath); // } //} //string path = AppDomain.CurrentDomain.BaseDirectory + "image"; //string fileName = string.Format("{0}{1}{2}{3}{4}{5}", now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second) + ".jpg"; //filePath = path + "\\" + fileName; NET_SNAP_PARAMS asyncSnap = new NET_SNAP_PARAMS(); //asyncSnap.Channel = (uint)this._channalList[channelIndex]; asyncSnap.Channel = (uint)channelIndex; asyncSnap.Quality = 6; asyncSnap.ImageSize = 2; asyncSnap.mode = 0; asyncSnap.InterSnap = 0; NET_IN_SNAP_PIC_TO_FILE_PARAM inParam = new NET_IN_SNAP_PIC_TO_FILE_PARAM { dwSize = (uint)Marshal.SizeOf(typeof(NET_IN_SNAP_PIC_TO_FILE_PARAM)), stuParam = asyncSnap, szFilePath = filePath, }; NET_OUT_SNAP_PIC_TO_FILE_PARAM outParam = new NET_OUT_SNAP_PIC_TO_FILE_PARAM() { dwSize = (uint)Marshal.SizeOf(typeof(NET_OUT_SNAP_PIC_TO_FILE_PARAM)), dwPicBufLen = 1024000, szPicBuf = Marshal.AllocHGlobal(1024000), }; bool ret = NETClient.SnapPictureToFile(_LoginID, ref inParam, ref outParam, 1000); if (!ret) { LogHelper.Info("抓图失败"); } return ret; } public bool SnapPictureOk(int channelIndex = 0) { if (channelIndex >= _channalMax) { LogHelper.Info($"通道数 '{channelIndex}' 超出通道总数 '{_channalMax}'"); return false; } NET_SNAP_PARAMS asyncSnap = new NET_SNAP_PARAMS(); //asyncSnap.Channel = (uint)this._channalList[channelIndex]; asyncSnap.Channel = (uint)channelIndex; asyncSnap.Quality = 6; asyncSnap.ImageSize = 2; asyncSnap.mode = 0; asyncSnap.InterSnap = 0; bool ret = NETClient.SnapPictureEx(_LoginID, asyncSnap, IntPtr.Zero); if (!ret) { LogHelper.Info(NETClient.GetLastError()); return false; } return true; } private void SnapRevCallBack(IntPtr lLoginID, IntPtr pBuf, uint RevLen, uint EncodeType, uint CmdSerial, IntPtr dwUser) { string path = AppDomain.CurrentDomain.BaseDirectory + "image"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } if (EncodeType == 10) //.jpg { DateTime now = DateTime.Now; string fileName = string.Format("{0}-{1}-{2}-{3}-{4}-{5}", now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second) + ".jpg"; string filePath = path + "\\" + fileName; byte[] data = new byte[RevLen]; Marshal.Copy(pBuf, data, 0, (int)RevLen); try { //when the file is operate by local capture will throw expection. using (FileStream stream = new FileStream(filePath, FileMode.OpenOrCreate)) { stream.Write(data, 0, (int)RevLen); stream.Flush(); stream.Dispose(); } } catch (Exception ex) { LogHelper.Info($"发生了异常:{ex.Message}"); return; } // 替代Demo程序的Frame图片展示 LogHelper.Info($"保存图片到:{filePath}"); Process.Start(filePath); } } } } device/SnapManager.cs
@@ -11,24 +11,24 @@ if (_snapDevice == null) { _snapDevice = new SnapDevice(); } //_snapDevice.LoadInfo(snap); // TODO SNAP _snapDevice.LoadInfo(snap); // SNAP } public static string GetCapturePicturePath() { //DateTime now = DateTime.Now; //string path = Settings.CaptureUrl; //string fileName = string.Format("{0}{1}{2}{3}{4}{5}", now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second) + ".jpg"; //string filePath = path + "\\" + fileName; //if (_snapDevice.SnapPictureToFileOK(ref filePath)) { // return filePath; //} //else { // return string.Empty; //} // SNAP // TODO SNAP DateTime now = DateTime.Now; string path = Settings.CaptureUrl; string fileName = string.Format("{0}{1}{2}{3}{4}{5}", now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second) + ".jpg"; string filePath = path + "\\" + fileName; if (_snapDevice.SnapPictureToFileOK(ref filePath)) { return filePath; } else { return string.Empty; } } } } process/TaskProcess.cs
@@ -111,68 +111,7 @@ var start = "0"; var end = "0"; var taskType = mst.S_TYPE.Trim(); if (mst.N_B_STATE == 0) { if (mst.N_SCHEDULE_TYPE == 1)//通过NDC,hosttoagv调度设备 { start = LocationHelper.GetAgvSite(mst.S_START_LOC); end = LocationHelper.GetAgvSite(mst.S_END_LOC); //if (mst.S_TYPE == "空托下线堆叠") { // end = LocationHelper.GetAgvSite(mst.S_END_LOC, true); //} LogHelper.Info($"NDC推送任务 {mst.S_CODE};" + "start=" + start + "end= " + end); var startLoc = LocationHelper.GetLoc(mst.S_START_LOC); var endLoc = LocationHelper.GetLoc(mst.S_END_LOC); var dic = new List<param>(); dic.Add(new param() { name = "IKey", value = "IKey" }); dic.Add(new param() { name = "From", value = start.ToString() }); dic.Add(new param() { name = "To", value = end.ToString() }); dic.Add(new param() { name = "FUNC", value = startLoc.N_LAYER.ToString() }); dic.Add(new param() { name = "Ctype", value = "0" }); //if (mst.S_TYPE == "余料下线入库" || mst.S_TYPE == "人工拆盘入库") { // dic.Add(new param() { name = "DATA", value = "1024" }); //} //else { // dic.Add(new param() { name = "DATA", value = "0" }); //} var res = NDCApi.AddOrderNew(1, 1, mst.S_CODE, dic);//添加新命令 if (res != null && (res.err_code == 0 || res.err_code == 50009)) { //推送成功,修改任务优先级 mst.N_B_STATE = 1; mst.S_B_STATE = TN_Task.GetStateStr(1); WCSHelper.UpdateStatus(mst);//更新任务状态 result = true; LogHelper.Info($"NDC推送任务成功 {mst.S_CODE}start= {mst.S_START_LOC} + end = {mst.S_END_LOC}"); } else { LogHelper.Info($"NDC推送任务失败 {mst.S_CODE};Res:" + JsonConvert.SerializeObject(res)); } } else if (mst.N_SCHEDULE_TYPE == 5)//通过杭奥调度设备 { //调第三方接口 var model = new HanAo.TaskInfoModel { requestPk = mst.S_CODE, frmPos = mst.S_START_LOC, toPos = mst.S_END_LOC, trkType = mst.S_OP_NAME == "入库" ? "1" : "2", contNo = mst.S_CNTR_CODE }; if (HanAo.CreateOrder(model)) { mst.N_B_STATE = 1; WCSHelper.UpdateStatus(mst); LogHelper.Info($"杭奥推送任务成功 {mst.S_CODE};" + "start=" + model.frmPos + "end= " + model.toPos); } else { LogHelper.Info($"杭奥推送任务失败 {mst.S_CODE};" + JsonConvert.SerializeObject(model)); } } else if (mst.N_SCHEDULE_TYPE == 3) //通过国自调度设备 { var code = GZRobot.CreateOrder(mst.S_CODE, mst.N_PRIORITY, JsonConvert.SerializeObject(new { src = mst.S_START_LOC, dst = mst.S_END_LOC }), "p2p"); if (code > 0) { //更新任务状态 @@ -185,7 +124,82 @@ else { LogHelper.Info($"国自推送任务失败 {mst.S_CODE};" + JsonConvert.SerializeObject(mst)); } } //if (mst.N_SCHEDULE_TYPE == 1)//通过NDC,hosttoagv调度设备 //{ // start = LocationHelper.GetAgvSite(mst.S_START_LOC); // end = LocationHelper.GetAgvSite(mst.S_END_LOC); // //if (mst.S_TYPE == "空托下线堆叠") { // // end = LocationHelper.GetAgvSite(mst.S_END_LOC, true); // //} // LogHelper.Info($"NDC推送任务 {mst.S_CODE};" + "start=" + start + "end= " + end); // var startLoc = LocationHelper.GetLoc(mst.S_START_LOC); // var endLoc = LocationHelper.GetLoc(mst.S_END_LOC); // var dic = new List<param>(); // dic.Add(new param() { name = "IKey", value = "IKey" }); // dic.Add(new param() { name = "From", value = start.ToString() }); // dic.Add(new param() { name = "To", value = end.ToString() }); // dic.Add(new param() { name = "FUNC", value = startLoc.N_LAYER.ToString() }); // dic.Add(new param() { name = "Ctype", value = "0" }); // //if (mst.S_TYPE == "余料下线入库" || mst.S_TYPE == "人工拆盘入库") { // // dic.Add(new param() { name = "DATA", value = "1024" }); // //} // //else { // // dic.Add(new param() { name = "DATA", value = "0" }); // //} // var res = NDCApi.AddOrderNew(1, 1, mst.S_CODE, dic);//添加新命令 // if (res != null && (res.err_code == 0 || res.err_code == 50009)) { // //推送成功,修改任务优先级 // mst.N_B_STATE = 1; // mst.S_B_STATE = TN_Task.GetStateStr(1); // WCSHelper.UpdateStatus(mst);//更新任务状态 // result = true; // LogHelper.Info($"NDC推送任务成功 {mst.S_CODE}start= {mst.S_START_LOC} + end = {mst.S_END_LOC}"); // } // else { // LogHelper.Info($"NDC推送任务失败 {mst.S_CODE};Res:" + JsonConvert.SerializeObject(res)); // } //} //else if (mst.N_SCHEDULE_TYPE == 5)//通过杭奥调度设备 //{ // //调第三方接口 // var model = new HanAo.TaskInfoModel { // requestPk = mst.S_CODE, // frmPos = mst.S_START_LOC, // toPos = mst.S_END_LOC, // trkType = mst.S_OP_NAME == "入库" ? "1" : "2", // contNo = mst.S_CNTR_CODE // }; // if (HanAo.CreateOrder(model)) { // mst.N_B_STATE = 1; // WCSHelper.UpdateStatus(mst); // LogHelper.Info($"杭奥推送任务成功 {mst.S_CODE};" + "start=" + model.frmPos + "end= " + model.toPos); // } // else { // LogHelper.Info($"杭奥推送任务失败 {mst.S_CODE};" + JsonConvert.SerializeObject(model)); // } //} //else if (mst.N_SCHEDULE_TYPE == 3) //通过国自调度设备 //{ // var code = GZRobot.CreateOrder(mst.S_CODE, mst.N_PRIORITY, JsonConvert.SerializeObject(new { src = mst.S_START_LOC, dst = mst.S_END_LOC }), "p2p"); // if (code > 0) { // //更新任务状态 // mst.N_B_STATE = 1; // mst.S_EQ_TASK_CODE = code.ToString(); // WCSHelper.UpdateStatus(mst); // WCSHelper.UpdateEQNo(mst); // LogHelper.Info($"国自推送任务成功 {mst.S_CODE};" + "start=" + mst.S_START_LOC + "end= " + mst.S_END_LOC); // } // else { // LogHelper.Info($"国自推送任务失败 {mst.S_CODE};" + JsonConvert.SerializeObject(mst)); // } //} } return result;