Commit eced8df3 LN

同时出多工单修改。托盘信息保存到文件

1 个父辈 0de6a9c9
......@@ -64,6 +64,7 @@
<add key="Brush_Delay_Seconds" value="5" />
<add key ="SaveErrorImageToFile" value ="1"/>
<add key ="UseTrayCheck" value ="8,"/>
<add key ="ConfigPath_TrayList" value ="\LineConfig\TrayList.data"/>
</appSettings>
<!-- <log4net> -->
<!-- <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender"> -->
......
......@@ -38,19 +38,19 @@
this.label10 = new System.Windows.Forms.Label();
this.lblSelTrayNum = new System.Windows.Forms.Label();
this.panel1 = new System.Windows.Forms.Panel();
this.chbShunt = new System.Windows.Forms.CheckBox();
this.chbSaveImage = new System.Windows.Forms.CheckBox();
this.chbShunt2 = new System.Windows.Forms.CheckBox();
this.btnShunt2Reset = new System.Windows.Forms.Button();
this.btnShuntReset = new System.Windows.Forms.Button();
this.lblMoveInfo = new System.Windows.Forms.Label();
this.lblCID = new System.Windows.Forms.Label();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.chbShunt = new System.Windows.Forms.CheckBox();
this.chbShunt2 = new System.Windows.Forms.CheckBox();
this.chbTrayCheck = new System.Windows.Forms.CheckBox();
this.chbBuzzer = new System.Windows.Forms.CheckBox();
this.btnClearLog = new System.Windows.Forms.Button();
this.chbAGV = new System.Windows.Forms.CheckBox();
this.chbAutoRun = new System.Windows.Forms.CheckBox();
this.lblCID = new System.Windows.Forms.Label();
this.lblMoveInfo = new System.Windows.Forms.Label();
this.listView1 = new System.Windows.Forms.ListView();
this.logBox = new System.Windows.Forms.RichTextBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
......@@ -116,6 +116,8 @@
this.启用分流横移1ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator18 = new System.Windows.Forms.ToolStripSeparator();
this.启用分流横移2ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.自动保存托盘信息ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator19 = new System.Windows.Forms.ToolStripSeparator();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.groupBox1.SuspendLayout();
......@@ -230,18 +232,6 @@
this.panel1.Size = new System.Drawing.Size(165, 140);
this.panel1.TabIndex = 199;
//
// chbShunt
//
this.chbShunt.AutoSize = true;
this.chbShunt.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chbShunt.Location = new System.Drawing.Point(8, 61);
this.chbShunt.Name = "chbShunt";
this.chbShunt.Size = new System.Drawing.Size(120, 24);
this.chbShunt.TabIndex = 200;
this.chbShunt.Text = "禁用分流横移1";
this.chbShunt.UseVisualStyleBackColor = true;
this.chbShunt.CheckedChanged += new System.EventHandler(this.chbShunt_CheckedChanged);
//
// chbSaveImage
//
this.chbSaveImage.AutoSize = true;
......@@ -254,18 +244,6 @@
this.chbSaveImage.UseVisualStyleBackColor = true;
this.chbSaveImage.CheckedChanged += new System.EventHandler(this.chbSaveImage_CheckedChanged);
//
// chbShunt2
//
this.chbShunt2.AutoSize = true;
this.chbShunt2.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chbShunt2.Location = new System.Drawing.Point(8, 86);
this.chbShunt2.Name = "chbShunt2";
this.chbShunt2.Size = new System.Drawing.Size(120, 24);
this.chbShunt2.TabIndex = 202;
this.chbShunt2.Text = "禁用分流横移2";
this.chbShunt2.UseVisualStyleBackColor = true;
this.chbShunt2.CheckedChanged += new System.EventHandler(this.chbShunt2_CheckedChanged);
//
// btnShunt2Reset
//
this.btnShunt2Reset.BackColor = System.Drawing.Color.White;
......@@ -292,27 +270,6 @@
this.btnShuntReset.UseVisualStyleBackColor = false;
this.btnShuntReset.Click += new System.EventHandler(this.btnShuntReset_Click);
//
// lblMoveInfo
//
this.lblMoveInfo.AutoSize = true;
this.lblMoveInfo.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblMoveInfo.Location = new System.Drawing.Point(906, 9);
this.lblMoveInfo.Name = "lblMoveInfo";
this.lblMoveInfo.Size = new System.Drawing.Size(29, 17);
this.lblMoveInfo.TabIndex = 196;
this.lblMoveInfo.Text = "CID";
//
// lblCID
//
this.lblCID.AutoSize = true;
this.lblCID.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblCID.Location = new System.Drawing.Point(1230, 7);
this.lblCID.Name = "lblCID";
this.lblCID.Size = new System.Drawing.Size(33, 20);
this.lblCID.TabIndex = 95;
this.lblCID.Text = "CID";
this.lblCID.Visible = false;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.chbShunt);
......@@ -330,6 +287,30 @@
this.groupBox2.TabStop = false;
this.groupBox2.Visible = false;
//
// chbShunt
//
this.chbShunt.AutoSize = true;
this.chbShunt.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chbShunt.Location = new System.Drawing.Point(8, 61);
this.chbShunt.Name = "chbShunt";
this.chbShunt.Size = new System.Drawing.Size(120, 24);
this.chbShunt.TabIndex = 200;
this.chbShunt.Text = "禁用分流横移1";
this.chbShunt.UseVisualStyleBackColor = true;
this.chbShunt.CheckedChanged += new System.EventHandler(this.chbShunt_CheckedChanged);
//
// chbShunt2
//
this.chbShunt2.AutoSize = true;
this.chbShunt2.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chbShunt2.Location = new System.Drawing.Point(8, 86);
this.chbShunt2.Name = "chbShunt2";
this.chbShunt2.Size = new System.Drawing.Size(120, 24);
this.chbShunt2.TabIndex = 202;
this.chbShunt2.Text = "禁用分流横移2";
this.chbShunt2.UseVisualStyleBackColor = true;
this.chbShunt2.CheckedChanged += new System.EventHandler(this.chbShunt2_CheckedChanged);
//
// chbTrayCheck
//
this.chbTrayCheck.AutoSize = true;
......@@ -392,6 +373,27 @@
this.chbAutoRun.UseVisualStyleBackColor = true;
this.chbAutoRun.CheckedChanged += new System.EventHandler(this.chbAutoRun_CheckedChanged);
//
// lblCID
//
this.lblCID.AutoSize = true;
this.lblCID.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblCID.Location = new System.Drawing.Point(1230, 7);
this.lblCID.Name = "lblCID";
this.lblCID.Size = new System.Drawing.Size(33, 20);
this.lblCID.TabIndex = 95;
this.lblCID.Text = "CID";
this.lblCID.Visible = false;
//
// lblMoveInfo
//
this.lblMoveInfo.AutoSize = true;
this.lblMoveInfo.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblMoveInfo.Location = new System.Drawing.Point(906, 9);
this.lblMoveInfo.Name = "lblMoveInfo";
this.lblMoveInfo.Size = new System.Drawing.Size(29, 17);
this.lblMoveInfo.TabIndex = 196;
this.lblMoveInfo.Text = "CID";
//
// listView1
//
this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
......@@ -879,7 +881,9 @@
this.toolStripSeparator17,
this.启用分流横移1ToolStripMenuItem,
this.toolStripSeparator18,
this.启用分流横移2ToolStripMenuItem});
this.启用分流横移2ToolStripMenuItem,
this.toolStripSeparator19,
this.自动保存托盘信息ToolStripMenuItem});
this.运行参数ToolStripMenuItem.Name = "运行参数ToolStripMenuItem";
this.运行参数ToolStripMenuItem.Size = new System.Drawing.Size(86, 25);
this.运行参数ToolStripMenuItem.Text = "运行参数";
......@@ -887,58 +891,70 @@
// 开机自动启动ToolStripMenuItem
//
this.开机自动启动ToolStripMenuItem.Name = "开机自动启动ToolStripMenuItem";
this.开机自动启动ToolStripMenuItem.Size = new System.Drawing.Size(207, 26);
this.开机自动启动ToolStripMenuItem.Size = new System.Drawing.Size(208, 26);
this.开机自动启动ToolStripMenuItem.Text = "开机自动启动";
this.开机自动启动ToolStripMenuItem.Click += new System.EventHandler(this.开机自动启动ToolStripMenuItem_Click);
//
// toolStripSeparator15
//
this.toolStripSeparator15.Name = "toolStripSeparator15";
this.toolStripSeparator15.Size = new System.Drawing.Size(204, 6);
this.toolStripSeparator15.Size = new System.Drawing.Size(205, 6);
//
// 启用蜂鸣器ToolStripMenuItem
//
this.启用蜂鸣器ToolStripMenuItem.Name = "启用蜂鸣器ToolStripMenuItem";
this.启用蜂鸣器ToolStripMenuItem.Size = new System.Drawing.Size(207, 26);
this.启用蜂鸣器ToolStripMenuItem.Size = new System.Drawing.Size(208, 26);
this.启用蜂鸣器ToolStripMenuItem.Text = "启用蜂鸣器";
this.启用蜂鸣器ToolStripMenuItem.Click += new System.EventHandler(this.启用蜂鸣器ToolStripMenuItem_Click);
//
// toolStripSeparator16
//
this.toolStripSeparator16.Name = "toolStripSeparator16";
this.toolStripSeparator16.Size = new System.Drawing.Size(204, 6);
this.toolStripSeparator16.Size = new System.Drawing.Size(205, 6);
//
// aGVCancelStateToolStripMenuItem
//
this.aGVCancelStateToolStripMenuItem.Name = "aGVCancelStateToolStripMenuItem";
this.aGVCancelStateToolStripMenuItem.Size = new System.Drawing.Size(207, 26);
this.aGVCancelStateToolStripMenuItem.Size = new System.Drawing.Size(208, 26);
this.aGVCancelStateToolStripMenuItem.Text = "AGV cancelState";
this.aGVCancelStateToolStripMenuItem.Click += new System.EventHandler(this.aGVCancelStateToolStripMenuItem_Click);
//
// toolStripSeparator17
//
this.toolStripSeparator17.Name = "toolStripSeparator17";
this.toolStripSeparator17.Size = new System.Drawing.Size(204, 6);
this.toolStripSeparator17.Size = new System.Drawing.Size(205, 6);
//
// 启用分流横移1ToolStripMenuItem
//
this.启用分流横移1ToolStripMenuItem.Name = "启用分流横移1ToolStripMenuItem";
this.启用分流横移1ToolStripMenuItem.Size = new System.Drawing.Size(207, 26);
this.启用分流横移1ToolStripMenuItem.Size = new System.Drawing.Size(208, 26);
this.启用分流横移1ToolStripMenuItem.Text = "✔启用分流横移1";
this.启用分流横移1ToolStripMenuItem.Click += new System.EventHandler(this.启用分流横移1ToolStripMenuItem_Click);
//
// toolStripSeparator18
//
this.toolStripSeparator18.Name = "toolStripSeparator18";
this.toolStripSeparator18.Size = new System.Drawing.Size(204, 6);
this.toolStripSeparator18.Size = new System.Drawing.Size(205, 6);
//
// 启用分流横移2ToolStripMenuItem
//
this.启用分流横移2ToolStripMenuItem.Name = "启用分流横移2ToolStripMenuItem";
this.启用分流横移2ToolStripMenuItem.Size = new System.Drawing.Size(207, 26);
this.启用分流横移2ToolStripMenuItem.Size = new System.Drawing.Size(208, 26);
this.启用分流横移2ToolStripMenuItem.Text = "✔启用分流横移2";
this.启用分流横移2ToolStripMenuItem.Click += new System.EventHandler(this.启用分流横移2ToolStripMenuItem_Click);
//
// 自动保存托盘信息ToolStripMenuItem
//
this.自动保存托盘信息ToolStripMenuItem.Name = "自动保存托盘信息ToolStripMenuItem";
this.自动保存托盘信息ToolStripMenuItem.Size = new System.Drawing.Size(208, 26);
this.自动保存托盘信息ToolStripMenuItem.Text = "自动保存托盘信息";
this.自动保存托盘信息ToolStripMenuItem.Click += new System.EventHandler(this.自动保存托盘信息ToolStripMenuItem_Click);
//
// toolStripSeparator19
//
this.toolStripSeparator19.Name = "toolStripSeparator19";
this.toolStripSeparator19.Size = new System.Drawing.Size(205, 6);
//
// FrmLineStore
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
......@@ -1069,6 +1085,8 @@
private System.Windows.Forms.ToolStripMenuItem 启用分流横移1ToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator18;
private System.Windows.Forms.ToolStripMenuItem 启用分流横移2ToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator19;
private System.Windows.Forms.ToolStripMenuItem 自动保存托盘信息ToolStripMenuItem;
}
}
......@@ -110,6 +110,7 @@ namespace OnlineStore.AssemblyLine
Application.Exit();
}
TrayManager.InitFileData();
formLineStatus(false);
string title = ConfigAppSettings.GetValue(Setting_Init.App_Title);
this.Text = title;
......@@ -142,6 +143,14 @@ namespace OnlineStore.AssemblyLine
{
启用蜂鸣器ToolStripMenuItem.Text = "启用蜂鸣器";
}
if (TrayManager.DisTraySave)
{
自动保存托盘信息ToolStripMenuItem.Text = "自动保存托盘信息";
}
else
{
自动保存托盘信息ToolStripMenuItem.Text = gouStr + "自动保存托盘信息";
}
cmbTrayType.SelectedIndex = 0;
cmbTray.SelectedIndex = 0;
LogUtil.logBox = this.logBox;
......@@ -1024,14 +1033,15 @@ namespace OnlineStore.AssemblyLine
DialogResult resut = MessageBox.Show("确定手动清空所有托盘信息?", "提示", MessageBoxButtons.YesNo);
if (resut.Equals(DialogResult.Yes))
{
List<TrayInfo> tray = TrayManager.getTrayList();
LogUtil.info("-------------------点击:清空托盘。清空前打印托盘信息:");
foreach (TrayInfo t in tray)
{
LogUtil.info(t.ToStr());
}
//List<TrayInfo> tray = TrayManager.getTrayList();
//LogUtil.info("-------------------点击:清空托盘。清空前打印托盘信息:");
//foreach (TrayInfo t in tray)
//{
// LogUtil.info(t.ToStr());
//}
//TrayManager.ClearTrayInfo();
//LogUtil.info("-------------------点击:清空托盘。托盘内容已清空");
TrayManager.ClearTrayInfo();
LogUtil.info("-------------------点击:清空托盘。托盘内容已清空");
}
}
......@@ -1303,5 +1313,30 @@ namespace OnlineStore.AssemblyLine
}
LogUtil.info(Name + " 点击:" + 启用分流横移2ToolStripMenuItem.Text+ ",lineBean.DisableShunt2="+ lineBean.DisableShunt2);
}
private void 自动保存托盘信息ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!LoadOk)
{
return;
}
bool result = 自动保存托盘信息ToolStripMenuItem.Text.Contains(gouStr);
if (result.Equals(TrayManager.DisTraySave))
{
return;
}
TrayManager.DisTraySave = result;
ConfigAppSettings.SaveValue(Setting_Init.DisTraySave, (TrayManager.DisTraySave ? 1 : 0));
if (TrayManager.DisTraySave)
{
自动保存托盘信息ToolStripMenuItem.Text = "自动保存托盘信息";
}
else
{
自动保存托盘信息ToolStripMenuItem.Text = gouStr + " 自动保存托盘信息";
}
LogUtil.info(Name + " 点击:" + 自动保存托盘信息ToolStripMenuItem.Text);
}
}
}
2020120325
20210609
出库改为可以出多个工单。
流水线料盘移动到皮带线时进行判断
地址:
/rest/api/qisda/device/canReelToBelt
参数:
barcode: 料盘条码
返回:
{"code":0,"msg":"ok","data":true}
code: 0为正常,其他为异常,(未传参数, 未找到有效条码,多个有效条码)
msg:消息,
data: true 可以放上皮带线 false 继续留在环形线
20210603
扫码新算法更新。
20210325
等待托盘超时报警时,蜂鸣器响。
......@@ -8,12 +26,12 @@
2.入料机构点击暂停时只暂停入料,托盘继续处理。
3.入料机构提前获取库位号,提前拦截托盘。
20200305
20210305
进仓升降轴增加P3详细位置配置。需要修改配置文件。
扫码dll替换。
20200226
20210226
环形线更新文件 20210226-AssemblyLine-更新,能重启时帮忙更新下。
修改内容:
1.有料托盘需要入库时,若检测信号不亮,直接禁用托盘。
......@@ -24,7 +42,7 @@
5.料仓出库和料串入库 放料到托盘 时,如果是大于7寸的料盘,夹爪放松后夹紧一次,再放松。
20200225
20210225
1.托盘增加禁用功能,禁用的托盘可在(设备调试->查看禁用托盘)界面手动启用。
2.进仓界面增加启用托盘检测的勾选配置。
3.进仓启用托盘检测功能后,若拦截到入库托盘,需要等待托盘检测信号亮。拦截空托盘出库时,如果托盘检测信号亮,直接禁用托盘。
......
......@@ -99,5 +99,9 @@ namespace OnlineStore.Common
public static string SaveErrorImageToFile = "SaveErrorImageToFile";
public static string UseTrayCheck = "UseTrayCheck";
public static string ConfigPath_TrayList = "ConfigPath_TrayList";
public static string DisTraySave = "DisTraySave";
}
}
......@@ -165,6 +165,13 @@ namespace OnlineStore.DeviceLibrary
}
else if (trayInfo.InOrOutStore.Equals(ReelType.OutStore) && inoup.urgentReel.Equals(false) && inoup.cutReel.Equals(false))
{
bool needToBielt = SServerManager.canReelToBelt(Name, inoup.WareCode);
if (!needToBielt)
{
LogUtil.info(Name + $"工单料:{inoup.WareCode} canReelToBelt={needToBielt} ,暂不移到皮带线");
return null;
}
List<int> mustLine = new List<int>();
List<int> firstLine = new List<int>();
//urgentReel: true 表示紧急料,需要出到料串上
......@@ -329,6 +336,7 @@ namespace OnlineStore.DeviceLibrary
}
//出料中,需要拦盘
string outMsg = "";
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(5000));
InOutParam param = CheckIsNeedOutStore(out outMsg);
if (param != null)
{
......
......@@ -88,7 +88,7 @@ namespace OnlineStore.DeviceLibrary
if (serverResult == null)
{
msg = deviceName + " 【" + codeStr + "】结果:没有收到服务器反馈,调用 cancelPutInTask ";
cancelPutInTask(deviceName, codeStr,false);
cancelPutInTask(deviceName, codeStr, false);
return msg;
}
else if ((!string.IsNullOrEmpty(serverResult.msg)) || serverResult.result.Equals(0).Equals(false))
......@@ -303,7 +303,7 @@ namespace OnlineStore.DeviceLibrary
{
if (robotIndex <= 0)
{
return "robotIndex="+robotIndex;
return "robotIndex=" + robotIndex;
}
DateTime startTime = DateTime.Now;
Dictionary<string, string> paramMap = new Dictionary<string, string>();
......@@ -450,7 +450,7 @@ namespace OnlineStore.DeviceLibrary
if (data == null)
{
return msg = deviceName + " cancelPutInTask【 " + barcode + ","+ disablePos + "】 没有收到服务器反馈";
return msg = deviceName + " cancelPutInTask【 " + barcode + "," + disablePos + "】 没有收到服务器反馈";
}
else if (data.code.Equals(0).Equals(false))
{
......@@ -509,7 +509,7 @@ namespace OnlineStore.DeviceLibrary
if (serverResult == null)
{
result.Msg = deviceName + " 【" + codeStr + "】结果:没有收到服务器反馈,调用 cancelPutInTask ";
cancelPutInTask(deviceName, codeStr,false );
cancelPutInTask(deviceName, codeStr, false);
result.Param = new InOutParam(0, codeStr, "", height, width, true);
result.Param.rfid = rfid;
result.Param.InStoreNg = true;
......@@ -519,7 +519,7 @@ namespace OnlineStore.DeviceLibrary
else if ((!string.IsNullOrEmpty(serverResult.msg)) || serverResult.result.Equals(0).Equals(false))
{
result.Result = serverResult.result;
result.Msg = serverResult.msg;
result.Msg = serverResult.msg;
//result.Msg = deviceName + " 【" + codeStr + "】结果:" + serverResult.msg;
result.Param = new InOutParam(0, codeStr, "", height, width, true);
result.Param.rfid = rfid;
......@@ -546,7 +546,7 @@ namespace OnlineStore.DeviceLibrary
result.Param.rfid = rfid;
int storeId = result.Param.GetStoreId();
MoveEquip moveEquip = LineManager.Line.GetMoveByDId(storeId);
if (moveEquip!=null)
if (moveEquip != null)
{
if (LineManager.Line.IsReviceInPosId(moveEquip, posId))
{
......@@ -632,7 +632,7 @@ namespace OnlineStore.DeviceLibrary
paramMap.Add("deviceAlarmList", msgListStr);
string server = GetAddr(Addr_updateDeviceAlarmMsg, paramMap);
DateTime startTime = DateTime.Now;
string resultStr = HttpHelper.Post(server, "",5000);
string resultStr = HttpHelper.Post(server, "", 5000);
LogUtil.debug("updateDeviceAlarmMsg " + FormUtil.GetSpanStr(DateTime.Now - startTime) + " 【" + server + "】【" + resultStr + "】");
RfidData data = JsonHelper.DeserializeJsonToObject<RfidData>(resultStr);
......@@ -653,6 +653,57 @@ namespace OnlineStore.DeviceLibrary
}
return msg;
}
// 流水线料盘移动到皮带线时进行判断: 地址: /rest/api/qisda/device/canReelToBelt 参数:barcode: 料盘条码
private static string Addr_canReelToBelt = "/rest/api/qisda/device/canReelToBelt";
public static bool canReelToBelt(string deviceName, string barcode)
{
// 返回: // { "code":0,"msg":"ok","data":true}
// code: 0为正常,其他为异常,(未传参数, 未找到有效条码, 多个有效条码)
// msg:消息,
//data: true 可以放上皮带线 false 继续留在环形线。默认直接放到皮带线
try
{
Dictionary<string, string> paramMap = new Dictionary<string, string>();
paramMap.Add("barcode", barcode);
string server = GetAddr(Addr_canReelToBelt, paramMap);
DateTime startTime = DateTime.Now;
string resultStr = HttpHelper.Post(server, "");
LogUtil.debug($"{deviceName }canReelToBelt {FormUtil.GetSpanStr(DateTime.Now - startTime) } 【{ server }】【{resultStr }】");
ReturnData data = JsonHelper.DeserializeJsonToObject<ReturnData>(resultStr);
if (data != null)
{
bool result = Convert.ToBoolean(data.data);
if (data.code.Equals(0) && (!result))
{
return result;
} else if (!data.code.Equals(0))
{
LogUtil.error($"{deviceName }canReelToBelt【 { barcode }】 返回错误 :{ data.msg}={data.msg}");
}
}
}
catch (Exception ex)
{
LogUtil.error(deviceName + " " + ex.ToString());
}
return true;
}
}
public class ReturnData
{
// { "code":0,"msg":"ok","data":true}
public int code { get; set; }
public string msg { get; set; }
public object data { get; set; }
}
public class AlarmMsg
{
......
......@@ -5,15 +5,18 @@ using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
namespace OnlineStore.DeviceLibrary
{
public class TrayManager
{
public static bool DisTraySave = ConfigAppSettings.GetIntValue(Setting_Init.DisTraySave).Equals(1);
/// <summary>
/// 进仓5RFID缓存
/// </summary>
......@@ -110,6 +113,7 @@ namespace OnlineStore.DeviceLibrary
TrayInfo fixture = new TrayInfo(trayNum, isFull, inOrOut, param,ngMsg);
TrayInfoMap.TryAdd(trayNum, fixture);
}
SaveMapToFile();
}
public static void UpdateInStoreNG(int trayNum, bool isNg, string msg)
......@@ -120,6 +124,8 @@ namespace OnlineStore.DeviceLibrary
TrayInfoMap[trayNum].InoutPar.InStoreNg = isNg;
TrayInfoMap[trayNum].ShowMsg = msg;
TrayInfoMap[trayNum].LastUpdateTime = DateTime.Now;
SaveMapToFile();
}
}
......@@ -188,7 +194,15 @@ namespace OnlineStore.DeviceLibrary
public static void ClearTrayInfo()
{
List<TrayInfo> tray = TrayManager.getTrayList();
LogUtil.info("-------------------点击:清空托盘。清空前打印托盘信息:");
foreach (TrayInfo t in tray)
{
LogUtil.info(t.ToStr());
}
TrayInfoMap = new ConcurrentDictionary<int, TrayInfo>();
SaveMapToFile();
LogUtil.info("-------------------点击:清空托盘。托盘内容已清空");
}
/// <summary>
/// 只清空托盘的 入库任务,会取消入库任务
......@@ -268,6 +282,69 @@ namespace OnlineStore.DeviceLibrary
}
return false;
}
private static string FilePath = "";
public static void InitFileData()
{
TrayInfoMap = new ConcurrentDictionary<int, TrayInfo>();
if (DisTraySave)
{
LogUtil.error("禁用了托盘保存功能,不需要从文件夹加载托盘");
return;
}
FilePath = Application.StartupPath + ConfigAppSettings.GetValue(Setting_Init.ConfigPath_TrayList);
if (File.Exists(FilePath))
{
LogUtil.info("开始加载文件缓存托盘:" + FilePath);
string[] lines = FileEncoding.GetFileLines(FilePath);
foreach (string line in lines)
{
TrayInfo tray = JsonHelper.DeserializeJsonToObject<TrayInfo>(line);
if (tray != null && tray.TrayCode > 0 && tray.IsFull)
{
LogUtil.info("加载到缓存托盘:" + tray.ToStr());
TrayInfoMap.TryAdd(tray.TrayCode, tray);
if (tray.InOrOutStore.Equals(1) && tray.InoutPar.InStoreNg.Equals(false) && (!tray.InoutPar.PosId.Equals("")))
{
int storeId = tray.InoutPar.GetStoreId();
MoveEquip moveEquip = LineManager.Line.GetMoveByDId(storeId);
if (storeId > 0 && moveEquip != null)
{
lock (moveEquip.waitInListLock)
{
//如果当前正在出入库中,需要记录下来,等待空闲时执行
LogUtil.info(moveEquip.Name + " 将托盘入库任务[" + tray.TrayCode + "]: " + tray.InoutPar.ToStr() + "加入等待列表中!");
moveEquip.waitInStoreList.Add(tray.InoutPar);
}
}
}
}
}
LogUtil.info("托盘加载完成");
}
}
public static void SaveMapToFile()
{
try
{
List<TrayInfo> trayList = new List<TrayInfo>(TrayInfoMap.Values);
List<string> lineList = new List<string>();
foreach (TrayInfo tray in trayList)
{
string line = JsonHelper.SerializeObject(tray);
if (!string.IsNullOrEmpty(line))
{
lineList.Add(line);
}
}
FileEncoding.WritteFile(FilePath, lineList.ToArray());
}
catch (Exception ex)
{
LogUtil.error("SaveTrayToFile出错:" + ex.ToString());
}
}
}
}
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace OnlineStore.LoadCSVLibrary
{
public class FileEncoding
{
public static bool WritteFile(string filePath, string[] lines)
{
try
{
//备份保存
try
{
if (File.Exists(filePath))
{
FileInfo file = new FileInfo(filePath);
string date = DateTime.Now.ToString("yyyy-MM-dd");
string targetBackPath = @"C:\configBack\" + date + @"\";
if (!Directory.Exists(targetBackPath))
{
Directory.CreateDirectory(targetBackPath);
}
string fileName = file.Name;
string backFile = targetBackPath + fileName;
if (File.Exists(backFile))
{
File.Delete(backFile);
}
File.Copy(filePath, backFile, true);
}
}
catch (Exception e)
{
LogUtil.error(" WritteFile备份文件 filePath 出错:", e);
}
if (File.Exists(filePath))
{
File.Delete(filePath);
}
File.WriteAllLines(filePath, lines, Encoding.UTF8);
}
catch (Exception ex)
{
LogUtil.error(ex.ToString());
return false;
}
return true;
}
public static string[] GetFileLines(string filePath)
{
if (!File.Exists(filePath))
{
return new string[] { };
}
Encoding encoding = Encoding.UTF8;
if (!FileEncoding.GetType(filePath).Equals(Encoding.UTF8))
{
encoding = Encoding.GetEncoding("gb2312");
}
string[] lines = File.ReadAllLines(filePath, encoding);
return lines;
}
/// <summary>
/// 给定文件的路径,读取文件的二进制数据,判断文件的编码类型
/// </summary>
/// <param name=“FILE_NAME“>文件路径</param>
/// <returns>文件的编码类型</returns>
public static System.Text.Encoding GetType(string FILE_NAME)
{
FileStream fs = new FileStream(FILE_NAME, FileMode.Open, FileAccess.Read);
Encoding r = GetType(fs);
fs.Close();
return r;
}
/// <summary>
/// 通过给定的文件流,判断文件的编码类型
/// </summary>
/// <param name=“fs“>文件流</param>
/// <returns>文件的编码类型</returns>
public static System.Text.Encoding GetType(FileStream fs)
{
byte[] Unicode = new byte[] { 0xFF, 0xFE, 0x41 };
byte[] UnicodeBIG = new byte[] { 0xFE, 0xFF, 0x00 };
byte[] UTF8 = new byte[] { 0xEF, 0xBB, 0xBF }; //带BOM
Encoding reVal = Encoding.Default;
BinaryReader r = new BinaryReader(fs, System.Text.Encoding.Default);
int i;
int.TryParse(fs.Length.ToString(), out i);
byte[] ss = r.ReadBytes(i);
if (IsUTF8Bytes(ss) || (ss[0] == 0xEF && ss[1] == 0xBB && ss[2] == 0xBF))
{
reVal = Encoding.UTF8;
}
else if (ss[0] == 0xFE && ss[1] == 0xFF && ss[2] == 0x00)
{
reVal = Encoding.BigEndianUnicode;
}
else if (ss[0] == 0xFF && ss[1] == 0xFE && ss[2] == 0x41)
{
reVal = Encoding.Unicode;
}
r.Close();
return reVal;
}
/// <summary>
/// 判断是否是不带 BOM 的 UTF8 格式
/// </summary>
/// <param name=“data“></param>
/// <returns></returns>
private static bool IsUTF8Bytes(byte[] data)
{
int charByteCounter = 1; //计算当前正分析的字符应还有的字节数
byte curByte; //当前分析的字节.
for (int i = 0; i < data.Length; i++)
{
curByte = data[i];
if (charByteCounter == 1)
{
if (curByte >= 0x80)
{
//判断当前
while (((curByte <<= 1) & 0x80) != 0)
{
charByteCounter++;
}
//标记位首位若为非0 则至少以2个1开始 如:110XXXXX...........1111110X
if (charByteCounter == 1 || charByteCounter > 6)
{
return false;
}
}
}
else
{
//若是UTF-8 此时第一位必须为1
if ((curByte & 0xC0) != 0x80)
{
return false;
}
charByteCounter--;
}
}
if (charByteCounter > 1)
{
throw new Exception("非预期的byte格式");
}
return true;
}
}
}
......@@ -47,6 +47,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="CSVExection.cs" />
<Compile Include="FileEncoding.cs" />
<Compile Include="storeConfig\ConfigItemBase.cs" />
<Compile Include="storeConfig\ConfigProAttribute.cs" />
<Compile Include="storeConfig\config\Line_Config.cs" />
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!