|
@@ -85,6 +85,9 @@ namespace HengshanPaymentTerminal
|
|
|
private object lockFrame = new object();
|
|
|
|
|
|
private readonly IHttpClientUtil httpClientUtil;
|
|
|
+
|
|
|
+ //记录油枪状态,key-枪号,value:是否忙碌
|
|
|
+ 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
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 发送油枪状态给云端
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="nozzleState"></param>
|
|
|
+ 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)}");
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 传入有效数据,拼接为要发送给油机包
|
|
|
/// </summary>
|