Просмотр исходного кода

fix:增加机床探头数据读取

wang.sq@aliyun.com 4 месяцев назад
Родитель
Сommit
b5d53aca49
2 измененных файлов с 49 добавлено и 6 удалено
  1. 47 5
      HEIDENHAIN/Form1.cs
  2. 2 1
      HEIDENHAIN/body/RequestBody.cs

+ 47 - 5
HEIDENHAIN/Form1.cs

@@ -246,9 +246,11 @@ namespace HEIDENHAIN
                                     string sSelectedFile = Path.GetFileName(hdhBody.Path);
                                     string dncPath = null;
                                     string tempDncPath = RemotePath + "\\2.h";
+                                    //防止地址内容累加
+                                    string newRemotePath = null;
                                     if (hdhBody.Address != "")
                                     {
-                                        RemotePath = RemotePath + "\\" + hdhBody.Address;
+                                        newRemotePath = RemotePath + "\\" + hdhBody.Address;
                                     }
                                     //上传
                                     dncPath = GenPath(RemotePath, sSelectedFile);
@@ -261,6 +263,9 @@ namespace HEIDENHAIN
                                     catch (Exception edel)
                                     {
                                     }
+
+                                    YG.Log.Instance.WriteLogAdd($"海德汉nc上传位置--->>" + dncPath, "海德汉nc上传");
+
                                     //上传
                                     m_FileSystem.TransmitFile(hdhBody.Path, dncPath);
                                     //设当前上传程序为主程序
@@ -280,6 +285,8 @@ namespace HEIDENHAIN
                                     JHAutomatic m_Automatic = Machine.GetInterface(DNC_INTERFACE_OBJECT.DNC_INTERFACE_JHAUTOMATIC);
 
                                     string dncPath = GenPath(RemotePath, hdhBody.Path);
+
+                                    YG.Log.Instance.WriteLogAdd($"海德汉设置nc--->>" + dncPath, "海德汉机床nc设置");
                                     m_Automatic.SelectProgram(iChannel, dncPath);
                                 }
                                 else if (hdhBody.Type == ActionTypeEnum.StartNcProgram.ToString())//启动程序备用
@@ -289,7 +296,10 @@ namespace HEIDENHAIN
 
                                     //m_Automatic.SelectProgram(iChannel, GenPath(RemotePath, hdhBody.Path));
                                     //Thread.Sleep(1000);
-                                    m_Automatic.StartProgram(GenPath(RemotePath, hdhBody.Path));
+                                    string sSelectedFile = Path.GetFileName(hdhBody.Path);
+                                    string bstrProgramName = GenPath(RemotePath, sSelectedFile);
+                                    YG.Log.Instance.WriteLogAdd($"海德汉执行启动--->>" + bstrProgramName, "海德汉机床启动");
+                                    m_Automatic.StartProgram(bstrProgramName);
                                 }
                                 else if (hdhBody.Type == ActionTypeEnum.Read.ToString())
                                 {
@@ -313,7 +323,7 @@ namespace HEIDENHAIN
                                     IJHDataEntry2List ToolLines = ToolTable.GetChildList();
                                     int ToolLinesCount = ToolLines.Count >= 50 ? 50 : ToolLines.Count;
                                     //int ToolLinesCount = ToolLines.Count;                                    
-                                    
+
                                     for (int i = 0; i < ToolLinesCount; i++)
                                     {
                                         ToolLine = ToolLines[i];
@@ -352,13 +362,13 @@ namespace HEIDENHAIN
                                     JObject jsonObject = JObject.Parse(hdhBody.CutterData);
 
 
-                                    
+
                                     JHDataAccess dataAccess = Machine.GetInterface(HeidenhainDNCLib.DNC_INTERFACE_OBJECT.DNC_INTERFACE_JHDATAACCESS);
                                     dataAccess.SetAccessMode(DNC_ACCESS_MODE.DNC_ACCESS_MODE_TABLEDATAACCESS, "");
 
                                     /*刀具表数据修改*/
                                     //刀具表查询语句
-                                    string ToolColumnNamesAccessor = @"\TABLE\TOOL\T\"+ jsonObject.GetValue("cutterT");
+                                    string ToolColumnNamesAccessor = @"\TABLE\TOOL\T\" + jsonObject.GetValue("cutterT");
                                     //刀具表数据
                                     IJHDataEntry2 ToolTable = dataAccess.GetDataEntry2(ToolColumnNamesAccessor, DNC_DATA_UNIT_SELECT.DNC_DATA_UNIT_SELECT_METRIC, false);
                                     // 获取字段列表
@@ -418,6 +428,38 @@ namespace HEIDENHAIN
 
                                     responseBody.msg = "数据设置成功";
                                     responseBody.result = true;
+                                } else if (hdhBody.Type == ActionTypeEnum.ReadProbeData.ToString())
+                                {
+                                    IJHDataEntry2 ToolLine = null;
+                                    IJHDataEntry2List ToolCells = null;
+                                    JHDataAccess dataAccess = Machine.GetInterface(HeidenhainDNCLib.DNC_INTERFACE_OBJECT.DNC_INTERFACE_JHDATAACCESS);
+                                    dataAccess.SetAccessMode(DNC_ACCESS_MODE.DNC_ACCESS_MODE_TABLEDATAACCESS, "");
+
+                                    /*探头检测结果表数据修改*/
+                                    //探头检测结果表查询语句
+                                    string ToolColumnNamesAccessor = @"\TABLE\TOOL_P\P\('1'-'50')";
+                                    //探头检测结果表数据
+                                    IJHDataEntry2 ToolTable = dataAccess.GetDataEntry2(ToolColumnNamesAccessor, DNC_DATA_UNIT_SELECT.DNC_DATA_UNIT_SELECT_METRIC, false);
+                                    // 获取字段列表
+                                    IJHDataEntry2List ToolLines = ToolTable.GetChildList();
+                                    int ToolLinesCount = ToolLines.Count >= 50 ? 50 : ToolLines.Count;
+                                    for (int i = 0; i < ToolLinesCount; i++)
+                                    {
+                                        ToolLine = ToolLines[i];
+                                        ToolCells = ToolLine.GetChildList();
+                                        // get child list from server                                       
+                                        ToolsInfo toolsInfo = new ToolsInfo();
+
+                                        //刀位编码
+                                        int[] pCode = ToolCells[0].GetPropertyValue(DNC_DATAENTRY_PROPKIND.DNC_DATAENTRY_PROPKIND_DATA);
+                                        toolsInfo.position = string.Join(".", pCode);
+                                        toolsInfo.number = ToolCells[1].GetPropertyValue(DNC_DATAENTRY_PROPKIND.DNC_DATAENTRY_PROPKIND_DATA).ToString();
+                                        toolsInfo.name = ToolCells[2].GetPropertyValue(DNC_DATAENTRY_PROPKIND.DNC_DATAENTRY_PROPKIND_DATA).ToString();
+
+
+                                        YG.Log.Instance.WriteLogAdd($"海德汉读取探头检测数据--->>" + JsonConvert.SerializeObject(toolsInfo), "海德汉机床探头检测数据");
+                                    }
+
                                 }
                             }
                             else

+ 2 - 1
HEIDENHAIN/body/RequestBody.cs

@@ -39,6 +39,7 @@ namespace IMCS.HeidenHain
         StartNcProgram,
         DeleteNc,
         ToolList,
-        ReadAndWriteTool
+        ReadAndWriteTool,
+        ReadProbeData
     }
  }