|
|
@ -31,7 +31,7 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
|
|
|
|
IMqttClientDisconnectedHandler
|
|
|
|
IMqttClientDisconnectedHandler
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private static readonly ILog Log = LogManager.GetLogger(typeof(CloudClient));
|
|
|
|
private static readonly ILog Log = LogManager.GetLogger(typeof(CloudClient));
|
|
|
|
|
|
|
|
|
|
|
|
public SwapOrderRepository SwapOrderRepository { get; set;}
|
|
|
|
public SwapOrderRepository SwapOrderRepository { get; set;}
|
|
|
|
|
|
|
|
|
|
|
|
#region tcp param
|
|
|
|
#region tcp param
|
|
|
@ -43,7 +43,7 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
|
|
|
|
public string? Password { get; set; }
|
|
|
|
public string? Password { get; set; }
|
|
|
|
public int KeepalivePeriod { get; set; } = 3000;
|
|
|
|
public int KeepalivePeriod { get; set; } = 3000;
|
|
|
|
public int Timeout { get; set; } = 60;
|
|
|
|
public int Timeout { get; set; } = 60;
|
|
|
|
public string Version { get; set; } = "5.0.16";
|
|
|
|
public string MqttVersion { get; set; } = "4.0.0";
|
|
|
|
public bool IsCleanSession { get; set; } = false;
|
|
|
|
public bool IsCleanSession { get; set; } = false;
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
@ -71,7 +71,7 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
|
|
|
|
public CarCanStart? CarCanStart { get; set; }
|
|
|
|
public CarCanStart? CarCanStart { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
public MsgPair<VehicleCertification, VehicleCertificationResp> CarAuth { get; set; } = new();
|
|
|
|
public MsgPair<VehicleCertification, VehicleCertificationResp> CarAuth { get; set; } = new();
|
|
|
|
public MsgPair<ChannelStatusReporting, ChannelStatusReportingResp> ChannelStatus { get; set; } = new();
|
|
|
|
public MsgPair<ChannelStatusReporting, ChannelStatusReportingResp> ChannelStatus { get; set; } = new();
|
|
|
@ -225,7 +225,7 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
|
|
|
|
MqttTopicFilter topicFilter = new MqttTopicFilter
|
|
|
|
MqttTopicFilter topicFilter = new MqttTopicFilter
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Topic = str,
|
|
|
|
Topic = str,
|
|
|
|
QualityOfServiceLevel = MqttQualityOfServiceLevel.AtMostOnce
|
|
|
|
QualityOfServiceLevel = MqttQualityOfServiceLevel.AtLeastOnce
|
|
|
|
};
|
|
|
|
};
|
|
|
|
list.Add(topicFilter);
|
|
|
|
list.Add(topicFilter);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -272,7 +272,7 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
|
|
|
|
MqttClient.PublishAsync(appMsg);
|
|
|
|
MqttClient.PublishAsync(appMsg);
|
|
|
|
MqttClient.PublishAsync(appMsg);
|
|
|
|
MqttClient.PublishAsync(appMsg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private string SignData<T>(Model<T> model) where T : ICmd
|
|
|
|
private string SignData<T>(Model<T> model) where T : ICmd
|
|
|
@ -366,7 +366,7 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
|
|
|
|
|
|
|
|
|
|
|
|
builder.WithKeepAlivePeriod(TimeSpan.FromSeconds(KeepalivePeriod))
|
|
|
|
builder.WithKeepAlivePeriod(TimeSpan.FromSeconds(KeepalivePeriod))
|
|
|
|
.WithCommunicationTimeout(TimeSpan.FromSeconds(Timeout));
|
|
|
|
.WithCommunicationTimeout(TimeSpan.FromSeconds(Timeout));
|
|
|
|
switch (Version)
|
|
|
|
switch (MqttVersion)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case "3.1.0":
|
|
|
|
case "3.1.0":
|
|
|
|
builder.WithProtocolVersion(MqttProtocolVersion.V310);
|
|
|
|
builder.WithProtocolVersion(MqttProtocolVersion.V310);
|
|
|
@ -397,7 +397,7 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
|
|
|
|
this.Publish(vehicleCertification);
|
|
|
|
this.Publish(vehicleCertification);
|
|
|
|
return CarAuth.GetResp(timeSpan);
|
|
|
|
return CarAuth.GetResp(timeSpan);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 换电站通道状态上报
|
|
|
|
/// 换电站通道状态上报
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
@ -499,8 +499,8 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
|
|
|
|
this.ChargeRecordUpLoad.Req = req;
|
|
|
|
this.ChargeRecordUpLoad.Req = req;
|
|
|
|
this.Publish(req);
|
|
|
|
this.Publish(req);
|
|
|
|
return ChargeRecordUpLoad.GetResp(timeSpan);
|
|
|
|
return ChargeRecordUpLoad.GetResp(timeSpan);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public ChargeDevDataInfoRes? SendChargeDevDataInfo(ChargeDevDataInfo req, TimeSpan? timeSpan = null)
|
|
|
|
public ChargeDevDataInfoRes? SendChargeDevDataInfo(ChargeDevDataInfo req, TimeSpan? timeSpan = null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this.ChargeDevDataInfo.Req = req;
|
|
|
|
this.ChargeDevDataInfo.Req = req;
|
|
|
@ -512,7 +512,7 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
|
|
|
|
#region business func
|
|
|
|
#region business func
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="chargeOrder"></param>
|
|
|
|
/// <param name="chargeOrder"></param>
|
|
|
|
/// <param name="op">1: 自动; 2: 人工手动</param>
|
|
|
|
/// <param name="op">1: 自动; 2: 人工手动</param>
|
|
|
@ -534,7 +534,7 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
|
|
|
|
ssoc = chargeOrder.StartSoc ?? 0,
|
|
|
|
ssoc = chargeOrder.StartSoc ?? 0,
|
|
|
|
esoc = lastChargeOrder.StopSoc ?? 0,
|
|
|
|
esoc = lastChargeOrder.StopSoc ?? 0,
|
|
|
|
//ssoe = chargeOrder.soe
|
|
|
|
//ssoe = chargeOrder.soe
|
|
|
|
//esoe
|
|
|
|
//esoe
|
|
|
|
dcce =0,
|
|
|
|
dcce =0,
|
|
|
|
acce =0,
|
|
|
|
acce =0,
|
|
|
|
tp = 0,
|
|
|
|
tp = 0,
|
|
|
@ -557,10 +557,10 @@ public class CloudClient : IMqttClientConnectedHandler, IMqttApplicationMessageR
|
|
|
|
req.vp += Convert.ToSingle(order.ValleyElecCount);
|
|
|
|
req.vp += Convert.ToSingle(order.ValleyElecCount);
|
|
|
|
req.ct += ((order.EndTime ?? DateTime.Now).Subtract(order.StartTime ?? DateTime.Now)).Minutes;
|
|
|
|
req.ct += ((order.EndTime ?? DateTime.Now).Subtract(order.StartTime ?? DateTime.Now)).Minutes;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.SendChargeRecordUpLoad(req);
|
|
|
|
this.SendChargeRecordUpLoad(req);
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|
|
|
|