فهرست منبع

添加松下PLC数据读取

callm 1 روز پیش
والد
کامیت
18420d8ed0
4فایلهای تغییر یافته به همراه36 افزوده شده و 16 حذف شده
  1. 4 0
      FileWatcher/FileWatcher.csproj
  2. 31 15
      FileWatcher/Form1.cs
  3. 1 1
      FileWatcher/Program.cs
  4. BIN
      FileWatcher/tool/HslCommunication.dll

+ 4 - 0
FileWatcher/FileWatcher.csproj

@@ -65,6 +65,10 @@
     <Reference Include="ExcelNumberFormat, Version=1.1.0.0, Culture=neutral, PublicKeyToken=23c6f5d73be07eca, processorArchitecture=MSIL">
       <HintPath>..\packages\ExcelNumberFormat.1.1.0\lib\net20\ExcelNumberFormat.dll</HintPath>
     </Reference>
+    <Reference Include="HslCommunication, Version=12.5.3.0, Culture=neutral, PublicKeyToken=3d72ad3b6b5ec0e3, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>tool\HslCommunication.dll</HintPath>
+    </Reference>
     <Reference Include="Interop.SpeechLib">
       <HintPath>..\UAS_MES_XCX\Tool\Interop.SpeechLib.dll</HintPath>
       <EmbedInteropTypes>True</EmbedInteropTypes>

+ 31 - 15
FileWatcher/Form1.cs

@@ -1,4 +1,5 @@
-using Microsoft.Win32;
+using HslCommunication;
+using Microsoft.Win32;
 using System;
 using System.Collections.Generic;
 using System.Data;
@@ -19,22 +20,37 @@ namespace FileWatcher
 
         private void Form1_Load(object sender, EventArgs e)
         {
-            FileWatcher.Path = @"D:\";
-            FileWatcher.Filter = "*.*";
-            FileWatcher.EnableRaisingEvents = true;
-            FileWatcher.Created += new FileSystemEventHandler(Watcher_Created);
+            HslCommunication.Profinet.Panasonic.PanasonicMewtocol plc = new HslCommunication.Profinet.Panasonic.PanasonicMewtocol();
+            plc.Station = 238;
+            HslCommunication.Core.Pipe.PipeSerialPort pipe = new HslCommunication.Core.Pipe.PipeSerialPort();
+            pipe.SerialPortInni("COM12-9600-8-O-1");
+            pipe.RtsEnable = false;
+            pipe.DtrEnable = false;
+            pipe.SleepTime = 20;
+            pipe.ReceiveTimeOut = 5000;
+            plc.CommunicationPipe = pipe;
 
-            string path = Application.ExecutablePath;
-            RegistryKey rk = Registry.LocalMachine;
-            RegistryKey rk2 = rk.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
-            rk2.SetValue("FileWatcher.exe", path);
-            rk2.Close();
-            rk.Close();
-            timer1.Interval = 1000 * 10;
-            timer1.Start();
+            // 当前读取操作的代码 The code for the current read operation
+            OperateResult<short> read = plc.ReadInt16("D60");
+            if (read.IsSuccess)
+            {
+                Console.WriteLine("Read [D60] Success, Value: " + read.Content);
+            }
+            else
+            {
+                Console.WriteLine("Read [D60] failed: " + read.Message);
+            }
 
-            timer2.Interval = 1000 * 60 * 60;
-            timer2.Start();
+            // 当前写入操作的代码 The code for the current write operation
+            OperateResult write = plc.Write("D60", short.Parse("2"));
+            if (write.IsSuccess)
+            {
+                Console.WriteLine("Write [D60] success");
+            }
+            else
+            {
+                Console.WriteLine("Write [D60] failed: " + write.Message);
+            }
 
         }
 

+ 1 - 1
FileWatcher/Program.cs

@@ -48,7 +48,7 @@ namespace FileWatcher
                 {
                     //Application.Run(new UploadMakePlan());
                     //Application.Run(new AutoAnalysisXmlByStep());
-                    Application.Run(new AutoSMTRXY());
+                    Application.Run(new AutoAnalysisDevice());
                 }
                 else
                 {

BIN
FileWatcher/tool/HslCommunication.dll