static void Main(string[] args) { IServer server = new ServerManager().CreateServer(new ServerConfig() { ServerName = "服务1", ComReadTimeout = 1000, ComWriteTimeout = 1000, NetReceiveTimeout = 1000, NetSendTimeout = 1000, ControlMode = ControlMode.Parallel, SocketMode = SocketMode.Tcp, ReceiveDataFliter = false, ClearSocketSession = false, CheckPackageLength = false, CheckSameSocketSession = false, DeliveryMode = DeliveryMode.DeviceIP, ParallelInterval = 1000 }); server.SocketConnected += server_SocketConnected; server.SocketClosed += server_SocketClosed; server.AddDeviceCompleted += server_AddDeviceCompleted; server.DeleteDeviceCompleted += server_DeleteDeviceCompleted; server.Start(); string devCode = "0"; DeviceDriver dev1 = new DeviceDriver(); dev1.DeviceParameter.DeviceName = "设备驱动" + devCode.ToString(); dev1.DeviceParameter.DeviceAddr = int.Parse(devCode); dev1.DeviceParameter.DeviceCode = devCode.ToString(); dev1.DeviceParameter.DeviceID = devCode.ToString(); dev1.DeviceDynamic.DeviceID = devCode.ToString(); dev1.DeviceParameter.NET.RemoteIP = "127.0.0.1"; dev1.DeviceParameter.NET.RemotePort = 9600; dev1.CommunicateType = CommunicateType.NET; dev1.Initialize(devCode.ToString()); server.AddDevice(dev1); //devCode = "1"; //DeviceDriver dev2 = new DeviceDriver(); //dev2.DeviceParameter.DeviceName = "设备驱动" + devCode.ToString(); //dev2.DeviceParameter.DeviceAddr = int.Parse(devCode); //dev2.DeviceParameter.DeviceCode = devCode.ToString(); //dev2.DeviceParameter.DeviceID = devCode.ToString(); //dev2.DeviceDynamic.DeviceID = devCode.ToString(); //dev2.DeviceParameter.NET.RemoteIP = "192.168.1.102"; //dev2.DeviceParameter.NET.RemotePort = 9600; //dev2.CommunicateType = CommunicateType.NET; //dev2.Initialize(devCode.ToString()); //server.AddDevice(dev2); while ("exit" == Console.ReadLine()) { server.Stop(); } }
static void Main(string[] args) { string devid = "899d716b-59b7-4b9f-89d7-181017fe897c"; DeviceDriver dev1 = new DeviceDriver(); dev1.DeviceParameter.DeviceName = "串口设备1"; dev1.DeviceParameter.DeviceAddr = 0; dev1.DeviceParameter.DeviceID = devid; dev1.DeviceParameter.DeviceCode = "0"; dev1.DeviceDynamic.DeviceID = devid; dev1.DeviceParameter.COM.Port = 1; dev1.DeviceParameter.COM.Baud = 9600; dev1.DeviceParameter.COM.Baud = 8; dev1.DeviceParameter.COM.StopBits = System.IO.Ports.StopBits.One; dev1.DeviceParameter.COM.Parity = System.IO.Ports.Parity.None; dev1.CommunicateType = CommunicateType.COM; dev1.Initialize(devid); //DeviceDriver dev2 = new DeviceDriver(); //dev2.DeviceParameter.DeviceName = "设备2"; //dev2.DeviceParameter.DeviceAddr = 0; //dev2.DeviceParameter.DeviceID = 1; //dev2.DeviceDynamic.DeviceID = 1; //dev2.DeviceParameter.COM.Port = 3; //dev2.DeviceParameter.COM.Baud = 9600; //dev2.CommunicateType = CommunicateType.COM; //dev2.Initialize(1); string deviceID = "0"; //DeviceSelfDriver dev = new DeviceSelfDriver(); //dev.DeviceParameter.DeviceName = "设备2"; //dev.DeviceParameter.DeviceAddr = 0; //dev.DeviceParameter.DeviceID = deviceID; //dev.DeviceParameter.DeviceCode = deviceID; //dev.DeviceDynamic.DeviceID = deviceID; //dev.DeviceParameter.NET.RemoteIP = "127.0.0.1"; //dev.DeviceParameter.NET.RemotePort = 9600; //dev.DeviceParameter.NET.ControllerGroup = "G2"; //dev.CommunicateType = CommunicateType.NET; //dev.DeviceParameter.NET.WorkMode = WorkMode.TcpServer; //dev.Initialize(deviceID); deviceID = "2"; DeviceDriver dev3 = new DeviceDriver(); dev3.DeviceParameter.DeviceName = "设备2"; dev3.DeviceParameter.DeviceAddr = 0; dev3.DeviceParameter.DeviceID = deviceID; dev3.DeviceParameter.DeviceCode = deviceID; dev3.DeviceDynamic.DeviceID = deviceID; dev3.DeviceParameter.NET.RemoteIP = "127.0.0.1"; dev3.DeviceParameter.NET.RemotePort = 9600; dev3.DeviceParameter.NET.ControllerGroup = "G"; dev3.CommunicateType = CommunicateType.NET; dev3.DeviceParameter.NET.WorkMode = WorkMode.TcpServer; dev3.Initialize(deviceID); deviceID = "3"; DeviceDriver dev4 = new DeviceDriver(); dev4.DeviceParameter.DeviceName = "设备3"; dev4.DeviceParameter.DeviceAddr = 0; dev4.DeviceParameter.DeviceID = deviceID; dev4.DeviceParameter.DeviceCode = "0"; dev4.DeviceDynamic.DeviceID = deviceID; dev4.DeviceParameter.NET.RemoteIP = "127.0.0.1"; dev4.DeviceParameter.NET.RemotePort = 9600; dev4.DeviceParameter.NET.ControllerGroup = "G"; dev4.CommunicateType = CommunicateType.NET; dev4.Initialize(deviceID); IServer server = new ServerManager().CreateServer(new ServerConfig() { ServerName = "服务1", ComReadTimeout = 1000, ComWriteTimeout = 1000, NetReceiveTimeout = 1000, NetSendTimeout = 1000, ControlMode = ControlMode.Loop, SocketMode = SocketMode.Tcp, DeliveryMode = DeliveryMode.DeviceCode, ReceiveDataFliter = true, ClearSocketSession = true, CheckPackageLength = false, CheckSameSocketSession = false, }); server.AddDeviceCompleted += server_AddDeviceCompleted; server.DeleteDeviceCompleted += server_DeleteDeviceCompleted; server.SocketConnected += server_SocketConnected; server.SocketClosed += server_SocketClosed; server.Start(); server.AddDevice(dev1); // server.AddDevice(dev2); //server.AddDevice(dev3); server.AddDevice(dev4); //server.RemoveDevice(3);//删除设备 //ServerSuperIO.ControlDeviceService.ControlService service = new ServerSuperIO.ControlDeviceService.ControlService(); //service.IsAutoStart = true; //server.AddService(service); while ("exit" == Console.ReadLine()) { server.Stop(); } }
private static void Main(string[] args) { DeviceDriver dev1 = new DeviceDriver(); dev1.DeviceParameter.DeviceName = "串口设备1"; dev1.DeviceParameter.DeviceAddr = 0; dev1.DeviceParameter.DeviceID = "0"; dev1.DeviceParameter.DeviceCode = "0"; dev1.DeviceDynamic.DeviceID = "0"; dev1.DeviceParameter.COM.Port = 1; dev1.DeviceParameter.COM.Baud = 9600; dev1.CommunicateType = CommunicateType.COM; dev1.Initialize("0"); //DeviceDriver dev2 = new DeviceDriver(); //dev2.DeviceParameter.DeviceName = "设备2"; //dev2.DeviceParameter.DeviceAddr = 0; //dev2.DeviceParameter.DeviceID = 1; //dev2.DeviceDynamic.DeviceID = 1; //dev2.DeviceParameter.COM.Port = 3; //dev2.DeviceParameter.COM.Baud = 9600; //dev2.CommunicateType = CommunicateType.COM; //dev2.Initialize(1); //DeviceDriver dev3 = new DeviceDriver(); //dev3.DeviceParameter.DeviceName = "设备3"; //dev3.DeviceParameter.DeviceAddr = 0; //dev3.DeviceParameter.DeviceID = 2; //dev3.DeviceDynamic.DeviceID = 2; //dev3.DeviceParameter.NET.RemoteIP = "127.0.0.1"; //dev3.DeviceParameter.NET.RemotePort = 9600; //dev3.CommunicateType = CommunicateType.NET; //dev3.DeviceParameter.NET.WorkMode = WorkMode.TcpClient; //dev3.Initialize(2); DeviceDriver dev4 = new DeviceDriver(); dev4.DeviceParameter.DeviceName = "网络设备2"; dev4.DeviceParameter.DeviceAddr = 0; dev4.DeviceParameter.DeviceID = "3"; dev4.DeviceDynamic.DeviceID = "3"; dev4.DeviceParameter.NET.RemoteIP = "127.0.0.1"; dev4.DeviceParameter.NET.RemotePort = 9600; dev4.CommunicateType = CommunicateType.NET; dev4.Initialize("3"); IServer server = new ServerManager().CreateServer(new ServerConfig() { ServerName = "服务1", ComReadTimeout = 1000, ComWriteTimeout = 1000, NetReceiveTimeout = 1000, NetSendTimeout = 1000, ControlMode = ControlMode.Loop, SocketMode = SocketMode.Tcp, StartReceiveDataFliter = false, ClearSocketSession = false, StartCheckPackageLength = false, CheckSameSocketSession = false, }); server.AddDeviceCompleted += server_AddDeviceCompleted; server.DeleteDeviceCompleted += server_DeleteDeviceCompleted; server.SocketConnected += server_SocketConnected; server.SocketClosed += server_SocketClosed; server.Start(); server.AddDevice(dev1); //server.AddDevice(dev2); //server.AddDevice(dev3); // server.AddDevice(dev4); //server.RemoveDevice(3);//删除设备 TestService.Service service = new TestService.Service(); server.AddService(service); while ("exit" == Console.ReadLine()) { server.Stop(); } }
static void Main(string[] args) { //DeviceDriver dev1 = new DeviceDriver(); //dev1.DeviceParameter.DeviceName = "设备1"; //dev1.DeviceParameter.DeviceAddr = 0; //dev1.DeviceParameter.DeviceID = 0; //dev1.DeviceDynamic.DeviceID = 0; //dev1.DeviceParameter.COM.Port = 1; //dev1.DeviceParameter.COM.Baud = 9600; //dev1.CommunicateType = CommunicateType.COM; //dev1.Initialize(0); //DeviceDriver dev2 = new DeviceDriver(); //dev2.DeviceParameter.DeviceName = "设备2"; //dev2.DeviceParameter.DeviceAddr = 0; //dev2.DeviceParameter.DeviceID = 1; //dev2.DeviceDynamic.DeviceID = 1; //dev2.DeviceParameter.COM.Port = 3; //dev2.DeviceParameter.COM.Baud = 9600; //dev2.CommunicateType = CommunicateType.COM; //dev2.Initialize(1); //DeviceDriver dev3 = new DeviceDriver(); //dev3.DeviceParameter.DeviceName = "设备3"; //dev3.DeviceParameter.DeviceAddr = 0; //dev3.DeviceParameter.DeviceID = 2; //dev3.DeviceDynamic.DeviceID = 2; //dev3.DeviceParameter.NET.RemoteIP = "127.0.0.1"; //dev3.DeviceParameter.NET.RemotePort = 9600; //dev3.CommunicateType = CommunicateType.NET; //dev3.Initialize(2); DeviceDriver dev4 = new DeviceDriver(); dev4.DeviceParameter.DeviceName = "设备4"; dev4.DeviceParameter.DeviceAddr = 0; dev4.DeviceParameter.DeviceCode = "000"; dev4.DeviceParameter.DeviceID = "3"; dev4.DeviceDynamic.DeviceID = "3"; dev4.DeviceParameter.NET.RemoteIP = "127.0.0.1"; dev4.DeviceParameter.NET.RemotePort = 9600; dev4.CommunicateType = CommunicateType.NET; dev4.Initialize("000"); IServer server = new ServerFactory().CreateServer(new ServerConfig() { ServerName = "服务1", NetReceiveTimeout = 3000, ControlMode = ControlMode.Parallel, SocketMode = SocketMode.Tcp, StartReceiveDataFliter = false, ClearSocketSession = false, StartCheckPackageLength = true }); server.AddDeviceCompleted += server_AddDeviceCompleted; server.DeleteDeviceCompleted += server_DeleteDeviceCompleted; server.Start(); //server.AddDevice(dev1); //server.AddDevice(dev2); //server.RemoveDevice(0); //删除设备 //server.AddDevice(dev3); server.AddDevice(dev4); ////个性串口号 //int oldport = dev1.DeviceParameter.COM.Port; //int oldbaud = dev1.DeviceParameter.COM.Baud; //int newport = 2; //int newbaud = 9600; //server.ChangeDeviceComInfo(0, oldport, oldbaud, newport, newbaud); //dev1.DeviceParameter.COM.Port = newport; //dev1.DeviceParameter.COM.Baud = newbaud; //Service s = new Service(); //s.AppServiceLog += s_AppServiceLog; //server.AddAppService((IAppService)s); //Graphics g = new Graphics(); //server.AddGraphicsShow((IGraphicsShow)g); while ("exit" == Console.ReadLine()) { server.Stop(); } }
static void Main(string[] args) { DeviceDriver dev1 = new DeviceDriver(); dev1.DeviceParameter.DeviceName = "设备1"; dev1.DeviceParameter.DeviceAddr = 0; dev1.DeviceParameter.DeviceID = 0; dev1.DeviceDynamic.DeviceID = 0; dev1.DeviceParameter.COM.Port = 1; dev1.DeviceParameter.COM.Baud = 9600; dev1.CommunicateType = CommunicateType.COM; dev1.Initialize(0); DeviceDriver dev2 = new DeviceDriver(); dev2.DeviceParameter.DeviceName = "设备2"; dev2.DeviceParameter.DeviceAddr = 0; dev2.DeviceParameter.DeviceID = 1; dev2.DeviceDynamic.DeviceID = 1; dev2.DeviceParameter.COM.Port = 3; dev2.DeviceParameter.COM.Baud = 9600; dev2.CommunicateType = CommunicateType.COM; dev2.Initialize(1); DeviceDriver dev3 = new DeviceDriver(); dev3.DeviceParameter.DeviceName = "设备3"; dev3.DeviceParameter.DeviceAddr = 0; dev3.DeviceParameter.DeviceID = 2; dev3.DeviceDynamic.DeviceID = 2; dev3.DeviceParameter.NET.RemoteIP = "127.0.0.1"; dev3.DeviceParameter.NET.RemotePort = 9600; dev3.CommunicateType = CommunicateType.NET; dev3.Initialize(2); DeviceDriver dev4 = new DeviceDriver(); dev4.DeviceParameter.DeviceName = "设备4"; dev4.DeviceParameter.DeviceAddr = 0; dev4.DeviceParameter.DeviceID = 3; dev4.DeviceDynamic.DeviceID = 3; dev4.DeviceParameter.NET.RemoteIP = "127.0.0.1"; dev4.DeviceParameter.NET.RemotePort = 9600; dev4.CommunicateType = CommunicateType.NET; dev4.Initialize(3); Server server = new Server("服务1", new Config() { ControlMode = ControlMode.Loop }); server.AddDeviceCompleted += server_AddDeviceCompleted; server.DeleteDeviceCompleted += server_DeleteDeviceCompleted; server.SocketConnected += server_SocketConnected; server.SocketClosed += server_SocketClosed; server.Start(); server.AddDevice(dev1); server.AddDevice(dev2); //server.RemoveDevice(0); //删除设备 server.AddDevice(dev3); server.AddDevice(dev4); //server.RemoveDevice(3);//删除设备 //dev3.DeviceParameter.NET.WorkMode=WorkMode.TcpClient; dev1.ShowMonitorDialog(); ////个性串口号 //int oldport = dev1.DeviceParameter.COM.Port; //int oldbaud = dev1.DeviceParameter.COM.Baud; //int newport = 3; //int newbaud = 9600; //server.ChangeDeviceComInfo(1, oldport, oldbaud, newport, newbaud); //dev1.DeviceParameter.COM.Port = newport; //dev1.DeviceParameter.COM.Baud = newbaud; Service s = new Service(); s.AppServiceLog += s_AppServiceLog; server.AddAppService((IAppService)s); Graphics g = new Graphics(); server.AddGraphicsShow((IGraphicsShow)g); while ("exit" == Console.ReadLine()) { server.Stop(); } }
static void Main(string[] args) { DeviceDriver dev1 = new DeviceDriver(); dev1.DeviceParameter.DeviceName = "设备1"; dev1.DeviceParameter.DeviceAddr = 0; dev1.DeviceParameter.DeviceID = "0"; dev1.DeviceDynamic.DeviceID = "0"; dev1.DeviceParameter.COM.Port = 1; dev1.DeviceParameter.COM.Baud = 9600; dev1.CommunicateType = CommunicateType.COM; dev1.Initialize("0"); DeviceDriver dev2 = new DeviceDriver(); dev2.DeviceParameter.DeviceName = "设备2"; dev2.DeviceParameter.DeviceAddr = 0; dev2.DeviceParameter.DeviceID = "1"; dev2.DeviceDynamic.DeviceID = "1"; dev2.DeviceParameter.COM.Port = 1; dev2.DeviceParameter.COM.Baud = 9600; dev2.CommunicateType = CommunicateType.COM; dev2.Initialize("1"); DeviceSelfDriver dev3 = new DeviceSelfDriver(); dev3.DeviceParameter.DeviceName = "设备3"; dev3.DeviceParameter.DeviceAddr = 0; dev3.DeviceParameter.DeviceID = "2"; dev3.DeviceDynamic.DeviceID = "2"; dev3.DeviceParameter.NET.RemoteIP = "127.0.0.1"; dev3.DeviceParameter.NET.RemotePort = 9600; dev3.CommunicateType = CommunicateType.NET; dev3.Initialize("2"); DeviceSelfDriver dev4 = new DeviceSelfDriver(); dev4.DeviceParameter.DeviceName = "设备4"; dev4.DeviceParameter.DeviceAddr = 0; dev4.DeviceParameter.DeviceID = "3"; dev4.DeviceDynamic.DeviceID = "3"; dev4.DeviceParameter.NET.RemoteIP = "127.0.0.1"; dev4.DeviceParameter.NET.RemotePort = 9600; dev4.CommunicateType = CommunicateType.NET; dev4.Initialize("3"); IServer server = new ServerFactory().CreateServer(new ServerConfig() { ServerName = "服务1", ControlMode = ControlMode.Self }); server.AddDeviceCompleted += server_AddDeviceCompleted; server.DeleteDeviceCompleted += server_DeleteDeviceCompleted; server.Start(); server.AddDevice(dev1); server.AddDevice(dev2); server.RemoveDevice("0"); //删除设备 server.AddDevice(dev3); server.AddDevice(dev4); server.RemoveDevice("3");//删除设备 //个性串口号 int oldport = dev1.DeviceParameter.COM.Port; int oldbaud = dev1.DeviceParameter.COM.Baud; int newport = 2; int newbaud = 9600; server.ChangeDeviceComInfo("0", oldport, oldbaud, newport, newbaud); dev1.DeviceParameter.COM.Port = newport; dev1.DeviceParameter.COM.Baud = newbaud; TestService.Service s = new TestService.Service(); s.ServiceLog += s_AppServiceLog; server.AddService((IService)s); Graphics g = new Graphics(); server.AddGraphicsShow((IGraphicsShow)g); while ("exit" == Console.ReadLine()) { server.Stop(); } }