Commit 3a0bb722 张东亮

称重逻辑加入入库

1 个父辈 8fd26869
......@@ -29,13 +29,14 @@ namespace DeviceLibrary
static string server = Setting_Init.Server_Addr;
static string CID = Setting_Init.Server_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;
......@@ -61,13 +62,17 @@ namespace DeviceLibrary
LogUtil.info($"ServerConnectTimer_Elapsed:{ex}");
}
}
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)
......@@ -76,9 +81,10 @@ namespace DeviceLibrary
}
return null;
}
).Where(x=>!string.IsNullOrEmpty(x)));
).Where(x => !string.IsNullOrEmpty(x)));
}
public void SendInStoreRequest(string[] codelist,InOutDevice inOutDevice, bool printlog=false,double weight=0.0) {
public void SendInStoreRequest(string[] codelist, InOutDevice inOutDevice, bool printlog = false, double weight = 0.0)
{
if (RobotManage.InoutDebugMode)
return;
......@@ -87,13 +93,13 @@ namespace DeviceLibrary
var code = ProcessCode(codelist, 0, 0);
Operation operation = getLineBoxStatus();
operation.op = 1;
operation.data = new Dictionary<string, string>() { { "code", code }, { "boxId", StoreID.ToString() }, { "doorReelSignal", "1" } };
operation.data = new Dictionary<string, string>() { { "code", code + spiltStr + weight }, { "boxId", StoreID.ToString() }, { "doorReelSignal", "1" } };
Operation resultOperation = HttpHelper.Post(GetPostApi(), operation, false, printlog);
if (operation.seq != resultOperation.seq)
{
Thread.Sleep(500);
SendInStoreRequest(codelist, inOutDevice ,printlog);
SendInStoreRequest(codelist, inOutDevice, printlog);
return;
}
ResultProcess(resultOperation, inOutDevice);
......@@ -114,7 +120,7 @@ namespace DeviceLibrary
if (RobotManage.InoutDebugMode)
return;
Operation resultOperation = HttpHelper.Post(GetPostApi(), operation, false);
ResultProcess(resultOperation,null);
ResultProcess(resultOperation, null);
if (storeStatus == StoreStatus.OutStoreEnd ||
storeStatus == StoreStatus.OutStoreBoxEnd ||
......@@ -125,15 +131,15 @@ namespace DeviceLibrary
}
}
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;
......@@ -173,9 +179,10 @@ namespace DeviceLibrary
boxStatus.temperature = RobotManage.humitureControllers.Average(x => x.LastData.Temperate).ToString();
}
List<humidata> humidatas = new List<humidata>();
for (int i = 0; i < RobotManage.humitureControllers.Count; i++) {
for (int i = 0; i < RobotManage.humitureControllers.Count; i++)
{
var v = RobotManage.humitureControllers[i].LastData;
humidatas.Add(new humidata { id = (i+1).ToString(), humidity = v.Humidity.ToString(), temperature = v.Temperate.ToString() });
humidatas.Add(new humidata { id = (i + 1).ToString(), humidity = v.Humidity.ToString(), temperature = v.Temperate.ToString() });
}
boxStatus.data.Add("humiAndtempList", JsonConvert.SerializeObject(humidatas));
//状态
......@@ -202,7 +209,8 @@ namespace DeviceLibrary
//lineOperation.msgData["jp"] = lineOperation.msg;
//lineOperation.status = (int)StoreStatus.Warning;
}
else if (!RobotManage.isRunning){
else if (!RobotManage.isRunning)
{
sendmsg = "设备未启动";
}
......@@ -216,7 +224,8 @@ namespace DeviceLibrary
lineOperation.boxStatus.Add(StoreID, boxStatus);
return lineOperation;
}
class humidata {
class humidata
{
public string id;
public string humidity;
public string temperature;
......@@ -277,7 +286,7 @@ namespace DeviceLibrary
if (resultOperation != null)
getthtime = 0;
//LogUtil.info(JsonHelper.SerializeObject(resultOperation.data));
ResultProcess(resultOperation,null);
ResultProcess(resultOperation, null);
TimeSpan span = DateTime.Now - time;
if (span.TotalMilliseconds > 700)
{
......@@ -286,14 +295,15 @@ namespace DeviceLibrary
}
}
ConcurrentQueue<string> commandResultMsg = new ConcurrentQueue<string>();
void ResultProcess(Operation resultOperation, InOutDevice inOutDevice) {
void ResultProcess(Operation resultOperation, InOutDevice inOutDevice)
{
//发送状态信息到服务器
if (resultOperation == null)
{
//判断服务端是否返回出库操作
return;
}
if (resultOperation.op.Equals(1) && inOutDevice!=null)
if (resultOperation.op.Equals(1) && inOutDevice != null)
{
var barcode = "";
if (resultOperation.data.ContainsKey("code"))
......@@ -343,7 +353,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;
}
......@@ -351,10 +361,10 @@ namespace DeviceLibrary
if (inOutDevice.IsInStoreReady)
{
WarnMsg = "";
JobInfo inStoreJob = new JobInfo(message, posId,hSerial);
JobInfo inStoreJob = new JobInfo(message, posId, hSerial);
inOutDevice.StartInStore(inStoreJob);
//如果当前正在出入库中,需要记录下来,等待空闲时执行
LogUtil.info(StoreName + " 收到服务器入库命令:库位号【" + posId + "】二维码【" + message + "】 工单号[+"+ hSerial + "]开始入库!");
LogUtil.info(StoreName + " 收到服务器入库命令:库位号【" + posId + "】二维码【" + message + "】 工单号[+" + hSerial + "]开始入库!");
}
else
{
......@@ -369,7 +379,8 @@ namespace DeviceLibrary
LogUtil.info("服务器没有正确返回库位.");
inOutDevice.Rescan();
}
else {
else
{
LogUtil.info("扫码时状态错误.");
}
......@@ -388,13 +399,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)
{
......@@ -446,7 +457,7 @@ namespace DeviceLibrary
{
//出入库没有找到服务器发送的库位,需要打印日志方便查询原因
WarnMsg = StoreName + "出库未找库位:【" + posId + "】";
LogUtil.error( "收到服务器出库命令:未找到【" + posId + "】的库位信息");
LogUtil.error("收到服务器出库命令:未找到【" + posId + "】的库位信息");
continue;
}
else
......@@ -513,7 +524,8 @@ namespace DeviceLibrary
}
public void SendDoorStatus()
{
foreach(var dev in InOutDevice.InOutDeviceList) {
foreach (var dev in InOutDevice.InOutDeviceList)
{
HttpHelper.Post<DoorInfo>(GetPostApi("/api/xlc/updateDoorInfo"), dev.Value.DoorInfo, false);
}
}
......@@ -593,8 +605,10 @@ namespace DeviceLibrary
InStoreError = 14,
}
public class DoorInfo {
public DoorInfo() {
public class DoorInfo
{
public DoorInfo()
{
status = doorStatusE.free;
hasContainer = false;
hSerial = "";
......@@ -606,19 +620,21 @@ namespace DeviceLibrary
public string hSerial;
}
public enum doorIndexE {
XLC_2=2,
XLC_1=1,
public enum doorIndexE
{
XLC_2 = 2,
XLC_1 = 1,
}
public enum doorStatusE
{
free=1,
inStore=2,
outStore=3,
needBox=4,
fullBoxNeedLeave=5
free = 1,
inStore = 2,
outStore = 3,
needBox = 4,
fullBoxNeedLeave = 5
}
public class DoorTypeE {
public class DoorTypeE
{
public const string IN = "IN";
public const string OUT = "OUT";
public const string BOTH = "BOTH";
......
......@@ -23,7 +23,8 @@ namespace DeviceLibrary
{
get => MoveInfo.MoveStep == MoveStep.InWaitBoxLeave;
}
public void OpenDoor(MoveInfo moveInfo) {
public void OpenDoor(MoveInfo moveInfo)
{
LogUtil.info($"OpenDoor:low:{DO_Door_Down},up:{DO_Door_Up}");
MainMachine.CylinderMove(moveInfo, DO_Door_Down, DO_Door_Up, IO_VALUE.HIGH);
......@@ -49,7 +50,8 @@ namespace DeviceLibrary
}
return false;
}
public void Rescan() {
public void Rescan()
{
MoveInfo.NextMoveStep(MoveStep.In03);
MoveInfo.log("扫码失败重新扫码");
}
......@@ -126,13 +128,11 @@ namespace DeviceLibrary
}
else
{
MoveInfo.NextMoveStep(MoveStep.InWaitServerCallback);
MoveInfo.log($"已完成扫码,等待服务器反馈库位 Count={x.Count}");
MoveInfo.MoveParam.IsNg = false;
MoveInfo.MoveParam.codeInfos = x;
var cc = x.Select((a) => a.CodeStr);
mainMachine.ServerCM.SendInStoreRequest(cc.ToArray(), this, true);
MoveInfo.NextMoveStep(MoveStep.In05);
Lift.LiftDown(MoveInfo);
MoveInfo.log($"放下入料阻挡");
}
}
else if (MoveInfo.IsTimeOut(10))
{
......@@ -140,25 +140,6 @@ namespace DeviceLibrary
MoveInfo.log($"等待扫码超时,重新扫码");
}
break;
case MoveStep.InWaitServerCallback:
if (RobotManage.InoutDebugMode)
{
//Msg.add("等待手动选择入库库位", MsgLevel.info);
MoveInfo.NextMoveStep(MoveStep.StartInStore);
}
else if (MoveInfo.IsTimeOut(5))
Msg.add("等待服务器返回库位", MsgLevel.info);
else if (MoveInfo.IsTimeOut(15))
{
MoveInfo.NextMoveStep(MoveStep.Wait);
MoveInfo.log($"等待服务器返回库位超时");
}
break;
case MoveStep.StartInStore:
MoveInfo.NextMoveStep(MoveStep.In05);
Lift.LiftDown(MoveInfo);
MoveInfo.log($"放下入料阻挡");
break;
case MoveStep.In05:
Line.LineRun("work", false, 999);
MoveInfo.NextMoveStep(MoveStep.In06);
......@@ -179,7 +160,7 @@ namespace DeviceLibrary
{
MoveInfo.NextMoveStep(MoveStep.In09);
MiddleStop(MoveInfo, IO_VALUE.HIGH);
Line.LineRun("work",false, 2);
Line.LineRun("work", false, 2);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
}
else if (MoveInfo.IsTimeOut(15))
......@@ -195,6 +176,57 @@ namespace DeviceLibrary
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_EndMaterialTop_Check, IO_VALUE.HIGH));
break;
case MoveStep.In10:
MoveInfo.NextMoveStep(MoveStep.In11);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
break;
case MoveStep.In11:
//读取称重
bool res = BSQController.queryData(Config.WeightSensorPort, out double weight);
if (res)
{
if (weight > 0 && weight <= Config.StoreWeightLimited)
{
var x = InScanTask.Result;
{
MoveInfo.NextMoveStep(MoveStep.InWaitServerCallback);
MoveInfo.log($"已完成扫码,并称重完成 {weight}kg,等待服务器反馈库位 Count={x.Count}");
MoveInfo.MoveParam.IsNg = false;
MoveInfo.MoveParam.codeInfos = x;
var cc = x.Select((a) => a.CodeStr);
mainMachine.ServerCM.SendInStoreRequest(cc.ToArray(), this, true,weight);
}
}
else//超重
{
MoveInfo.NextMoveStep(MoveStep.Out05);
Lift.LiftDown(MoveInfo);
Msg.add("周转箱超重,退出", MsgLevel.alarm);
MoveInfo.log($"周转箱当前重量{weight},超重。顶升下降,出库该周转箱");
}
}
else
{
MoveInfo.NextMoveStep(MoveStep.In10);
MoveInfo.log($"获取周转箱重量失败,重新读取");
}
break;
case MoveStep.InWaitServerCallback:
if (RobotManage.InoutDebugMode)
{
//Msg.add("等待手动选择入库库位", MsgLevel.info);
MoveInfo.NextMoveStep(MoveStep.StartInStore);
}
else if (MoveInfo.IsTimeOut(5))
Msg.add("等待服务器返回库位", MsgLevel.info);
else if (MoveInfo.IsTimeOut(15))
{
MoveInfo.NextMoveStep(MoveStep.Wait);
MoveInfo.log($"等待服务器返回库位超时");
}
break;
case MoveStep.StartInStore:
MoveInfo.NextMoveStep(MoveStep.InWaitBoxLeave);
break;
case MoveStep.InWaitBoxLeave:
......@@ -252,7 +284,7 @@ namespace DeviceLibrary
Task.Delay(delay).Wait();
List<CodeInfo> LastCodeList;
CodeManager.CloseCamera(InOutSide == InOutSideE.Left ? Config.CameraName_Left : Config.CameraName_Right);
LastCodeList = CodeManager.CameraScan(new List<string> { InOutSide== InOutSideE.Left? Config.CameraName_Left: Config.CameraName_Right });
LastCodeList = CodeManager.CameraScan(new List<string> { InOutSide == InOutSideE.Left ? Config.CameraName_Left : Config.CameraName_Right });
return LastCodeList;
}));
......
......@@ -38,6 +38,9 @@ namespace DeviceLibrary
In08,
In09,
In10,
In11,
In12,
In13,
InWaitBoxLeave, //等待料箱入库
InBoxLeaved, //料箱已取走
InOverHead,
......
......@@ -31,8 +31,8 @@ namespace TheMachine
{
this.axisMoveControl1 = new DeviceLibrary.AxisMoveControl();
this.panel1 = new System.Windows.Forms.Panel();
this.configControl1 = new TheMachine.ConfigControl();
this.button1 = new System.Windows.Forms.Button();
this.configControl1 = new TheMachine.ConfigControl();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
......@@ -55,15 +55,6 @@ namespace TheMachine
this.panel1.Size = new System.Drawing.Size(1234, 924);
this.panel1.TabIndex = 2;
//
// configControl1
//
this.configControl1.Config = null;
this.configControl1.Location = new System.Drawing.Point(568, 3);
this.configControl1.Name = "configControl1";
this.configControl1.Size = new System.Drawing.Size(647, 474);
this.configControl1.TabIndex = 1;
this.configControl1.Tag = "not";
//
// button1
//
this.button1.Location = new System.Drawing.Point(16, 409);
......@@ -74,6 +65,15 @@ namespace TheMachine
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// configControl1
//
this.configControl1.Config = null;
this.configControl1.Location = new System.Drawing.Point(568, 3);
this.configControl1.Name = "configControl1";
this.configControl1.Size = new System.Drawing.Size(647, 474);
this.configControl1.TabIndex = 1;
this.configControl1.Tag = "not";
//
// AxisControl
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
......
......@@ -20,6 +20,7 @@ namespace TheMachine
{
public Form1()
{
Control.CheckForIllegalCrossThreadCalls = false;
InitializeComponent();
this.FormClosing += Form1_FormClosing;
this.Text = Setting_Init.App_Title + " " + Setting_Init.Server_CID;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!