private void userButton2_Click(object sender, EventArgs e) { // 远程通知服务器启动设备 HslCommunication.OperateResult <string, string> operate = mqttSyncClient.ReadString("StartPLC", ""); if (operate.IsSuccess) { MessageBox.Show(operate.Content1); } else { MessageBox.Show("通讯失败!" + operate.Message); } }
private void button1_Click(object sender, EventArgs e) { // 锁定 OperateResult <string, string> write = syncClient.ReadString("MainPLC/WriteBool", "{ \"address\": \"M300.1\", \"value\": true}"); if (write.IsSuccess) { MessageBox.Show("锁定成功"); } else { MessageBox.Show("锁定失败,原因:" + write.Message); } }
public ActionResult StopPlc() { MqttSyncClient mqttSyncClient = new MqttSyncClient("127.0.0.1", 1883); HslCommunication.OperateResult <string, string> operate = mqttSyncClient.ReadString("StopPLC", ""); if (operate.IsSuccess) { return(Content(operate.Content1)); } else { return(Content("通讯失败!" + operate.Message)); } }