|
@@ -85,6 +85,9 @@ namespace HengshanPaymentTerminal
|
|
|
private object lockFrame = new object();
|
|
|
|
|
|
private readonly IHttpClientUtil httpClientUtil;
|
|
|
+
|
|
|
+
|
|
|
+ private ConcurrentDictionary<int, bool> nozzleStatusDic = new ConcurrentDictionary<int, bool>();
|
|
|
#endregion
|
|
|
|
|
|
#region Logger
|
|
@@ -436,6 +439,25 @@ namespace HengshanPaymentTerminal
|
|
|
|
|
|
switch(context.Incoming.Message.Handle)
|
|
|
{
|
|
|
+
|
|
|
+ case 10:
|
|
|
+ {
|
|
|
+
|
|
|
+ HeartBeatMessage heartBeatMessage = (HeartBeatMessage)context.Incoming.Message;
|
|
|
+ foreach(var nozzleState in heartBeatMessage.NozzleStatus)
|
|
|
+ {
|
|
|
+ bool isBusy = nozzleState.STATU != 0x03;
|
|
|
+ if(nozzleStatusDic.TryGetValue(nozzleState.NozzleNum, out var value))
|
|
|
+ {
|
|
|
+ if(isBusy == value) return;
|
|
|
+ SendNozzleStatus(nozzleState,isBusy);
|
|
|
+ } else
|
|
|
+ {
|
|
|
+ SendNozzleStatus(nozzleState,isBusy);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
case 0x18:
|
|
|
{
|
|
@@ -891,6 +913,23 @@ namespace HengshanPaymentTerminal
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private async void SendNozzleStatus(HeartBeatNozzleState nozzleState,bool isBusy)
|
|
|
+ {
|
|
|
+
|
|
|
+ nozzleStatusDic[nozzleState.NozzleNum] = isBusy;
|
|
|
+
|
|
|
+
|
|
|
+ SendNozzleStatu sendNozzleStatu = new SendNozzleStatu(nozzleState);
|
|
|
+ logger.Info($"send nozzle state to cloud,{sendNozzleStatu.NozzleId}-{sendNozzleStatu.Status}");
|
|
|
+ HttpResponseMessage httpResponseMessage = await httpClientUtil.SendNozzleStatu(JsonConvert.SerializeObject(sendNozzleStatu));
|
|
|
+ Response<object>? response = JsonConvert.DeserializeObject<Response<object>>(await httpResponseMessage.Content.ReadAsStringAsync());
|
|
|
+ logger.Info($"reveice send nozzle state response:{JsonConvert.SerializeObject(response)}");
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
|