1.移植查询电压值功能

This commit is contained in:
hehaibing-1996
2024-05-28 20:09:24 +08:00
parent ac14b22507
commit 08850a2f15
9 changed files with 227 additions and 6 deletions

View File

@ -626,6 +626,15 @@ namespace WCS.BLL.HardWare
this.CurrentMode = Mode.;
}
public void QueryVoltage(int moduleId)
{
var moudle = Modules.Where(t => t.ModuleId == moduleId).First();
if (moudle != null)
{
moudle.QueryVoltage(TcpCleint);
}
}
void IShelfBase.SetCurrentMode()
{
throw new NotImplementedException();
@ -684,6 +693,15 @@ namespace WCS.BLL.HardWare
case 0x13://复位的返回信号
ResetReturnProcess(data, boardId, lightNumber);
break;
case 0x17://电压值1
QueryVoltageProcess(data, boardId, lightNumber);
break;
case 0x18://电压值2
QueryVoltageProcess(data, boardId, lightNumber);
break;
case 0x19://电压值3
QueryVoltageProcess(data, boardId, lightNumber);
break;
default:
;
break;
@ -1789,6 +1807,71 @@ namespace WCS.BLL.HardWare
module.CurrentMode = Mode.;
}
}
public void QueryVoltageProcess(byte[] data, int boardId, int lightNumber)
{
//第n帧
var n = (int)data[TcpCleint.PreFixLength + 3];
var voltage1 = (data[TcpCleint.PreFixLength + 4] << 8) + data[TcpCleint.PreFixLength + 5];
var voltage2 = (data[TcpCleint.PreFixLength + 6] << 8) + data[TcpCleint.PreFixLength + 7];
var voltage3 = (data[TcpCleint.PreFixLength + 8] << 8) + data[TcpCleint.PreFixLength + 9];
var number1 = (n - 1) * 3 + 1;
var number2 = (n - 1) * 3 + 2;
var number3 = (n - 1) * 3 + 3;
if (number1 <= 16)
{
var storeInfo1 = DbHelp.db.Queryable<StoreInfo>()
.Where(t => t.BoardId == boardId && t.LightNumber == number1 && t.ShelfId == ShelfId)
.First();
if (storeInfo1 != null)
{
if (data[TcpCleint.PreFixLength + 2] == 0x17)
storeInfo1.CurrentVoltage = voltage1;
else if (data[TcpCleint.PreFixLength + 2] == 0x18)
storeInfo1.OffsetVoltage = voltage1;
else
storeInfo1.StandardVoltage = voltage1;
DbHelp.db.Updateable(storeInfo1).ExecuteCommand();
}
}
if (number2 <= 16)
{
var storeInfo2 = DbHelp.db.Queryable<StoreInfo>()
.Where(t => t.BoardId == boardId && t.LightNumber == number2 && t.ShelfId == ShelfId)
.First();
if (storeInfo2 != null)
{
if (data[TcpCleint.PreFixLength + 2] == 0x17)
storeInfo2.CurrentVoltage = voltage2;
else if (data[TcpCleint.PreFixLength + 2] == 0x18)
storeInfo2.OffsetVoltage = voltage2;
else
storeInfo2.StandardVoltage = voltage2;
DbHelp.db.Updateable(storeInfo2).ExecuteCommand();
}
}
if (number1 <= 16)
{
var storeInfo3 = DbHelp.db.Queryable<StoreInfo>()
.Where(t => t.BoardId == boardId && t.LightNumber == number3 && t.ShelfId == ShelfId)
.First();
if (storeInfo3 != null)
{
if (data[TcpCleint.PreFixLength + 2] == 0x17)
storeInfo3.CurrentVoltage = voltage3;
else if (data[TcpCleint.PreFixLength + 2] == 0x18)
storeInfo3.OffsetVoltage = voltage3;
else
storeInfo3.StandardVoltage = voltage3;
DbHelp.db.Updateable(storeInfo3).ExecuteCommand();
}
}
}
#endregion
}

View File

@ -65,11 +65,22 @@ namespace WCS.BLL.HardWare
/// </summary>
public byte[] GoOutStockTakingModeData = { 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
/// <summary>
/// 复位命令
/// </summary>
public byte[] ResetData = { 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
/// <summary>
/// 查询当前电压值
/// </summary>
public byte[] VoltageSingleData = { 0x17, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
/// <summary>
/// 电压偏移值
/// </summary>
public byte[] OffsetSingleData = { 0x18, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
/// <summary>
/// 电压标准值
/// </summary>
public byte[] StandardSingleData = { 0x19, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
#endregion
public int ModuleId { get; set; }
public string ModuleCode { get; set; }
@ -370,5 +381,21 @@ namespace WCS.BLL.HardWare
tcpClient.Send(tcpClient.GenerateMessage(BoardId, ComfirmOutstoreData));
}
/// <summary>
/// 查询电压值
/// </summary>
/// <param name="tcpClient"></param>
public void QueryVoltage(TCPClient tcpClient)
{
Thread.Sleep(10);
Task.Run(() =>
{
tcpClient.Send(tcpClient.GenerateMessage(BoardId, VoltageSingleData));
Thread.Sleep(50);
tcpClient.Send(tcpClient.GenerateMessage(BoardId, StandardSingleData));
Thread.Sleep(50);
tcpClient.Send(tcpClient.GenerateMessage(BoardId, OffsetSingleData));
});
}
}
}

View File

@ -45,6 +45,13 @@ namespace WCS.BLL.Services.IService
/// <returns></returns>
public Task<ResponseCommon> disableOrEnableModule(DisableOrEnableModuleRequest request);
/// <summary>
/// 查询模组电压值
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public Task<ResponseCommon> queryModuleVoltage(QueryModuleVoltageRequest request);
/// <summary>
/// 查询库位列表

View File

@ -691,6 +691,12 @@ namespace WCS.BLL.Services.Service
outOrderMatDetails = outOrderMatDetails.Where(t => t.MatCode == matCode)
.ToList();
Logs.Write($"出库单{order.OrderNumber},本次亮灯物料{matCode}",LogsType.Outstore);
//分批次亮灯再计算一次出哪些货架 以免亮大灯不亮小灯
shelfIds = outOrderMatDetails.Select(t => t.StoreInfo.ShelfId)
.Distinct()
.ToList();
shelfs = ShelfManager.Shelves.Where(t => shelfIds.Contains(t.ShelfId)).ToList();
}
//相同物料不存在盘数超过n的情况剩余物料全部亮灯
else
@ -698,6 +704,8 @@ namespace WCS.BLL.Services.Service
//剩余物料全出
Logs.Write($"出库单{order.OrderNumber},剩余物料灯全亮!", LogsType.Outstore);
}
}
//对应的货架对应位置 进入出库模式 亮灯

