| | |
| | | } |
| | | #endregion |
| | | |
| | | //#region MQTTæ¥æ¶å°ä¿¡æ¯åçåè°æ¹æ³ |
| | | //public void client_MqttMsgPublishReceived(object sender, MqttMsgPublishEventArgs e) |
| | | //{ |
| | | // try |
| | | // { |
| | | // string message = Encoding.UTF8.GetString(e.Message); |
| | | // List<MQTT_MainEntity_New> mQTT_MainEntity = getObjectByJson_Xs_OutDoorBillMain_New(message); |
| | | // for (int i = 0; i < mQTT_MainEntity[0].data.Count; i++) |
| | | // { |
| | | // if (mQTT_MainEntity[0].data[i].id == textBox_WorkPositionParams.Text && mQTT_MainEntity[0].data[i].value == 1) |
| | | // { |
| | | // produceQty += 1; |
| | | // } |
| | | // } |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // MessageBox.Show(ex.Message); |
| | | |
| | | // string msg = ""; |
| | | // if (disConnect(ref msg) == true) |
| | | // { |
| | | // MessageBox.Show(msg); |
| | | // } |
| | | // else |
| | | // { |
| | | // MessageBox.Show(msg); |
| | | // } |
| | | // } |
| | | //} |
| | | //#endregion |
| | | |
| | | |
| | | #region MQTTæ¥æ¶å°ä¿¡æ¯åçåè°æ¹æ³ |
| | | public void client_MqttMsgPublishReceived(object sender, MqttMsgPublishEventArgs e) |
| | | { |
| | | try |
| | | { |
| | | string message = Encoding.UTF8.GetString(e.Message); |
| | | List<MQTT_MainEntity> mQTT_MainEntity = getObjectByJson_Xs_OutDoorBillMain(message); |
| | | for(int i = 0; i < mQTT_MainEntity[0].values.Count; i++) |
| | | List<MQTT_MainEntity_New> mQTT_MainEntity = getObjectByJson_Xs_OutDoorBillMain_New(message); |
| | | for(int i = 0; i < mQTT_MainEntity[0].data.Count; i++) |
| | | { |
| | | if (mQTT_MainEntity[0].values[i].id == textBox_WorkPositionParams.Text && mQTT_MainEntity[0].values[i].v == true) |
| | | if (mQTT_MainEntity[0].data[i].id == textBox_WorkPositionParams.Text && mQTT_MainEntity[0].data[i].value == 1) |
| | | { |
| | | produceQty += 1; |
| | | } |
| | |
| | | return list; |
| | | } |
| | | #endregion |
| | | |
| | | #region json转为对象 |
| | | public List<MQTT_MainEntity_New> getObjectByJson_Xs_OutDoorBillMain_New(string jsonString) |
| | | { |
| | | jsonString = "[" + jsonString.ToString() + "]"; |
| | | List<MQTT_MainEntity_New> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<MQTT_MainEntity_New>>(jsonString); |
| | | return list; |
| | | } |
| | | #endregion |
| | | #endregion |
| | | } |
| | | |
| | |
| | | public long t; //æ¶é´æ³ |
| | | } |
| | | #endregion |
| | | |
| | | #region MQTTåéæ°æ®æ¨¡å1 |
| | | public class MQTT_MainEntity_New |
| | | { |
| | | public string id; |
| | | public string name; |
| | | public List<MQTT_SubEntity_New> data; |
| | | } |
| | | public class MQTT_SubEntity_New |
| | | { |
| | | public string id; //å·¥ä½ |
| | | public string name; //ç»æ |
| | | public string updatetime; |
| | | public string address; |
| | | public long value; //æ¶é´æ³ |
| | | } |
| | | #endregion |
| | | } |