|
|
@@ -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);
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|