Commit 693f71b1 LN

aoi界面打开时,关闭照明灯

1 个父辈 c12788e5
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using TSA_V.Common;
using TSA_V.LoadCSVLibrary;
namespace TSA_V.DeviceLibrary
{
public class LedLabelController
{
{
public static void OpenAll()
{
OpenOrCloseAll(true);
......@@ -37,10 +38,10 @@ namespace TSA_V.DeviceLibrary
{
string url = $"http://{ip}/wms/associate/lightTagsLed";
string json = JsonHelper.SerializeObject(getLedMaps(macs, ledvs));
Post(url, json,(open ? "打开所有":"关闭所有"));
Post(url, json, (open ? "打开所有" : "关闭所有"));
}
}
public static LabelInfo GetLabel(TSAVPosition position, ComponetInfo com, bool opendLed )
public static LabelInfo GetLabel(TSAVPosition position, ComponetInfo com, bool opendLed)
{
if (com == null)
{
......@@ -108,7 +109,7 @@ namespace TSA_V.DeviceLibrary
Dictionary<string, object> keyValuePairss = getLedMap(mac, ledrgb);
string json = JsonHelper.SerializeObject(keyValuePairss);
string value = $"[{json}]";
Post(url, value, mac + (openLed ?"开灯":"关灯"));
Post(url, value, mac + (openLed ? "开灯" : "关灯"));
}
public static void UpdateScreen(LabelInfo label)
{
......@@ -142,13 +143,13 @@ namespace TSA_V.DeviceLibrary
}
string json = JsonHelper.SerializeObject(dic);
string value = $"[{json}]";
Post(url, value,"更新屏幕");
Post(url, value, "更新屏幕");
}
public static async void Post(string url, string json, string opName = "")
public static async Task<string> Post(string url, string json, string opName = "")
{
try
{
{
using (var client = new HttpClient())
{
using (var request = new HttpRequestMessage(HttpMethod.Post, url))
......@@ -161,12 +162,14 @@ namespace TSA_V.DeviceLibrary
{
string jsonResponse = response.Content.ReadAsStringAsync().Result;
LogUtil.info($"电子屏 {opName} 发送{json} 结果 {response.IsSuccessStatusCode}: " + jsonResponse);
return jsonResponse;
}
else
{
string jsonResponse = response.Content.ReadAsStringAsync().Result;
LogUtil.info($"电子屏 {opName} 发送{json} 结果 {response.IsSuccessStatusCode}: " + jsonResponse);
}
LogUtil.info($"电子屏 {opName} 发送{json} 结果 {response.IsSuccessStatusCode}: " + jsonResponse);
return jsonResponse;
}
}
}
}
......@@ -175,6 +178,7 @@ namespace TSA_V.DeviceLibrary
{
LogUtil.info($"电子屏 {opName} 发送{json} 出错 {ex.ToString()}");
}
return "";
}
// {
// "mac":"99.96.19.64",
......@@ -194,89 +198,130 @@ namespace TSA_V.DeviceLibrary
// "ledstate":"0",
// "outtime":"0"
//}
private static List<DataInfo> queryState(string ip, List<string> ids)
{
try
{
if (ids == null)
{
ids = new List<string>();
}
string url = $"http://{ip}/wms/associate/queryTagsInRouterId";
string value = JsonHelper.SerializeObject(ids);
//private static void controlLed(string ip, string mac, bool openLed)
//{
// string ledrgb = openLed ? "ff00" : "0";
// using (var client = new HttpClient())
// {
// string url = $"http://{ip}/wms/associate/lightTagsLed";
// using (var requests = new HttpRequestMessage(HttpMethod.Post, url))
// {
// Dictionary<string, object> keyValuePairss = getLedMap(mac, ledrgb);
// string json = JsonHelper.SerializeObject(keyValuePairss);
// var contents = new StringContent($"[{json}]", null, "application/json");
// LogUtil.info($"电子屏 {ip}-{mac} : {(openLed ? "开灯" : "关灯")} url:{url}, 发送内容:{json}");
// requests.Content = contents;
// using (HttpResponseMessage response = client.SendAsync(requests).Result)
// {
// if (response.IsSuccessStatusCode)
// {
// string jsonResponse = response.Content.ReadAsStringAsync().Result;
// LogUtil.info($"电子屏 {ip}-{mac} : {(openLed ? "开灯" : "关灯")} 结果: " + jsonResponse);
// }
// else
// {
// LogUtil.info($"电子屏 {ip}-{mac} : {(openLed ? "开灯" : "关灯")} 结果: " + response.RequestMessage.ToString());
// }
Task<string> task = Post(url, value, "查询状态信息");
task.Wait();
string resutljson = task.Result;
ReturnData data = JsonHelper.DeserializeJsonToObject<ReturnData>(resutljson);
if (data != null && data.DataList != null)
{
return data.DataList;
}
return new List<DataInfo>();
// }
}
catch (Exception ex)
{
LogUtil.error($"查询标签{string.Join(",", ids)}状态出错:" + ex.ToString());
}
return new List<DataInfo>();
}
}
public class ReturnData
{
public List<DataInfo> DataList { get; set; }
/// <summary>
/// 返回码
/// </summary>
public int ResultCode { get; set; }
/// <summary>
/// 接口响应信息
/// </summary>
public string ResultMsg { get; set; }
}
// requests.Dispose();
// }
// }
// { "datalist": [
//{ "hardwareVersion": "4.5", "height": 128, "mac": "99.26.17.85", "manufacture": "CoreWind31", "power": 100, "productionBatch": "20-08-29", "routerId": 1, "rssi": -21, "screenType": 1, "serialNumber": "CNSHZH1000", "shopNumber": "A0015", "showStyle": "拣货模板单列", "softwareVersion": "7.0", "state": true, "status": 4, "tagRegisterEN": 1, "width": 296
//},{ "hardwareVersion": "4.5", "height": 128, "mac": "99.26.18.21", "manufacture": "CoreWind31", "power": 87, "productionBatch": "20-08-29", "routerId": 1, "rssi": -19, "screenType": 1, "serialNumber": "CNSHZH1000", "shopNumber": "A0015", "showStyle": "拣货模板单列", "softwareVersion": "7.0", "state": true, "status": 4, "tagRegisterEN": 1, "width": 296
//},{
// "hardwareVersion": "4.5", "height": 128, "mac": "99.26.18.36", "manufacture": "CoreWind31", "power": 100, "productionBatch": "20-08-29",
//"routerId": 1, "rssi": -25, "screenType": 1, "serialNumber": "CNSHZH1000", "shopNumber": "A0015", "showStyle": "拣货模板单列", "softwareVersion": "7.0", "state": true, "status": 4, "tagRegisterEN": 0, "width": 296
//}
//public static void UpdateScreen(LabelInfo label)
//{
// string ledrgb = label.openLed ? "ff00" : "0";
// using (var client = new HttpClient())
// {
// string url = $"http://{label.ip}/wms/associate/updateScreen";
// using (var request = new HttpRequestMessage(HttpMethod.Post, url))
// {
// Dictionary<string, object> dic = new Dictionary<string, object>();
// dic.Add("mac", label.mac);
// dic.Add("mappingtype", "868");
// dic.Add("styleid", 47);
// dic.Add("ledrgb", "0");
// dic.Add("ledstate", "0");
// dic.Add("outtime", "0");
// Dictionary<string, object> lmap = label.toMap();
// foreach (string key in lmap.Keys)
// {
// if (dic.ContainsKey(key))
// {
// dic[key] = lmap[key];
// }
// else
// {
// dic.Add(key, lmap[key]);
// }
// }
// string json = JsonHelper.SerializeObject(dic);
// var contents = new StringContent($"[{json}]", null, "application/json");
// LogUtil.info($"电子屏 {label.ip}-{label.mac} : 更改屏幕内容 url:{url}, 发送内容:{json}");
// request.Content = contents;
// using (HttpResponseMessage response = client.SendAsync(request).Result)
// {
// if (response.IsSuccessStatusCode)
// {
// string jsonResponse = response.Content.ReadAsStringAsync().Result;
// LogUtil.info($"电子屏 {label.ip}-{label.mac} : 更改屏幕结果: " + jsonResponse);
// }
// else
// {
// LogUtil.info($"电子屏 {label.ip}-{label.mac} : 更改屏幕失败: " + response.RequestMessage.ToString());
// }
// }
// }
// }
//],"resultCode": 10, "resultMsg": "success"
//}
}
public class DataInfo
{
/// <summary>
/// 硬件版本号
/// </summary>
public string HardwareVersion { get; set; }
/// <summary>
/// 分辨率(高)
/// </summary>
public int Height { get; set; }
/// <summary>
/// 标签id号
/// </summary>
public string Mac { get; set; }
/// <summary>
/// 型号标识
/// </summary>
public string Manufacture { get; set; }
/// <summary>
/// 标签电量
/// </summary>
public int Power { get; set; }
/// <summary>
/// 生产批次
/// </summary>
public string ProductionBatch { get; set; }
/// <summary>
/// 绑定基站ID
/// </summary>
public int RouterId { get; set; }
/// <summary>
/// 信号强度
/// </summary>
public int Rssi { get; set; }
/// <summary>
/// 屏幕类型
/// </summary>
public int ScreenType { get; set; }
/// <summary>
/// 序列号
/// </summary>
public string SerialNumber { get; set; }
/// <summary>
/// 所属店铺
/// </summary>
public string ShopNumber { get; set; }
/// <summary>
/// 使用模板名称
/// </summary>
public string ShowStyle { get; set; }
/// <summary>
/// 软件版本号
/// </summary>
public string SoftwareVersion { get; set; }
/// <summary>
/// 在线状态
/// </summary>
public bool State { get; set; }
/// <summary>
/// 更新状态
/// </summary>
public int Status { get; set; }
/// <summary>
/// 允许标签注册开关
/// </summary>
public int TagRegisterEN { get; set; }
/// <summary>
/// 分辨率(宽)
/// </summary>
public int Width { get; set; }
}
}
......@@ -30,7 +30,7 @@ namespace TSA_V
/// 检测结果,0=未知,1=OK,2=NG
/// </summary>
private int CheckResult =0;
private int waitSeconds = 1;
private int waitSeconds = 0;
public FrmAOICheck(AoiProject currAoi )
{
InitializeComponent();
......@@ -166,6 +166,8 @@ namespace TSA_V
{
camera = AccAOI.camera.CameraManager.hikNameList.ToArray().FirstOrDefault();
}
DateTime startTime = DateTime.Now;
LogUtil.info("AOICheck : 开始获取图片");
Image currImage = CameraManager.GetCamerImage(camera);
if (currImage == null)
......@@ -181,9 +183,13 @@ namespace TSA_V
if (currImage != null)
{
TimeSpan span1 = DateTime.Now - startTime;
LogUtil.info($"AOICheck : 图片获取完成, {Math.Round( span1.TotalMilliseconds,1)}ms, 开始check");
//Bitmap bitmap = new Bitmap(currImage);
Image outImage = null;
List<ResultBean> resultBean = CurrProject.CheckAll(currImage, out outImage);
span1 = DateTime.Now - startTime;
LogUtil.info($"AOICheck : check完成, {Math.Round(span1.TotalMilliseconds, 1)}ms");
currImage.Dispose();
ResultList = resultBean;
if (outImage != null)
......
......@@ -338,11 +338,13 @@ namespace TSA_V
LogUtil.info(" 工作完成, 清理投影内容,弹出 提示框提示进入AOI检测 ,设置 AOIopen = true;");
ProjectorProcess.AOIopen = true;
IOManager.IOMove(IOManager.Device_Led, IO_VALUE.LOW);
FrmProjectorScreen.instance.ClearPoint();
//IOManager.IOMove(IOManager.Camera_Led, IO_VALUE.HIGH);
FrmAOICheck frm = new FrmAOICheck(CurrProject);
frm.ShowDialog();
IOManager.IOMove(IOManager.Device_Led, IO_VALUE.HIGH );
ProjectorProcess.AOIopen = false;
LogUtil.info("AOI检测已关闭 ,设置 AOIopen = false;");
// IOManager.IOMove(IOManager.Camera_Led, IO_VALUE.LOW);
......@@ -899,12 +901,14 @@ namespace TSA_V
if (TSAVBean.IsNeedAOI)
{
LogUtil.info("点击【" + btnCamera.Text + "】,清理投影内容,进入AOI检测 , 设置AOIopen = true");
IOManager.IOMove(IOManager.Device_Led, IO_VALUE.LOW);
ProjectorProcess.AOIopen = true;
FrmProjectorScreen.instance.ClearPoint();
// IOManager.IOMove(IOManager.Camera_Led, IO_VALUE.HIGH);
FrmAOICheck frm = new FrmAOICheck(CurrProject);
frm.ShowDialog();
ProjectorProcess.AOIopen = false;
IOManager.IOMove(IOManager.Device_Led, IO_VALUE.HIGH);
LogUtil.info("点击【" + btnCamera.Text + "】,AOI检测已关闭 , 设置AOIopen = false");
// IOManager.IOMove(IOManager.Camera_Led, IO_VALUE.LOW);
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!