lxb 1 year ago
parent
commit
c8c168f6c6

+ 1 - 1
deviceHttpServer/hedidenain/HeidenhainServer.cs

@@ -22,7 +22,7 @@ namespace Fanuc_HttpServer.hedidenain
         //连接设备列表
         public Dictionary<string, DNC_STATE> deviceList { get; set; } = new Dictionary<string, DNC_STATE>();
         private DNC_STATE m_ControlState;
-        public Dictionary<string, JHMachineInProcess> machineList { get; set; } = new Dictionary<string, JHMachineInProcess>();
+        public static Dictionary<string, JHMachineInProcess> machineList { get; set; } = new Dictionary<string, JHMachineInProcess>();
         public ResponseBody requestHttpServer(RequestBody requestBody)
         {
             string ip = requestBody.serverUrl;

+ 25 - 2
deviceHttpServer/mitsubishi/EZSockets/MitCom.cs

@@ -6,6 +6,8 @@ using System.Windows.Forms;
 using System.Data.Common;
 using System.IO;
 using Common;
+using EZNCAUTLib;
+using RequestServer.HttpServer;
 
 namespace EZSockets
 {
@@ -15,12 +17,19 @@ namespace EZSockets
     public class MitCom
     {
         private EZNCAUTLib.DispEZNcCommunication EZNcCom;//通讯库变量
-       
+        private EZNCAUTLib.DispEZNcCommunication EZNcCom106;
+        private EZNCAUTLib.DispEZNcCommunication EZNcCom107;
+        public static Dictionary<string, DispEZNcCommunication> deviceList { get; set; } = new Dictionary<string, DispEZNcCommunication>();
+        
         private int lResult=1;
         private int lSystemType;
         private string szMessage;
         public event Common.MyDelegate<string, string> AlarmData;//声明事件
         Random x = new Random();
+        public MitCom(string ipAdress)
+        { 
+           // EZNcCom = deviceList.Where(m => m.Key == ipAdress).FirstOrDefault().Value;
+        }
 
         /// <summary>
         /// 连接三菱设备
@@ -32,6 +41,8 @@ namespace EZSockets
             int lMachine;
             int lTimeOut;
             string strHostName;
+            
+
             if (EZNcCom == null)
             {
                 EZNcCom = new EZNCAUTLib.DispEZNcCommunication();
@@ -107,6 +118,7 @@ namespace EZSockets
                     {
                         lResultOpen = EZNcCom.Open2(lSystemType, lMachine, lTimeOut, "EZNC_LOCALHOST");//EZNC_LOCALHOST
                         lResult = lResultOpen;
+                        deviceList.Add(ipAdress, EZNcCom);
                         ErrorCheck("Open");
                     }
                 }
@@ -125,7 +137,18 @@ namespace EZSockets
 
             }
         }
-
+        public void SimClose()
+        {
+             if(EZNcCom != null)
+            {
+                lResult = EZNcCom.Close();
+                ErrorCheck("Close");
+            }
+            
+           
+            EZNcCom = null;
+            
+        }
         /// <summary>
         /// 获取版本号
         /// IAxistNo:设置轴号(从轴1 =从1)

+ 7 - 5
deviceHttpServer/mitsubishi/MitsubishiServer.cs

@@ -15,6 +15,7 @@ namespace HttpServer.mitsubishi
     {
         private static string ON_LINE_STATE = "在线";
         public static Dictionary<string, MitCom> deviceList { get; set; } = new Dictionary<string, MitCom>();
+       
         public static ResponseBody requestHttpServer(RequestBody requestBody)
         {
             string ip = requestBody.serverUrl;
@@ -22,9 +23,9 @@ namespace HttpServer.mitsubishi
             string fun = requestBody.type; 
             
             ResponseBody responseBody = new ResponseBody();
-            MitCom mitCom = null;
-            //先ping
-            Ping pingSender = new Ping();
+               MitCom mitCom = null;
+        //先ping
+        Ping pingSender = new Ping();
             PingReply reply = pingSender.Send(requestBody.serverUrl);
             if (reply.Status != IPStatus.Success)
             {
@@ -37,9 +38,9 @@ namespace HttpServer.mitsubishi
                 {
                     try
                     {
-                        mitCom = new MitCom();
+                        mitCom = new MitCom(requestBody.serverUrl);
                         mitCom.GetSimConnect("M700M", "1", "10", requestBody.serverUrl);
-                        deviceList.Add(requestBody.serverUrl, mitCom);
+                        //deviceList.Add(requestBody.serverUrl, mitCom); 
                         responseBody.deviceState = ON_LINE_STATE;
                     }
                     catch (Exception e)
@@ -83,6 +84,7 @@ namespace HttpServer.mitsubishi
                             //mitCom.GetParaValue(30, 8002, 1, 1, out pvValue);
                             int runTime;
                             mitCom.GetRunTime(out runTime);
+                            mitCom.SimClose();
                             responseBody.powerOnTime = (runTime/60).ToString();
                         }
                     }

+ 3 - 2
deviceHttpServer/opcua/OpcUaServer.cs

@@ -22,7 +22,7 @@ namespace Fanuc_HttpServer.opcuaserver
         private uint currentToolArea = 1;
         private static string ON_LINE_STATE = "在线";
         Server opcServer = null;
-        public Dictionary<string, Server> deviceList { get; set; } = new Dictionary<string, Server>();
+        public static Dictionary<string, Server> deviceList { get; set; } = new Dictionary<string, Server>();
         public ResponseBody requestHttpServer(RequestBody requestBody)
         {
             string ip = requestBody.serverUrl;
@@ -74,7 +74,8 @@ namespace Fanuc_HttpServer.opcuaserver
                     {
                         
                         List<string> addresses = new List<string>();
-                        addresses.Add("ns=2;s=/Channel/GeometricAxis/actFeedRate"); //进给倍率
+                        //addresses.Add("ns=2;s=/Channel/GeometricAxis/feedRateOvr"); //进给倍率
+                        addresses.Add("ns=2;s=/Channel/State/acFZ"); //进给速度
                         addresses.Add("ns=2;s=/Channel/Spindle/speedOvr");//主轴倍率
                         addresses.Add("ns=2;s=/Channel/Spindle/actSpeed");//主轴实际速度
                         addresses.Add("ns=2;s=/Channel/Spindle/driveLoad");//主轴负载