Commit 90ed9115 张东亮

添加呼叫AGV按钮状态、更改上报出入库状态、添加校准库位缓存(FixBuffInfo)以在启动时进行检查状态

1 个父辈 ab64b6d5
......@@ -31,5 +31,9 @@ namespace OnlineStore.Common
public static string QRCodeCount = "QRCodeCount";
public static string CodeTimeOut = "CodeTimeOut";
/// <summary>
/// 校准库位的料盘信息
/// </summary>
public static string FixBuffInfo = "FixBuffInfo";
}
}
......@@ -291,5 +291,22 @@ namespace OnlineStore.Common
public static string disable = "disable";
public static string queueTaskCount="queueTaskCount";
/// <summary>
/// 贴标机交互按钮,出口 满料串取出
/// </summary>
public static string SendFullShelf = "SendFullShelf";
/// <summary>
/// 贴标机交互按钮,出口 空料串送入
/// </summary>
public static string NeedEmptySHelf = "NeedEmptySHelf";
/// <summary>
/// 贴标机交互按钮,入口 满料串送入
/// </summary>
public static string NeedFullShelf = "NeedFullShelf";
/// <summary>
/// 贴标机交互按钮,入口 空料串取出
/// </summary>
public static string SendEmptyShelf = "SendEmptyShelf";
}
}
......@@ -14,10 +14,12 @@ namespace DeviceLibrary
partial class ServerCommunication
{
volatile StoreStatus _storeStatus = StoreStatus.Debugging;
public StoreStatus storeStatus {
public StoreStatus storeStatus
{
get => _storeStatus;
set {
if (_storeStatus!= value)
set
{
if (_storeStatus != value)
LogUtil.info($"set storeStatus to {value}");
_storeStatus = value;
}
......@@ -25,13 +27,14 @@ namespace DeviceLibrary
static string server = ConfigHelper.Config.Get("http_server");
static string CID = ConfigHelper.Config.Get("CID");
int StoreID = 1;
string StoreName="";
string StoreName = "";
string WarnMsg = "";
private System.Timers.Timer serverConnectTimer = new System.Timers.Timer();
object serverclock = new object();
public ServerCommunication() {
public ServerCommunication()
{
serverConnectTimer.Interval = 1000;
serverConnectTimer.AutoReset = true;
serverConnectTimer.Enabled = true;
......@@ -65,17 +68,22 @@ namespace DeviceLibrary
{
LogUtil.info($"ServerConnectTimer_Elapsed:{ex}");
}
finally {
finally
{
//Monitor.Exit(serverConnectTimer);
}
}
public void StartConnectServer() {
public void StartConnectServer()
{
//serverConnectTimer.Enabled = true;
}public void StopConnectServer() {
}
public void StopConnectServer()
{
//serverConnectTimer.Enabled = false;
}
public void ProcessMsg(List<Msg> msg) {
public void ProcessMsg(List<Msg> msg)
{
WarnMsg = string.Join(",", msg.Select(x =>
{
if (x.msgLevel == MsgLevel.warning || x.msgLevel == MsgLevel.alarm)
......@@ -84,9 +92,10 @@ namespace DeviceLibrary
}
return null;
}
).Where(x=>!string.IsNullOrEmpty(x)));
).Where(x => !string.IsNullOrEmpty(x)));
}
public void SendInStoreRequest(string[] codelist, ReelParam reel,bool printlog=false) {
public void SendInStoreRequest(string[] codelist, ReelParam reel, bool printlog = false)
{
if (RobotManage.InoutDebugMode)
return;
......@@ -97,7 +106,7 @@ namespace DeviceLibrary
operation.op = 1;
operation.data = new Dictionary<string, string>() { { "code", code }, { "boxId", StoreID.ToString() }, { "doorReelSignal", "1" } };
if (reel.PlateH==100 && ConfigHelper.Config.Get("Device_SingleInSingleOut",false))
if (reel.PlateH == 100 && ConfigHelper.Config.Get("Device_SingleInSingleOut", false))
{
//singleIn 单盘入库
operation.data.Add("singleIn", "true");
......@@ -123,7 +132,12 @@ namespace DeviceLibrary
Operation operation = getLineBoxStatus();
if (!string.IsNullOrEmpty(posid))
operation.boxStatus[StoreID].data.Add(ParamDefine.posId, posid);
if (storeStatus == StoreStatus.OutStoreEnd ||
storeStatus == StoreStatus.OutStoreBoxEnd ||
storeStatus == StoreStatus.InStoreEnd)
{
}
else
operation.boxStatus[StoreID].status = (int)storeStatus;
LogUtil.info(JsonHelper.SerializeObject(operation));
......@@ -136,7 +150,8 @@ namespace DeviceLibrary
LogUtil.info($"SendStoreState error,posid:{posid}, storeStatus:{storeStatus}");
return false;
}
if (operation.seq != resultOperation.seq) {
if (operation.seq != resultOperation.seq)
{
LogUtil.info($"SendStoreState seq error,posid:{posid}, storeStatus:{storeStatus}");
return false;
}
......@@ -144,26 +159,29 @@ namespace DeviceLibrary
LogUtil.info($"SendStoreState success,posid:{posid}, storeStatus:{storeStatus}");
ResultProcess(resultOperation);
if (storeStatus == StoreStatus.OutStoreEnd ||
storeStatus == StoreStatus.OutStoreBoxEnd ||
storeStatus == StoreStatus.InStoreEnd)
//if (storeStatus == StoreStatus.OutStoreEnd ||
// storeStatus == StoreStatus.OutStoreBoxEnd ||
// storeStatus == StoreStatus.InStoreEnd)
//{
// this.storeStatus = StoreStatus.StoreOnline;
//}
if (RobotManage.mainMachine.StringMoveInfo.MoveStep == MoveStep.StringOut_Released)
{
this.storeStatus = StoreStatus.StoreOnline;
}
}
return true;
}
public string spiltStr = "##";
private string ProcessCode(string[] codeList,int reelw,int reelh)
private string ProcessCode(string[] codeList, int reelw, int reelh)
{
string message = "";
//= 7x12 = CODE
foreach (string str in codeList)
{
string code = str.Replace("\r","");
code = code.Replace("\n","");
string code = str.Replace("\r", "");
code = code.Replace("\n", "");
//根据二维码开头获取固定尺寸
string codeSize = $"{reelw}x{reelh}";
message = message + "=" + "1+0x0-" + codeSize + "=" + code + spiltStr;
......@@ -185,7 +203,7 @@ namespace DeviceLibrary
lineOperation.status = 1;
lineOperation.data = new Dictionary<string, string>();
lineOperation.data=lineOperation.data.Concat(GetBtnStatus()).ToDictionary(x=>x.Key,v=>v.Value);
lineOperation.data = lineOperation.data.Concat(GetBtnStatus()).ToDictionary(x => x.Key, v => v.Value);
lineOperation.data = lineOperation.data.Concat(AgvStatus()).ToDictionary(x => x.Key, v => v.Value);
lineOperation.status = (int)storeStatus;
......@@ -226,8 +244,9 @@ namespace DeviceLibrary
//lineOperation.msgData["jp"] = lineOperation.msg;
//lineOperation.status = (int)StoreStatus.Warning;
}
else if (!RobotManage.isRunning){
sendmsg = crc.GetString("Res0001","设备未启动");
else if (!RobotManage.isRunning)
{
sendmsg = crc.GetString("Res0001", "设备未启动");
}
lineOperation.msg = sendmsg;
......@@ -293,13 +312,14 @@ namespace DeviceLibrary
}
}
if (lineOperation.status != laststatus) {
if (lineOperation.status != laststatus)
{
laststatus = lineOperation.status;
printlog = true;
}
Operation resultOperation = HttpHelper.Post(GetPostApi(), lineOperation,700, printlog);
Operation resultOperation = HttpHelper.Post(GetPostApi(), lineOperation, 700, printlog);
if (resultOperation != null)
getthtime = 0;
//LogUtil.info(JsonHelper.SerializeObject(resultOperation.data));
......@@ -311,7 +331,7 @@ namespace DeviceLibrary
}
}
}
public int queueTaskCount=-1;
public int queueTaskCount = -1;
ConcurrentQueue<string> commandResultMsg = new ConcurrentQueue<string>();
void ResultProcess(Operation resultOperation)
{
......@@ -449,9 +469,31 @@ namespace DeviceLibrary
map[ParamDefine.confirmReelOut] = ParamDefine.enable;
}
if (RobotManage.mainMachine.StringType== MainMachine.StringTypeE.Out || RobotManage.mainMachine.StringMoveInfo.MoveStep==MoveStep.Wait) {
if (RobotManage.mainMachine.StringType == MainMachine.StringTypeE.Out || RobotManage.mainMachine.StringMoveInfo.MoveStep == MoveStep.Wait)
{
map[ParamDefine.singleReelIn] = ParamDefine.enable;
}
//mimo呼叫agv按钮
map.Add(ParamDefine.SendEmptyShelf, ParamDefine.disable);
map.Add(ParamDefine.SendFullShelf, ParamDefine.disable);
map.Add(ParamDefine.NeedEmptySHelf, ParamDefine.disable);
map.Add(ParamDefine.NeedFullShelf, ParamDefine.disable);
if (RobotManage.mainMachine.StringState == MainMachine.StringStateE.None)
{
map[ParamDefine.NeedEmptySHelf] = ParamDefine.enable;
map[ParamDefine.NeedFullShelf] = ParamDefine.enable;
}
if (RobotManage.mainMachine.StringMoveInfo.MoveStep == MoveStep.StringOut_Released)
{
if (RobotManage.mainMachine.StringState == MainMachine.StringStateE.Full)
{
map[ParamDefine.SendFullShelf] = ParamDefine.enable;
}
else
{
map[ParamDefine.SendEmptyShelf] = ParamDefine.enable;
}
}
return map;
}
......@@ -486,7 +528,7 @@ namespace DeviceLibrary
{
//出入库没有找到服务器发送的库位,需要打印日志方便查询原因
//SetWarnMsg(ResourceControl.InStoreNoPosition, message, posId);
WarnMsg = crc.GetString(L.in_store_nothave_position,"入库未找到库位:") + posId;//0505
WarnMsg = crc.GetString(L.in_store_nothave_position, "入库未找到库位:") + posId;//0505
LogUtil.info("收到服务器入库命令:入库未找到库位:二维码【" + message + "】库位【" + posId + "】");
return;
}
......@@ -512,9 +554,10 @@ namespace DeviceLibrary
SendStoreState("", StoreStatus.InStoreError);
//RobotManage.mainMachine.ClampMoveInfo.NextMoveStep(MoveStep.NGOUT_01);
RobotManage.mainMachine.NGPuted(msg);
LogUtil.info("服务器没有正确返回库位. msg="+ msg);
LogUtil.info("服务器没有正确返回库位. msg=" + msg);
}
else {
else
{
}
......@@ -535,13 +578,13 @@ namespace DeviceLibrary
{
string maxHumidity = data[ParamDefine.maxHumidity];
string maxTemp = data[ParamDefine.maxTemperature];
LogUtil.info( "收到服务器温湿度预警值:maxHumidity=" + maxHumidity + ",maxTemperature=" + maxTemp);
LogUtil.info("收到服务器温湿度预警值:maxHumidity=" + maxHumidity + ",maxTemperature=" + maxTemp);
try
{
this.Max_Humidity = (float)Convert.ToDouble(maxHumidity);
this.Max_Temperature = (float)Convert.ToDouble(maxTemp);
LogUtil.info( "保存温湿度预警值:Max_Humidity=" + Max_Humidity + ",Max_Temperature=" + Max_Temperature);
LogUtil.info("保存温湿度预警值:Max_Humidity=" + Max_Humidity + ",Max_Temperature=" + Max_Temperature);
}
catch (Exception ex)
{
......@@ -585,13 +628,13 @@ namespace DeviceLibrary
{
//出入库没有找到服务器发送的库位,需要打印日志方便查询原因
WarnMsg = StoreName + "出库未找库位:【" + posId + "】";
LogUtil.error( "收到服务器出库命令:未找到【" + posId + "】的库位信息");
LogUtil.error("收到服务器出库命令:未找到【" + posId + "】的库位信息");
continue;
}
else
{
if (isSingleOut)
RobotManage.mainMachine.AddSingleStoreTask(posId,plateW,plateH);
RobotManage.mainMachine.AddSingleStoreTask(posId, plateW, plateH);
else
RobotManage.mainMachine.AddOutStoreTask(posId, plateW, plateH);
}
......
......@@ -210,6 +210,7 @@ namespace DeviceLibrary
break;
case MoveStep.StoreFIX04:
MoveInfo.NextMoveStep(MoveStep.StoreFIX05);
RobotManage.PutReelInFixPos(MoveInfo.MoveParam);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
break;
case MoveStep.StoreFIX05:
......@@ -226,6 +227,7 @@ namespace DeviceLibrary
break;
case MoveStep.StoreTS10:
MoveInfo.NextMoveStep(MoveStep.StoreTS11);
RobotManage.ClearReelInFixPos();
Middle_Axis.AbsMove(MoveInfo, To.Middle_P2, Config.Middle_P2_speed);
MoveInfo.log($"{storeMoveType}:行走机构到达目的地:{To.Middle_P2}");
UpDown_Axis.AbsMove(MoveInfo, To.UpDown_PH, Config.UpDown_P1_speed);
......
......@@ -535,6 +535,17 @@ namespace DeviceLibrary
ServerCM.storeStatus = StoreStatus.OutStoreExecute;
CloseFlipDoor(StoreMoveInfo);
}
else if((RobotManage.HasReelInFixPos(out ReelParam reelParam)) && boxTransport.IsComplateOrFree && ClampMoveInfo.MoveStep == MoveStep.Wait && ConfigHelper.Config.Get("Device_Use_Fixpos", false))
{
StoreMoveInfo.NewMove(MoveStep.StoreOut_NGPre);
StoreMoveInfo.MoveParam=reelParam.clone();
StoreMoveInfo.MoveParam.PosID = "NG";
StoreMoveInfo.MoveParam.IsNg = true;
StoreMoveInfo.MoveParam.NgMsg = "检测到校准库位有料盘信息,请人工确认";
StoreMoveInfo.log($"开始校准库位料盘出库");
ServerCM.storeStatus = StoreStatus.OutStoreExecute;
CloseFlipDoor(StoreMoveInfo);
}
runStatus = RunStatus.Running;
ServerCM.storeStatus = StoreStatus.StoreOnline;
break;
......
......@@ -16,8 +16,9 @@ namespace DeviceLibrary
StoreJobList OutStoreJobList = new StoreJobList($"批量");
StoreJobList OutSingleJobList = new StoreJobList($"单盘");
public void AddOutStoreTask(string posId,int plateW,int plateH) {
JobInfo jobInfo = new JobInfo("", posId,plateW,plateH);
public void AddOutStoreTask(string posId, int plateW, int plateH)
{
JobInfo jobInfo = new JobInfo("", posId, plateW, plateH);
OutStoreJobList.Enqueue(jobInfo);
LogUtil.info($"添加出库任务队列: {posId},当前任务数量: {OutStoreJobList.Count}");
}
......@@ -63,11 +64,11 @@ namespace DeviceLibrary
if (!boxTransport.IgnoreX09 && IOMonitor.IODebound(IO_Type.TrayCheck_Fixture, Config, IO_VALUE.HIGH, 1000))
{
Msg.add(crc.GetString("Res0004","收到出库任务,但料叉上有料,无法启动,请检查"), MsgLevel.alarm, ErrInfo.X09_BoxNotDetect);
Msg.add(crc.GetString("Res0004", "收到出库任务,但料叉上有料,无法启动,请检查"), MsgLevel.alarm, ErrInfo.X09_BoxNotDetect);
//RobotManage.UserPause("收到出库任务,但料叉上有料,无法启动,请检查");
}
else
Msg.add(crc.GetString("Res0004","收到出库任务,但料叉上有料,无法启动,请检查"), MsgLevel.warning);
Msg.add(crc.GetString("Res0004", "收到出库任务,但料叉上有料,无法启动,请检查"), MsgLevel.warning);
return;
}
else
......@@ -87,18 +88,18 @@ namespace DeviceLibrary
}
}
//判断有没有出库任务, 需要入库空闲, 出口空闲
else if (OutStoreJobList.Count>0 && boxTransport.IsComplateOrFree)
else if (OutStoreJobList.Count > 0 && boxTransport.IsComplateOrFree)
{
if (!boxTransport.IgnoreX09 && IOValue(IO_Type.TrayCheck_Fixture).Equals(IO_VALUE.HIGH))
{
if (!boxTransport.IgnoreX09 && IOMonitor.IODebound(IO_Type.TrayCheck_Fixture, Config, IO_VALUE.HIGH, 1000))
{
Msg.add(crc.GetString("Res0004","收到出库任务,但料叉上有料,无法启动,请检查"), MsgLevel.alarm, ErrInfo.X09_BoxNotDetect);
Msg.add(crc.GetString("Res0004", "收到出库任务,但料叉上有料,无法启动,请检查"), MsgLevel.alarm, ErrInfo.X09_BoxNotDetect);
//RobotManage.UserPause("收到出库任务,但料叉上有料,无法启动,请检查");
}
else
Msg.add(crc.GetString("Res0004","收到出库任务,但料叉上有料,无法启动,请检查"), MsgLevel.warning);
Msg.add(crc.GetString("Res0004", "收到出库任务,但料叉上有料,无法启动,请检查"), MsgLevel.warning);
return;
}
else
......@@ -110,7 +111,7 @@ namespace DeviceLibrary
StoreMoveInfo.MoveParam.PosID = jobInfo.PosId;
StoreMoveInfo.MoveParam.PlateH = jobInfo.plateH;
StoreMoveInfo.MoveParam.PlateW = jobInfo.plateW;
StoreMoveInfo.log($"开始出库任务:"+ jobInfo.ToStr());
StoreMoveInfo.log($"开始出库任务:" + jobInfo.ToStr());
ServerCM.storeStatus = StoreStatus.OutStoreExecute;
}
}
......@@ -118,7 +119,7 @@ namespace DeviceLibrary
case MoveStep.StoreIn01:
if (!ServerCM.SendStoreState(StoreMoveInfo.MoveParam.PosID, StoreStatus.InStoreExecute))
{
Msg.add(crc.GetString("Res0008","服务器连接异常"),MsgLevel.warning);
Msg.add(crc.GetString("Res0008", "服务器连接异常"), MsgLevel.warning);
return;
}
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn03);
......@@ -145,7 +146,7 @@ namespace DeviceLibrary
{
if (!ServerCM.SendStoreState(StoreMoveInfo.MoveParam.PosID, StoreStatus.InStoreEnd))
{
Msg.add(crc.GetString("Res0008","服务器连接异常"), MsgLevel.warning);
Msg.add(crc.GetString("Res0008", "服务器连接异常"), MsgLevel.warning);
return;
}
StoreMoveInfo.log($"料盘已到达目的地");
......@@ -159,7 +160,7 @@ namespace DeviceLibrary
case MoveStep.StoreOut10:
if (!ServerCM.SendStoreState(StoreMoveInfo.MoveParam.PosID, StoreStatus.OutStoreExecute))
{
Msg.add(crc.GetString("Res0008","服务器连接异常"), MsgLevel.warning);
Msg.add(crc.GetString("Res0008", "服务器连接异常"), MsgLevel.warning);
return;
}
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut11);
......@@ -178,7 +179,7 @@ namespace DeviceLibrary
{
if (!ServerCM.SendStoreState(StoreMoveInfo.MoveParam.PosID, StoreStatus.OutStoreBoxEnd))
{
Msg.add(crc.GetString("Res0008","服务器连接异常"), MsgLevel.warning);
Msg.add(crc.GetString("Res0008", "服务器连接异常"), MsgLevel.warning);
return;
}
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut12);
......@@ -194,7 +195,7 @@ namespace DeviceLibrary
{
if (!ServerCM.SendStoreState(StoreMoveInfo.MoveParam.PosID, StoreStatus.OutStoreEnd))
{
Msg.add(crc.GetString("Res0008","服务器连接异常"), MsgLevel.warning);
Msg.add(crc.GetString("Res0008", "服务器连接异常"), MsgLevel.warning);
return;
}
StoreMoveInfo.log($"料盘已到达目的地");
......@@ -218,8 +219,9 @@ namespace DeviceLibrary
break;
}
}
string StoreState() {
string state = crc.GetString(L.free,"空闲中");
string StoreState()
{
string state = crc.GetString(L.free, "空闲中");
if (StoreMoveInfo.MoveStep >= MoveStep.StoreOut10)
{
state = $"{crc.GetString(L.reel_outting, "出库中")},{crc.GetString(L.posnum, "出库中")}:{StoreMoveInfo.MoveParam.PosID}";
......
......@@ -183,6 +183,34 @@ namespace DeviceLibrary
else
LogUtil.info("用户取消忽略安全光栅");
}
#region 校准库位缓存
public static bool HasReelInFixPos(out ReelParam reelParam)
{
reelParam = null;
try
{
string fix = ConfigHelper.Config.Get(Setting_Init.FixBuffInfo,"");
if(!string.IsNullOrEmpty(fix))
{
reelParam=JsonHelper.DeserializeJsonToObject<ReelParam>(fix);
return true;
}
}
catch (Exception e)
{
LogUtil.error("解析校准库位缓存异常",e);
}
return false;
}
public static void PutReelInFixPos(ReelParam reelParam)
{
ConfigHelper.Config.Set(Setting_Init.FixBuffInfo,JsonHelper.SerializeObject(reelParam));
}
public static void ClearReelInFixPos()
{
ConfigHelper.Config.Set(Setting_Init.FixBuffInfo,"");
}
#endregion
}
public enum StoreType {
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!