|
@@ -20,6 +20,7 @@ namespace xicheji
|
|
|
private byte[]? currentDataBlock;
|
|
|
private Plc? plc = null;
|
|
|
private HikApi? hikApi = null;
|
|
|
+ private string lastCarNo = string.Empty;
|
|
|
|
|
|
public MainForm()
|
|
|
{
|
|
@@ -197,6 +198,13 @@ namespace xicheji
|
|
|
|
|
|
if (ReadPLCInt("最后一次洗车开始月") != 0)
|
|
|
{
|
|
|
+ if (string.IsNullOrEmpty(lastCarNo))
|
|
|
+ {
|
|
|
+ receivePLCTimer.Enabled = false;
|
|
|
+ MessageBox.Show("未检测到车牌信息,请检查是否识别正常");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
//洗车完成后才有数据的
|
|
|
|
|
|
var washStartTime = new DateTime(
|
|
@@ -218,7 +226,7 @@ namespace xicheji
|
|
|
var washRecord = new WashRecord()
|
|
|
{
|
|
|
DeviceId = macAddress,
|
|
|
- CarNum = "",//TODO
|
|
|
+ CarNum = lastCarNo,
|
|
|
StartTime = washStartTime,
|
|
|
EndTime = washEndTime,
|
|
|
DryTime = ReadPLCInt("最后一次洗车风干时长"),
|
|
@@ -229,6 +237,9 @@ namespace xicheji
|
|
|
};
|
|
|
|
|
|
washRecords.Add(washRecord);
|
|
|
+
|
|
|
+ //洗车完成后重置车牌信息
|
|
|
+ lastCarNo = string.Empty;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -577,22 +588,13 @@ namespace xicheji
|
|
|
washTime = washRecord.WashTime, //洗车时长(s)
|
|
|
widnowsDefender = washRecord.TotalWater, //用水量(t)
|
|
|
waterPressure = washRecord.WaterPressure, //压力(MPa)
|
|
|
- picBase64 = ConvertImageToBase64(pbCamera.Image, ImageFormat.Jpeg), //洗车图片base64
|
|
|
+ picBase64 = ImageToBase64(pbCamera.Image, ImageFormat.Jpeg), //洗车图片base64
|
|
|
};
|
|
|
request.AddParameter("application/json", JsonConvert.SerializeObject(jsonBody), ParameterType.RequestBody);
|
|
|
var response = await restClient.ExecuteAsync(request);
|
|
|
if (response == null) return;
|
|
|
}
|
|
|
|
|
|
- private static string ConvertImageToBase64(Image image, ImageFormat format)
|
|
|
- {
|
|
|
- if (image == null) return string.Empty;
|
|
|
-
|
|
|
- using var memoryStream = new MemoryStream();
|
|
|
- image.Save(memoryStream, format);
|
|
|
- var imageBytes = memoryStream.ToArray();
|
|
|
- return Convert.ToBase64String(imageBytes);
|
|
|
- }
|
|
|
#endregion
|
|
|
|
|
|
#region 摄像头
|
|
@@ -674,13 +676,50 @@ namespace xicheji
|
|
|
|
|
|
#region 服务接口回调->更新汽车信息
|
|
|
|
|
|
- public void UpdateTitle(DateTime now)
|
|
|
+ public void UpdateTest(DateTime now)
|
|
|
{
|
|
|
this.Invoke(() =>
|
|
|
{
|
|
|
this.Text = now.ToString();
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ public void UpdateCar(Plateresult result)
|
|
|
+ {
|
|
|
+ this.Invoke(() =>
|
|
|
+ {
|
|
|
+ var carNo = result.license;
|
|
|
+ var base64String = result.imageFile;
|
|
|
+ var colorType = result.colorType;
|
|
|
+ //var image = Base64ToImage(base64String);
|
|
|
+
|
|
|
+ this.lastCarNo = carNo;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region Image <-> Base64
|
|
|
+
|
|
|
+ public static Image Base64ToImage(string base64String)
|
|
|
+ {
|
|
|
+ byte[] imageBytes = Convert.FromBase64String(base64String);
|
|
|
+ using var ms = new MemoryStream(imageBytes, 0, imageBytes.Length);
|
|
|
+ ms.Write(imageBytes, 0, imageBytes.Length);
|
|
|
+ Image image = Image.FromStream(ms, true);
|
|
|
+ return image;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static string ImageToBase64(Image image, ImageFormat format)
|
|
|
+ {
|
|
|
+ if (image == null) return string.Empty;
|
|
|
+
|
|
|
+ using var memoryStream = new MemoryStream();
|
|
|
+ image.Save(memoryStream, format);
|
|
|
+ var imageBytes = memoryStream.ToArray();
|
|
|
+ return Convert.ToBase64String(imageBytes);
|
|
|
+ }
|
|
|
+
|
|
|
#endregion
|
|
|
}
|
|
|
}
|