public static int ServerTestMulti(string listenAddress, int port, bool debug) { ModbusCore core = new ModbusCore(listenAddress, port); core.Debug = debug; if (core.MappingNew(500, 500, 500, 500)) { Console.WriteLine("Failed to allocate the mapping."); return(-1); } // Initialization for testing for (int i = 0; i < 500; ++i) { core.RegisterRWSigned[i] = (short)(1000 + i); core.RegisterInputSigned[i] = (short)i; } core.ListenTcp(10); while (true) { core.AcceptTcp(); HandleModbusQuery mq = new HandleModbusQuery(core); Thread thread = new Thread(new ThreadStart(mq.HandleRequests)); thread.Start(); } core.MappingDispose(); core.Close(); core.Dispose(); return(0); }
public static int ServerTestMulti(string listenAddress, int port, bool debug) { ModbusCore core = new ModbusCore (listenAddress, port); core.Debug = debug; if (core.MappingNew (500, 500, 500, 500)) { Console.WriteLine ("Failed to allocate the mapping."); return -1; } // Initialization for testing for (int i = 0; i < 500; ++i) { core.RegisterRWSigned[i] = (short)(1000+i); core.RegisterInputSigned[i] = (short)i; } core.ListenTcp (10); while (true) { core.AcceptTcp (); HandleModbusQuery mq = new HandleModbusQuery(core); Thread thread = new Thread(new ThreadStart(mq.HandleRequests)); thread.Start (); } core.MappingDispose (); core.Close (); core.Dispose (); return 0; }