| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.Runtime.InteropServices;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Windows.Forms;
- using System.Windows.Forms.DataVisualization.Charting;
- using System.Web.ClientServices;
- using UAS_MES.CustomControl.DataGrid_View;
- using UAS_MES.DataOperate;
- using UAS_MES.PublicForm;
- using UAS_MES.PublicMethod;
- using System.Net;
- using System.IO;
- using System.Reflection;
- using System.Threading;
- using UAS_MES.CustomControl;
- using System.IO.Ports;
- using System.Net.Sockets;
- namespace UAS_MES
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- //Com.PortName = "COM4";
- //Com.ReadTimeout = 5000;
- //Com.WriteTimeout = 5000;
- //Com.BaudRate = 9600;
- //Com.StopBits = StopBits.One;
- //Com.Parity = Parity.None;
- }
- [DllImport("WinIo64.dll")]
- public static extern bool InitializeWinIo();
- [DllImport("WinIo64.dll")]
- public static extern void ShutdownWinIo();
- [DllImport("WinIo64.dll")]
- public static extern bool GetPortVal(IntPtr wPortAddr, out int pdwPortVal, byte bSize);
- [DllImport("WinIo64.dll")]
- public static extern bool SetPortVal(IntPtr wPortAddr, int dwPortVal, byte bSize);
- //以下是与并口无关
- [DllImport("WinIo64.dll")]
- public static extern byte MapPhysToLin(byte pbPhysAddr, uint dwPhysSize, IntPtr PhysicalMemoryHandle);
- [DllImport("WinIo64.dll")]
- public static extern bool UnmapPhysicalMemory(IntPtr PhysicalMemoryHandle, byte pbLinAddr);
- [DllImport("WinIo64.dll")]
- public static extern bool GetPhysLong(IntPtr pbPhysAddr, byte pdwPhysVal);
- [DllImport("WinIo64.dll")]
- public static extern bool SetPhysLong(IntPtr pbPhysAddr, byte dwPhysVal);
- [DllImport("user32.dll")]
- public static extern int MapVirtualKey(uint Ucode, uint uMapType);
- public bool online = false; //WinIo打开标志
- //数据端口共8位,控制端口共4位,可以组成1~12位的任意数字输出端口;
- //状态端口共5位,控制端口共4位,可以组成1~9位的任意数字输入端口
- private static IntPtr data_port = (IntPtr)0x378; //数据端口地址 D0-D7 8个端口
- private static IntPtr state_port = (IntPtr)0x379; //状态端口地址 S3-S7 只能读取5位
- private static IntPtr control_port = (IntPtr)0x37A; //控制端口地址 C0-C3 只能控制或输出4位
- ModeBusTCPServer md;
- private void button3_Click_1(object sender, EventArgs e)
- {
- md = new ModeBusTCPServer(txtIP.Text, txtPORT.Text);
- md.Open();
- txtMsg.AppendText("SUCCESS");
- }
- private void button4_Click(object sender, EventArgs e)
- {
- md.SendOrder(enterTextBox2.Text);
- }
- }
- }
|