static void Main() { //Create MDSClient object to connect to DotNetMQ //Name of this application: Application1 var mdsClient = new MDSClient("Application1"); //Connect to DotNetMQ server mdsClient.Connect(); Console.WriteLine("Write a text and press enter to send to Application2. Write 'exit' to stop application."); while (true) { //Get a message from user var messageText = Console.ReadLine(); if (string.IsNullOrEmpty(messageText) || messageText == "exit") { break; } //Create a DotNetMQ Message to send to Application2 var message = mdsClient.CreateMessage(); //Set destination application name message.DestinationApplicationName = "Application2"; //message.DestinationServerName = "this_server2"; //Set message data message.MessageData = Encoding.UTF8.GetBytes(messageText); //Send message message.Send(); } //Disconnect from DotNetMQ server mdsClient.Disconnect(); }
private Controller(int loopTime, string applicationName, string managerApplicationName) { // Name of this application ApplicationName = applicationName; // Name of the manager application ManagerApplicationName = managerApplicationName; model = new Model(); // Create MDSClient object to connect to DotNetMQ mdsClient = new MDSClient(ApplicationName); // Connect to DotNetMQ server try { mdsClient.Connect(); } catch (Exception ex) { Logger.Warn(ex.Message, ex); } // Register to MessageReceived event to get messages. mdsClient.MessageReceived += hmi_MessageReceived; // connessione al manager ManagerConnect(); LoopTime = loopTime; timer.Elapsed += timer_Elapsed; timer.Enabled = true; Logger.InfoFormat("{0} Application ready", ApplicationName); }
static void Main(string[] args) { Thread.Sleep(1000); //Create MDSClient object to connect to DotNetMQ //Name of this application: LapScore.MessageService.Listener var mdsClient = new MDSClient("LapScore.MessageService.Listener"); //Register to MessageReceived event to get messages. mdsClient.MessageReceived += MDSClient_MessageReceived; //Connect to DotNetMQ server mdsClient.Connect(); //Wait user to press enter to terminate application // Console.WriteLine("Press enter to exit..."); // Console.ReadLine(); while (KeepALive == true) { } //Disconnect from DotNetMQ server mdsClient.Disconnect(); }
public MQSendClient() { ServiceName = Utils.MQConfigHelper.MQQualityHelper.ServiceName; IpAddress = Utils.MQConfigHelper.MQQualityHelper.Ip; Port = Utils.MQConfigHelper.MQQualityHelper.Port; client = new MDSClient(ServiceName, IpAddress, Port); }
private Controller() { //// Name of this application: Interface //ApplicationName = Settings.Default.ApplicationName; //// Name of the plc server application: PLCServer //PLCServerApplicationName = Settings.Default.ApplicationName; model = new Model(); // Create MDSClient object to connect to DotNetMQ mdsClient = new MDSClient(ApplicationName); // Connect to DotNetMQ server try { mdsClient.Connect(); } catch (Exception ex) { Logger.Warn(ex.Message, ex); } // connetto a plcserver PLCServerConnect(); // Register to MessageReceived event to get messages. mdsClient.MessageReceived += hmi_MessageReceived; }
/// <summary> /// 开启服务 /// </summary> public void Start() { new DataProcessor().ReadConfig(); this.msgProcessor = new MessageProcessor(); this.mdsClient = new MDSClient("DataCalc"); // 注册消息接受事件 this.mdsClient.MessageReceived += this.MDSClient_MessageReceived; // 连接到MQ try { this.mdsClient.Connect(); this.logger.Info("二次计算服务启动成功"); fileProcessor = new FileProcessor(); fileProcessor.Start(); this.logger.Info("文件处理线程启动"); // 启动时进行历史数据处理 ProcessOmittedData(); } catch (Exception ex) { this.logger.Error("二次计算服务启动失败", ex); } }
private Controller() { // Name of this application: HMIClient ApplicationName = "Interface"; // Name of the plc server application: PLCServer PLCServerApplicationName = "PLCServer"; model = new Model(); timer = new DispatcherTimer(); // Create MDSClient object to connect to DotNetMQ mdsClient = new MDSClient(ApplicationName); // Connect to DotNetMQ server try { mdsClient.Connect(); } catch (Exception ex) { Logger.Warn(ex.Message, ex); } // connetto a plcserver PLCServerConnect(); // Register to MessageReceived event to get messages. mdsClient.MessageReceived += hmi_MessageReceived; // timer timer.Interval = TimeSpan.FromMilliseconds(LoopTime); timer.Tick += timer_Tick; timer.IsEnabled = true; }
public plcserver(int loopTime, string applicationName) { ApplicationName = applicationName; // Create MDSClient object to connect to DotNetMQ // Name of this application: PLCServer mdsClient = new MDSClient(ApplicationName); // Connect to DotNetMQ server try { mdsClient.Connect(); } catch (Exception ex) { Logger.Error(ex.Message, ex); // esco this.Exit(); } // Register to MessageReceived event to get messages. mdsClient.MessageReceived += PLCServer_MessageReceived; LoopTime = loopTime; timer.Elapsed += timer_Elapsed; timer.Enabled = true; Logger.InfoFormat("{0} application ready", ApplicationName); }
public void Dispose() { if (client != null) { client.Disconnect(); client.Dispose(); client = null; } }
private static void Ts() { mdsClient = new MDSClient("ExtractionTransformationProcess"); mdsClient.Connect(); while (true) { try { var tmp = Console.ReadLine().ToLower().Trim(); var parts = tmp.Split(null); var cmd = parts[0]; switch (cmd) { case "exit": case "quit": break; case "help": case "h": ShowHelp(); break; case "q": if (parts.Length < 2) { Console.WriteLine("need parameter"); } DateTime paratime; if (!DateTime.TryParseExact(parts[1], "yyyyMMddHHmmss", null, System.Globalization.DateTimeStyles.None, out paratime)) { Console.WriteLine("error time format"); } Send(paratime, 58, @"C:\Users\yinweiwen\Desktop\Vibration\9999_1_20140723151516925.odb", 415); break; case "qz1": Send(DateTime.Now, 95, parts[1], 2782); break; case "qzall": SendAll(); break; case "circ": // 测试消息通知 var interval = Convert.ToInt32(parts[1]); CircTest(interval); break; } } catch (System.Exception ex) { Console.WriteLine(ex.Message); } } }
public PLCItem(string plcName, string ipAddress, short rack, short slot, int delay, MDSClient mdsClient) { Name = plcName; IPAddress = ipAddress; Rack = rack; Slot = slot; Delay = delay; ConnectionStatus = PLCConnectionStatus.NotConnected; MDSClientInstance = mdsClient; }
static void Main(string[] args) { var mdsClient = new MDSClient("StockServer"); mdsClient.MessageReceived += MDSClient_MessageReceived; mdsClient.Connect(); Console.WriteLine("Press enter to exit..."); Console.ReadLine(); mdsClient.Disconnect(); }
private static void SendMessage(MDSClient mdsClient, string DestinationApplicationName, string newMessage, MDS.Communication.Messages.MessageTransmitRules rules) { //Create a DotNetMQ Message to send to Application2 var message = mdsClient.CreateMessage(); //Set destination application name message.DestinationApplicationName = DestinationApplicationName; message.TransmitRule = rules; //Set message data message.MessageData = Encoding.UTF8.GetBytes(newMessage); //Send message message.Send(); }
static void Main(string[] args) { MDSClient mdsClient = new MDSClient(Utils.MQConfigHelper.MQQualityHelper.ServiceName, Utils.MQConfigHelper.MQQualityHelper.Ip, Utils.MQConfigHelper.MQQualityHelper.Port); mdsClient.MessageReceived += new MessageReceivedHandler(mdsClient_MessageReceived); mdsClient.Connect(); Console.WriteLine("按回车键退出"); Console.ReadLine(); mdsClient.Disconnect(); }
public void Start() { mdsClient = new MDSClient("WirelessReceiver"); try { mdsClient.Connect(); Console.WriteLine("启动服务"); isConnect = true; } catch (Exception ex) { log.Error(ex.Message); Console.WriteLine("启动服务失败"); } }
public void Initialize() { Thread.Sleep(1000); //Create MDSClient object to connect to DotNetMQ //Name of this application: LapScore.MessageService.Listener var mdsClient = new MDSClient("LapScore.MessageService.GUI"); //Register to MessageReceived event to get messages. mdsClient.MessageReceived += MDSClient_MessageReceived; //Connect to DotNetMQ server mdsClient.Connect(); }
/// <summary> /// /// </summary> /// <param name="args"></param> static void Main(string[] args) { while (true) { //实例化客户端 var mdsClient = new MDSClient("SyncService", "127.0.0.1", 10905); //链接SERVER mdsClient.Connect(); var message = mdsClient.CreateMessage(); message.MessageData = System.Text.Encoding.UTF8.GetBytes(Guid.NewGuid().ToString()); message.Send(); Console.WriteLine("00"); mdsClient.Disconnect(); System.Threading.Thread.Sleep(1000); } }
static void Main(string[] args) { //Create MDSClient object to connect to DotNetMQ //Name of this application: Application2 var mdsClient = new MDSClient("Application2"); //Register to MessageReceived event to get messages. mdsClient.MessageReceived += MDSClient_MessageReceived; //Connect to DotNetMQ server mdsClient.Connect(); //Wait user to press enter to terminate application Console.WriteLine("Press enter to exit..."); Console.ReadLine(); //Disconnect from DotNetMQ server mdsClient.Disconnect(); }
static void Main(string[] args) { Console.WriteLine("Press enter to query a stock status"); Console.ReadLine(); //Connect to DotNetMQ var mdsClient = new MDSClient("StockClient"); mdsClient.MessageReceived += mdsClient_MessageReceived; mdsClient.Connect(); //Create a stock request message var stockQueryMessage = new StockQueryMessage { StockCode = "S01" }; //Create a MDS message var requestMessage = mdsClient.CreateMessage(); requestMessage.DestinationApplicationName = "StockServer"; requestMessage.TransmitRule = MessageTransmitRules.NonPersistent; requestMessage.MessageData = GeneralHelper.SerializeObject(stockQueryMessage); //Send message and get response var responseMessage = requestMessage.SendAndGetResponse(); //Get stock query result message from response message var stockResult = (StockQueryResultMessage)GeneralHelper.DeserializeObject(responseMessage.MessageData); //Write stock query result Console.WriteLine("StockCode = " + stockResult.StockCode); Console.WriteLine("ReservedStockCount = " + stockResult.ReservedStockCount); Console.WriteLine("TotalStockCount = " + stockResult.TotalStockCount); //Acknowledge received message responseMessage.Acknowledge(); Console.ReadLine(); //Disconnect from DotNetMQ server. mdsClient.Disconnect(); }
static void Main(string[] args) { //Create MDSClient object to connect to DotNetMQ //Name of this application: Application1 var mdsClient = new MDSClient("LapScore.Server"); //Connect to DotNetMQ server //mdsClient.Connect(); //Register to MessageReceived event to get messages. mdsClient.MessageReceived += MDSClient_MessageReceived; //Connect to DotNetMQ server mdsClient.Connect(); while (KeepALive == true) { } mdsClient.Disconnect(); }
/// <summary> /// Creates a new MDSServiceApplication object. /// </summary> /// <param name="applicationName">Name of the application</param> /// <param name="ipAddress">IP address of MDS server</param> /// <param name="port">TCP port of MDS server</param> public MDSServiceApplication(string applicationName, string ipAddress, int port) { _mdsClient = new MDSClient(applicationName, ipAddress, port); Initialize(); }
private static void Main(string[] args) { Ts(); return; var mdsClient = new MDSClient("ET"); mdsClient.Connect(); bool isAuto = false; int autoCount = 100; Console.WriteLine("输入(auto),自动执行100次"); isAuto = Console.ReadLine() == "auto"; while (true) { if (!isAuto) { string str = Console.ReadLine(); if (str == "end") { break; } } else { if (autoCount-- <= 0) { break; } } Task[] ts = new Task[100]; for (int i = 0; i < 100; i++) { ts[i] = new Task(() => { Random ran = new Random(); int number = ran.Next(0, 10); var message = mdsClient.CreateMessage(); message.DestinationApplicationName = "DataCalc"; message.MessageData = GeneralHelper.SerializeObject(new RequestDataCalcMessage() { StructId = number, DateTime = DateTime.Now }); message.TransmitRule = MDS.Communication.Messages.MessageTransmitRules.NonPersistent; message.Send(); Console.WriteLine("发送消息:结构物编号{0},采集时间:{1}", number, DateTime.Now); }); } foreach (Task task in ts) { task.Start(); } Thread.Sleep(200); } mdsClient.Disconnect(); Console.ReadLine(); }
/// <summary> /// Creates a new MDSServiceApplication object with default port to connect to MDS server. /// </summary> /// <param name="applicationName">Name of the application</param> /// <param name="ipAddress">IP address of MDS server</param> public MDSServiceApplication(string applicationName, string ipAddress) { _mdsClient = new MDSClient(applicationName, ipAddress, CommunicationConsts.DefaultMDSPort); Initialize(); }
/// <summary> /// Creates a new MDSServiceApplication object with default values to connect to MDS server. /// </summary> /// <param name="applicationName">Name of the application</param> public MDSServiceConsumer(string applicationName) { MdsClient = new MDSClient(applicationName, CommunicationConsts.DefaultIpAddress, CommunicationConsts.DefaultMDSPort); Initialize(); }
public PLCItem(string plcName, string ipAddress, MDSClient mdsClient) : this(plcName, ipAddress, 0, 2, 100, mdsClient) { }
/// <summary> /// Creates a new MDSServiceApplication object. /// </summary> /// <param name="applicationName">Name of the application</param> /// <param name="ipAddress">IP address of MDS server</param> /// <param name="port">TCP port of MDS server</param> public MDSServiceConsumer(string applicationName, string ipAddress, int port) { MdsClient = new MDSClient(applicationName, ipAddress, port); }
/// <summary> /// Creates a new MDSServiceApplication object with default port to connect to MDS server. /// </summary> /// <param name="applicationName">Name of the application</param> /// <param name="ipAddress">IP address of MDS server</param> public MDSServiceConsumer(string applicationName, string ipAddress) { MdsClient = new MDSClient(applicationName, ipAddress, CommunicationConsts.DefaultMDSPort); }
public DotNetMQHandler(string applicationName, string ipAddress, int port) { client = new MDSClient(applicationName, ipAddress, port); client.MessageReceived += client_MessageReceived; client.Connect(); }
public MQSendClient(string serviceName, string ip, int port) { client = new MDSClient(serviceName, ip, port); }
public Manager(int loopTime, string applicationName, string plcserverApplicationName) { ApplicationName = applicationName; PLCServerApplicationName = plcserverApplicationName; Logger.InfoFormat("{0} application ready", ApplicationName); // Create MDSClient object to connect to DotNetMQ // Name of this application: PLCServer mdsClient = new MDSClient(ApplicationName); mdsClient.AutoAcknowledgeMessages = true; // Connect to DotNetMQ server try { mdsClient.Connect(); } catch (Exception ex) { Logger.Error(ex.Message, ex); // esco this.Exit(); } // configurazione // data path // xml file name // opctags filename // lista plc connessi copn plcname,ipaddress // lettura del dominio dei tags LoadOPCTags(@"C:\Users\uts.MARINI\Documents\projects\cyb500n\Versione 9.6.x\Exe\OPCTags.xls", "plc4"); LoadOPCTags(@"C:\Users\uts.MARINI\Documents\projects\cyb500n\Versione 9.6.x\Exe\OPCTags.xls", "plc4cist"); LoadOPCTags(@"C:\Users\uts.MARINI\Documents\projects\cyb500n\Versione 9.6.x\Exe\OPCTags.xls", "plc5"); LoadOPCTags(@"C:\Users\uts.MARINI\Documents\projects\cyb500n\Versione 9.6.x\Exe\OPCTags.xls", "plc2"); LoadOPCTags(@"C:\Users\uts.MARINI\Documents\projects\cyb500n\Versione 9.6.x\Exe\OPCTags.xls", "WamFoam"); // Register to MessageReceived event to get messages. mdsClient.MessageReceived += Manager_MessageReceived; PLCServerConnect(); // spostare su plcserver PLCAdd("plc4", "213.131.0.161"); PLCAdd("plc4cist", "213.131.0.161"); PLCAdd("plc5", "213.131.0.161"); PLCAdd("plc2", "213.131.0.161"); PLCAdd("WamFoam", "213.131.0.161"); // configurazione // lettura del dominio degli oggetti MariniImpiantoTree.InitializeFromXmlFile(@"C:\Users\uts.MARINI\Documents\projects\new-project\oms\MariniImpianto\impianto-test.xml"); mariniImpiantoTree = MariniImpiantoTree.Instance; SubscribePLCTags(mariniImpiantoTree); LoopTime = loopTime; timer.Elapsed += timer_Elapsed; timer.Enabled = true; Logger.InfoFormat("{0} application ready", ApplicationName); }