View File

@ -397,6 +397,53 @@ namespace WCS.BLL.Services.Service
};
}
}
/// <summary>
/// 发送指令获取模组的电压值
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public async Task<ResponseCommon> queryModuleVoltage(QueryModuleVoltageRequest request)
{
try
{
var modules = await DbHelp.db.Queryable<ModuleInfo>().Where(t => request.MouduleIds.Contains(t.Id)).ToListAsync();
var isSend = false;
foreach (var module in modules)
{
var shelf = ShelfManager.Shelves.Where(t => t.ShelfId == module.ShelfId).FirstOrDefault();
if (shelf != null && shelf is SmartShelf)
{
var smartShelf = (SmartShelf)shelf;
smartShelf.QueryVoltage(module.Id);
isSend = true;
}
}
if (isSend)
return new ResponseCommon()
{
Code = 200,
Message = "Success"
};
else
return new ResponseCommon()
{
Code = 201,
Message = "操作失败:未找到对应模组"
};
}
catch (Exception ex)
{
return new ResponseCommon()
{
Code = 300,
Message = "操作失败:" + ex.Message
};
}
}
#endregion
#region
@ -534,6 +581,7 @@ namespace WCS.BLL.Services.Service
}
}
#endregion
}
}

View File

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace WCS.Model.ApiModel.StoreInfo
{
public class QueryModuleVoltageRequest : RequestBase
{
public List<int> MouduleIds { get; set; }
}
}

View File

@ -59,6 +59,13 @@ namespace WCS.WebApi.Controllers
{
return await _storeInfoService.disableOrEnableModule(request);
}
[Route("queryModuleVoltage")]
[HttpPost(Name = "queryModuleVoltage")]
public async Task<ResponseBase> queryModuleVoltage(QueryModuleVoltageRequest request)
{
return await _storeInfoService.queryModuleVoltage(request);
}
#endregion
#region

View File

@ -1,4 +1,5 @@
using Ping9719.WpfEx;
using HandyControl.Controls;
using Ping9719.WpfEx;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@ -14,7 +15,11 @@ using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using WCS.Model;
using WCS.Model.ApiModel.StoreInfo;
using .Api;
using .ViewModel;
using .Views.Controls;
namespace
{
@ -66,7 +71,7 @@ namespace 货架标准上位机
//dataGrid.UnselectAllCells(); // 取消选中所有单元格
}
}
catch(Exception ex)
catch (Exception ex)
{
Debug.WriteLine("SelectionChanged event handler failed: " + ex.Message);
}
@ -91,8 +96,33 @@ namespace 货架标准上位机
{
//先获取选中的模组
var module = viewModel.SelectedataGridItem;
#region
#region
try
{
var body = new QueryModuleVoltageRequest()
{
MouduleIds = new List<int>() { module.Id },
UserName = LocalStatic.CurrentUser,
DeviceType = LocalFile.Config.DeviceType,
};
var Result = ApiHelp.GetDataFromHttp<ResponseCommon>(LocalFile.Config.ApiIpHost + "storeInfo/queryModuleVoltage", body, "POST");
if (Result != null && Result.Code == 200)
{
Growl.Success("操作成功:可以进行查询!");
}
else if (Result != null)
{
Growl.Success(Result.Message);
}
}
catch (Exception ex)
{
Growl.Error("操作失败:" + ex.Message);
}
finally
{
}
#endregion
}
}

View File

@ -2,9 +2,9 @@
//连接不上加SslMode=none;
"MySql": "server=localhost;Database=db1;Uid=root;Pwd=123456;Convert Zero Datetime=True",
//货架服务器的IP和端口号
"ApiIpHost": "http://192.168.9.183:8888/",
"ApiIpHost": "http://127.0.0.1:8888/",
//WebSocket的地址
"WebSocketUrl": "ws://192.168.9.183:7789/ws",
"WebSocketUrl": "ws://127.0.0.1:7789/ws",
//货架分区
"GroupName": [ "C0"],
//设备类型 可以配置为每个电脑不一样