Commit e57b9fab 刘韬

增加取标贴标吹气

1 个父辈 d0fcb671
using log4net;
using ConfigHelper;
using log4net;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
......@@ -13,9 +14,32 @@ using System.Windows.Forms.Layout;
namespace OnlineStore
{
public class CrcObject {
public string msg;
public string key;
public CrcObject(string key, string msg)
{
this.key = key;
this.msg = msg;
}
public override string ToString()
{
return msg.ToString();
}
public static implicit operator string(CrcObject m1)
{
if (m1 == null)
return null;
return m1.msg;
}
}
public class crc : CodeResourceControl
{
}
public class CodeResourceControl
{
......@@ -166,12 +190,12 @@ namespace OnlineStore
{
return GetString(id.ToString(), defaultStr);
}
public static string GetString(string id, string defaultStr)
public static CrcObject GetString(string id, string defaultStr)
{
string strCurLanguage = defaultStr;
var haslang = getLangRes(CurrLanguage);
if (!haslang) {
return strCurLanguage;
return new CrcObject(id, strCurLanguage);
}
try
{
......@@ -200,7 +224,7 @@ namespace OnlineStore
{
strCurLanguage = "";
}
return strCurLanguage;
return new CrcObject(id, strCurLanguage);
}
public static string GetString(string id, string defaultStr, params object[] param)
{
......@@ -314,7 +338,7 @@ namespace OnlineStore
var newStr = GetString(GetTextIdStr(className, con.Name), txt);
if (!newStr.Equals(""))
{
Con_SetTxt(con, newStr.Replace("\\n", "\n"));
Con_SetTxt(con, newStr.ToString().Replace("\\n", "\n"));
//haslang = true;
}
}
......
......@@ -35,6 +35,8 @@ namespace OnlineStore.Common
public static MyConfig<string> Device_DauxiKS107_Port = "COM3";
[MyConfigComment("RFID IP")]
public static MyConfig<string> Device_RFID_IP = "192.168.110.21";
[MyConfigComment("RFID IP2")]
public static MyConfig<string> Device_RFID_IP2 = "192.168.110.21";
[MyConfigComment("是否启用校准库位")]
public static MyConfig<bool> Device_Use_Fixpos = false;
[MyConfigComment("屏蔽日志窗口")]
......
......@@ -291,6 +291,8 @@ namespace OnlineStore.Common
public static string disable = "disable";
public static string queueTaskCount="queueTaskCount";
public static string selfAudit = "selfAudit";
public static string selfAuditException = "selfAuditException";
public static string inDoorStatus= "inDoorStatus";
public static string outDoorStatus= "outDoorStatus";
public static string open= "open";
......
......@@ -107,7 +107,7 @@
<Compile Include="theMachine\MainMachine _AutoInOutTest.cs" />
<Compile Include="theMachine\MainMachine_Labeling.cs" />
<Compile Include="theMachine\MainMachine_RFIDSelftest.cs" />
<Compile Include="theMachine\MainMachine_StoreDemo.cs" />
<Compile Include="theMachine\MainMachine_Store.cs" />
<Compile Include="theMachine\MainMachine _IOMonitor.cs" />
<Compile Include="theMachine\MainMachine _LedProcess.cs" />
<Compile Include="theMachine\MainMachine.cs" />
......
using OnlineStore.Common;
using OnlineStore;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
......@@ -36,6 +37,9 @@ namespace DeviceLibrary
Msg = "";
string portName = Config.DeviceName;
short slvAddr = Config.GetAxisValue();
if (AxisManager.IsServeoOn(portName, slvAddr)) {
return true;
}
AxisManager.AlarmClear(portName, slvAddr);
Thread.Sleep(50);
AxisManager.ServoOn(portName, slvAddr);
......@@ -79,7 +83,7 @@ namespace DeviceLibrary
else
{
AxisManager.ServoOff(portName, slvAddr);
msg = "打开轴" + Config.Explain + "失败 ";
msg = crc.GetString("Res0158.2bf5c941","打开轴") + Config.Explain + crc.GetString("Res0159.33d2a704","失败 ");
LogUtil.info(AxisName + msg);
return false;
}
......@@ -128,7 +132,7 @@ namespace DeviceLibrary
if (ForceSafeCheck && !IsSafe(targetPosition,out string msg))
{
Msg.add(msg, MsgLevel.alarm);
Msg.add(Config.ProName,msg, MsgLevel.alarm);
RobotManage.UserPause(msg);
return;
}
......@@ -158,7 +162,7 @@ namespace DeviceLibrary
if (ForceSafeCheck && !IsSafe(targetPosition, out string msg))
{
Msg.add(msg, MsgLevel.alarm);
Msg.add(Config.ProName, msg, MsgLevel.alarm);
LogUtil.info(AxisName + $" 不在安全点无法运行:{msg}");
RobotManage.UserPause(msg);
return false;
......@@ -224,7 +228,7 @@ namespace DeviceLibrary
int isAlarm = AxisManager.GetAlarmStatus(deviceName, axisNo);
if (isAlarm.Equals(1))
{
clearMsg = "清理报警,";
clearMsg = crc.GetString("Res0160.cbd5d752","清理报警,");
AxisManager.AlarmClear(deviceName, axisNo);
Thread.Sleep(200);
AxisManager.ServoOn(deviceName, axisNo);
......@@ -273,7 +277,7 @@ namespace DeviceLibrary
}
else
{
msg = MoveInfo.Name + " " + MoveInfo.MoveStep + axis.DisplayStr + ",收到原点完成信号,当前位置[" + outCount + "],误差过大,需要报警";
msg = MoveInfo.Name + " " + MoveInfo.MoveStep + axis.DisplayStr + crc.GetString("Res0161.405c5a9e",",收到原点完成信号,当前位置[") + outCount + crc.GetString("Res0162.6658614e","],误差过大,需要报警");
LogUtil.error(msg);
}
}
......@@ -467,4 +471,4 @@ namespace DeviceLibrary
}
}
}
\ No newline at end of file
using OnlineStore.Common;
using OnlineStore;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO.Ports;
using System.Linq;
using System.Text;
......@@ -17,13 +19,12 @@ public class DauxiKS107Controller
private SerialPort _serialPort = null;
string comPortName;
System.Timers.Timer timer;
public bool IsAlarm;
public int Distance;
public DauxiKS107Controller()
{
timer = new System.Timers.Timer(5*60*1000);
timer = new System.Timers.Timer(5*1000);
timer.Elapsed += Timer_Elapsed;
timer.AutoReset = true;
IsAlarm = false;
}
~DauxiKS107Controller() {
LogUtil.info($"液位传感器退出");
......@@ -34,11 +35,29 @@ public class DauxiKS107Controller
}
private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
Quary(out int value, out string errmsg);
LogUtil.info($"读取到液位:{value}mm,err:{errmsg}");
if (value > 0)
bool readok = true;
for (int i = 0; i < 5; i++)
{
IsAlarm = value < 180;
if (Quary(out int value, out string errmsg))
{
Debug.WriteLine($"读取到液位:{value}mm,err:{errmsg}");
readok = true;
if (value > 0)
{
Distance = value;
return;
}
}
else {
readok = false;
}
}
if (!readok)
{
LogUtil.info($"液位传感器读取失败,重新打开");
if (!OpenPort(comPortName, out string errmsg)) {
LogUtil.info($"液位传感器打开失败:"+ errmsg);
}
}
}
......@@ -50,14 +69,19 @@ public class DauxiKS107Controller
{
comPortName = _comport;
_serialPort = new SerialPort(comPortName, baudRate, parity, dataBits, stopBits);
_serialPort.RtsEnable = true; //自动请求
_serialPort.ReadTimeout = 100;//超时
errmsg = "";
bool ok = false;
//如果串口是打开的,先关闭
if (_serialPort == null)
{
_serialPort = new SerialPort(comPortName, baudRate, parity, dataBits, stopBits);
_serialPort.RtsEnable = true; //自动请求
_serialPort.ReadTimeout = 100;//超时
}
if (_serialPort.IsOpen)
_serialPort.Close();
errmsg = "";
bool ok = false;
try
{
//打开串口
......@@ -84,7 +108,7 @@ public class DauxiKS107Controller
static byte[] quarycommand = new byte[] { 0xe8, 0x02, 0xb0 };
public bool Quary(out int value, out string errmsg) {
errmsg = "";
byte[] buf = new byte[50];
byte[] buf = new byte[8];
value = 0;
try
{
......@@ -98,6 +122,7 @@ public class DauxiKS107Controller
}
else
{
errmsg = crc.GetString("Res0170.6832e9a0","返回数据不正确:")+BitConverter.ToString(buf);
return false;
}
}
......@@ -108,4 +133,3 @@ public class DauxiKS107Controller
return true;
}
}
......@@ -32,6 +32,7 @@ namespace DeviceLibrary
upspeed = _upspeed;
StrokeLength = _StrokeLength;
SafetyDevice.AddDevice(this);
TurnWork = Task.Run(() => { });
}
public bool isAtTOP
{
......
......@@ -32,7 +32,8 @@ namespace DeviceLibrary
string WarnMsg = "";
private System.Timers.Timer serverConnectTimer = new System.Timers.Timer();
public bool selfAudit = false;
public bool selfAuditException = false;
object serverclock = new object();
public ServerCommunication()
{
......@@ -347,7 +348,20 @@ namespace DeviceLibrary
queueTaskCount = -1;
}
}
if (dataMap.ContainsKey(ParamDefine.selfAudit))
{
if (!string.IsNullOrEmpty(dataMap[ParamDefine.selfAudit].ToString()))
selfAudit = true;
}
else
selfAudit = false;
if (dataMap.ContainsKey(ParamDefine.selfAuditException))
{
if (dataMap[ParamDefine.selfAuditException].ToString()=="true")
selfAuditException = true;
}
else
selfAuditException = false;
if (dataMap.ContainsKey(ParamDefine.openInLock) && dataMap[ParamDefine.openInLock].Equals(ParamDefine.doit))
{
......@@ -359,11 +373,19 @@ namespace DeviceLibrary
{
LogUtil.info(StoreName + "收到服务器命令:closeInLock=doit");
IOManager.IOMove(IO_Type.Entry_Drawer_Lock, IO_VALUE.HIGH);
RobotManage.mainMachine.NGInfoList = new List<ReelParam>();
Setting_Init.Runtime_NGINFOLIST = JsonConvert.SerializeObject(RobotManage.mainMachine.NGInfoList);
RobotManage.mainMachine.StoreMoveInfo.NewMove(MoveStep.StoreIn01);
RobotManage.mainMachine.StoreMoveInfo.log(StoreName + " 服务器锁定抽屉,开始入库");
result = "";
if (!selfAuditException)
{
RobotManage.mainMachine.newDrawer = false;
RobotManage.mainMachine.NGInfoList = new List<ReelParam>();
Setting_Init.Runtime_NGINFOLIST = JsonConvert.SerializeObject(RobotManage.mainMachine.NGInfoList);
RobotManage.mainMachine.StoreMoveInfo.NewMove(MoveStep.StoreIn01);
RobotManage.mainMachine.StoreMoveInfo.log(StoreName + " 服务器锁定抽屉,开始入库");
}
else
{
RobotManage.mainMachine.StoreMoveInfo.log(StoreName + " 服务器锁定抽屉,有自检错误,不允许入库");
result = crc.GetString("Res0171.14f1eca7","有自检错误,仅锁入库抽屉");
}
}
if (dataMap.ContainsKey(ParamDefine.openOutLock) && dataMap[ParamDefine.openOutLock].Equals(ParamDefine.doit))
......@@ -412,7 +434,7 @@ namespace DeviceLibrary
&& RobotManage.mainMachine.StoreMoveInfo.MoveStep == MoveStep.Wait)
{
map[ParamDefine.inDoorStatus] = ParamDefine.close;
}else if (IOManager.IOValue(IO_Type.Entry_Drawer_Lock).Equals(IO_VALUE.LOW)
}else if ((RobotManage.mainMachine.newDrawer || IOManager.IOValue(IO_Type.Entry_Drawer_Lock).Equals(IO_VALUE.LOW))
&& RobotManage.mainMachine.StoreMoveInfo.MoveStep == MoveStep.Wait)
{
map[ParamDefine.inDoorStatus] = ParamDefine.open;
......@@ -554,7 +576,17 @@ namespace DeviceLibrary
}
else
{
RobotManage.mainMachine.AddOutStoreTask(code.ToString(), posId);
var ngReel = false;
object ngMsg = "";
if (data.ContainsKey("ngReel") && data["ngReel"].ToString().ToLower() == "true")
{
ngReel = true;
data.TryGetValue("ngMsg", out ngMsg);
}
RobotManage.mainMachine.AddOutStoreTask(code.ToString(), posId, ngReel, ngMsg.ToString());
}
}
TimeSpan span = DateTime.Now - time;
......@@ -633,6 +665,103 @@ namespace DeviceLibrary
}
return msg;
}
public JobInfo SelfAudit_getNetPos()
{
string msg = "";
try
{
Dictionary<string, string> paramMap = new Dictionary<string, string>();
paramMap.Add("cid", CID);
string server = GetAddr("/rest/device/selfAudit/getNetPos", paramMap);
DateTime startTime = DateTime.Now;
string resultStr = HttpHelper.Post(server, "");
LogUtil.info("SelfAudit:" + FormUtil.GetSpanStr(DateTime.Now - startTime) + " 【" + server + "】【" + resultStr + "】");
ResultData data = JsonHelper.DeserializeJsonToObject<ResultData>(resultStr);
if (data == null)
{
return null;
}
else if (data.code.Equals(0).Equals(false))
{
return null;
}
try
{
//data 中包含:posName 库位号,barcode 条码,batchNo 盘点批次号
var d = JsonConvert.DeserializeObject<Dictionary<string, string>>(data.data.ToString());
var posName = d["posName"];
var barcode = d["barcode"];
var batchNo = d["batchNo"];
var j = new JobInfo(barcode, posName);
j.batchNo = batchNo;
return j;
}
catch (Exception ex) {
LogUtil.info("SelfAudit:" + data.data.ToString());
return null;
}
}
catch (Exception ex)
{
LogUtil.error("SelfAudit: " + ex.ToString());
}
return null;
}
public string SelfAudit_posOutEnd(string posName)
{
string msg = "";
try
{
Dictionary<string, string> paramMap = new Dictionary<string, string>();
paramMap.Add("posName", posName);
string server = GetAddr("/rest/device/selfAudit/posOutEnd", paramMap);
string resultStr = HttpHelper.Post(server, "");
ResultData data = JsonHelper.DeserializeJsonToObject<ResultData>(resultStr);
if (data == null)
return msg = " DisabledPos【 " + posName + "】 没有收到服务器反馈";
else if (data.code.Equals(0).Equals(false))
return msg = " DisabledPos【 " + posName + "】 :" + data.msg;
return "";
}
catch (Exception ex)
{
LogUtil.error("DisabledPos: " + ex.ToString());
}
return msg;
}
public string SelfAudit_posSelfAuditEnd(string posName,string barcode,string actualBarcode)
{
string msg = "";
try
{
Dictionary<string, string> paramMap = new Dictionary<string, string>();
paramMap.Add("posName", posName);
paramMap.Add("barcode", barcode);
paramMap.Add("actualBarcode", actualBarcode);
string server = GetAddr("/rest/device/selfAudit/posSelfAuditEnd", paramMap);
string resultStr = HttpHelper.Post(server, "");
ResultData data = JsonHelper.DeserializeJsonToObject<ResultData>(resultStr);
if (data == null)
return msg = " posSelfAuditEnd【 " + posName + "】没有收到服务器反馈";
else if (data.code.Equals(0).Equals(false))
return msg = " posSelfAuditEnd【 " + posName + "】:" + data.msg;
return resultStr;
}
catch (Exception ex)
{
LogUtil.error("DisabledPos: " + ex.ToString());
}
return msg;
}
private static string GetAddr(string addr, Dictionary<string, string> paramsMap)
{
if (server.EndsWith("/"))
......
......@@ -28,7 +28,7 @@ namespace DeviceLibrary
public event Action<string, StoreMoveType, bool> InOutEndProcessEvent;
public bool IsComplateOrFree { get => MoveInfo.MoveStep == MoveStep.Wait && !movelock; }
public bool IsTakedReel { get => MoveInfo.MoveStep >= MoveStep.StoreTS20; }
public bool IsTakedReel { get => MoveInfo.MoveStep >= MoveStep.StoreTS20 || MoveInfo.MoveStep == MoveStep.Wait; }
public bool IsPutOnOut {get=> MoveInfo.MoveStep >= MoveStep.StoreTS16; }
public ReelTransport(Robot_Config _Config, MainMachine _mainMachine)
......@@ -57,12 +57,15 @@ namespace DeviceLibrary
bool ignoreFixtureCheck = false;
int ToCheckOffset = 0;
int FromCheckOffset = 0;
public bool isSelfAudit = false;
public bool CheckHasMatetial = false;
public bool Start(BoxStorePosition from, BoxStorePosition to, StoreMoveType _storeMoveType, bool premove=false)
{
if (MoveInfo.MoveStep != MoveStep.Wait)
return false;
isSelfAudit = false;
CheckHasMatetial = false;
ignoreFixtureCheck = false;
storeMoveType = _storeMoveType;
PreMove = premove;
......@@ -113,6 +116,7 @@ namespace DeviceLibrary
IgnoreX09 = false;
MoveInfo.NextMoveStep(MoveStep.StoreTS02);
MoveInfo.log($"{storeMoveType}:开始");
CheckPosStatus(MoveInfo, From.posid, true);
break;
case MoveStep.StoreTS02:
MoveInfo.NextMoveStep(MoveStep.StoreTS03);
......@@ -138,25 +142,38 @@ namespace DeviceLibrary
if (CheckPosStatus(MoveInfo, From.posid))
{
MoveInfo.NextMoveStep(MoveStep.StoreTS05);
var zp2 = From.Z_Axis_P3 - 205000;
if (zp2 < 0)
zp2 = 0;
Z_Axis.AbsMove(MoveInfo, zp2, Config.Z_Axis_P1_speed);
MoveInfo.log($"{storeMoveType}:Z轴到达取料前点,{From.Z_Axis_P2}");
if (From.posid != MainMachine.LabelP)
{
var zp2 = From.Z_Axis_P3 - 205000;
if (zp2 < 0)
zp2 = 0;
Z_Axis.AbsMove(MoveInfo, zp2, Config.Z_Axis_P1_speed);
MoveInfo.log($"{storeMoveType}:Z轴到达取料前点,{From.Z_Axis_P2}");
}
RobotManage.mainMachine.CylinderMove(MoveInfo, IO_Type.Taking_Release, IO_Type.Taking_Clamp, IO_VALUE.LOW);
MoveInfo.log($"{storeMoveType}:松开夹爪");
IgnoreX09 = false;
}
break;
case MoveStep.StoreTS05:
if (!ignoreFixtureCheck && FromCheckOffset > 0 && !IgnoreX09 && IOManager.IOValue(FromCheckOffset > 0 ? IO_Type.Taking_Left_Check : IO_Type.Taking_Right_Check).Equals(IO_VALUE.LOW))
if (!ignoreFixtureCheck && FromCheckOffset != 0 && !IgnoreX09 && IOManager.IOValue(FromCheckOffset > 0 ? IO_Type.Taking_Left_Check : IO_Type.Taking_Right_Check).Equals(IO_VALUE.LOW))
{
Msg.add(crc.GetString("Res0062", "取料时没有检测到物料信号,请检查."), MsgLevel.alarm, ErrInfo.X09_BoxNotDetect);
MoveInfo.log($"取料时没有检测到物料信号,请检查.");
RobotManage.UserPause(crc.GetString("Res0063", "取料时没有检测到物料信号,请检查"));
if (isSelfAudit)
{
CheckHasMatetial = false;
MoveInfo.log($"{storeMoveType}:自检时没有检测到物料");
MoveInfo.NextMoveStep(MoveStep.StoreTS26);
}
else
{
Msg.add(crc.GetString("Res0062", "取料时没有检测到物料信号,请检查."), MsgLevel.alarm, ErrInfo.X09_BoxNotDetect);
MoveInfo.log($"取料时没有检测到物料信号,请检查.");
//RobotManage.UserPause(crc.GetString("Res0063", "取料时没有检测到物料信号,请检查"));
}
}
else
{
CheckHasMatetial = true;
Msg.add("", MsgLevel.info, ErrInfo.X09_Clear);
IgnoreX09 = false;
MoveInfo.NextMoveStep(MoveStep.StoreTS06);
......@@ -203,6 +220,7 @@ namespace DeviceLibrary
break;
case MoveStep.StoreTS20:
MoveInfo.NextMoveStep(MoveStep.StoreTS21);
CheckPosStatus(MoveInfo, To.posid,true);
Y_Axis.AbsMove(MoveInfo, To.Y_Axis_P2 + ToCheckOffset, Config.Y_Axis_P1_speed);
X_Axis.AbsMove(MoveInfo, To.X_Axis_P2, Config.X_Axis_P1_speed);
MoveInfo.log($"{storeMoveType}:XY轴到达目的地检测,X:{To.X_Axis_P2},Y:{To.Y_Axis_P2}+{ToCheckOffset}");
......@@ -235,20 +253,24 @@ namespace DeviceLibrary
zp2 = 0;
Z_Axis.AbsMove(MoveInfo, zp2, Config.Z_Axis_P1_speed);
}
else if (To.posid == MainMachine.LabelP)
{
RobotManage.mainMachine.FlipEquip.LiftUp(MoveInfo);
}
break;
case MoveStep.StoreTS23:
if (!ignoreFixtureCheck && ToCheckOffset > 0 && IOManager.IOValue(ToCheckOffset > 0 ? IO_Type.Taking_Left_Check : IO_Type.Taking_Right_Check).Equals(IO_VALUE.HIGH))
{
Msg.add(crc.GetString("Res0064", "放料时发现库位已经有料,请检查."), MsgLevel.alarm);
MoveInfo.log($"放料时发现库位已经有料,请检查.");
RobotManage.UserPause(crc.GetString("Res0065", "放料时发现库位已经有料,请检查"));
//RobotManage.UserPause(crc.GetString("Res0065", "放料时发现库位已经有料,请检查"));
}
else
{
Msg.add("", MsgLevel.info, ErrInfo.X09_Clear);
IgnoreX09 = false;
MoveInfo.NextMoveStep(MoveStep.StoreTS24);
MoveInfo.log($"{storeMoveType}:检测料");
MoveInfo.log($"{storeMoveType}:检测有无物料,有物料");
}
break;
......@@ -298,7 +320,7 @@ namespace DeviceLibrary
else
{
MoveInfo.log($"{storeMoveType}:XY返回待机点");
Y_Axis.AbsMove(MoveInfo, Config.Y_Axis_P1, Config.Y_Axis_P1_speed);
//Y_Axis.AbsMove(MoveInfo, Config.Y_Axis_P1, Config.Y_Axis_P1_speed);
X_Axis.AbsMove(MoveInfo, Config.X_Axis_P1, Config.X_Axis_P1_speed);
}
MoveInfo.log($"{storeMoveType}:完成放料");
......@@ -319,7 +341,7 @@ namespace DeviceLibrary
return false;
}
bool CheckPosStatus(MoveInfo moveInfo,string posid) {
bool CheckPosStatus(MoveInfo moveInfo,string posid,bool precheck=false) {
if (posid.StartsWith("L"))
{
if (IOManager.IOValue(IO_Type.Entry_Drawer).Equals(IO_VALUE.HIGH) &&
......@@ -372,7 +394,7 @@ namespace DeviceLibrary
return true;
else
{
RobotManage.mainMachine.TPMove.ToLow(moveInfo);
RobotManage.mainMachine.TPMove.ToLow(precheck?null:moveInfo);
moveInfo.log($"{posid},上层库位移至左侧");
return false;
}
......@@ -383,7 +405,7 @@ namespace DeviceLibrary
return true;
else
{
RobotManage.mainMachine.TPMove.ToHigh(moveInfo);
RobotManage.mainMachine.TPMove.ToHigh(precheck ? null : moveInfo);
moveInfo.log($"{posid},上层库位移至右侧");
return false;
}
......@@ -394,7 +416,7 @@ namespace DeviceLibrary
return true;
else
{
RobotManage.mainMachine.TPMove.ToLow(moveInfo);
RobotManage.mainMachine.TPMove.ToLow(precheck ? null : moveInfo);
moveInfo.log($"{posid},上层库位移至左侧");
return false;
}
......
......@@ -7,16 +7,19 @@ using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace DeviceLibrary
{
[Serializable]
public enum TestStorePointPort {
入口, 出口, 上层左侧, 上层右侧, 下层左侧, 下层右侧,贴标
入口, 出口, 上层左侧, 上层右侧, 下层左侧, 下层右侧,贴标,接标台
}
[Serializable]
public class tstoredata {
......@@ -69,7 +72,8 @@ namespace DeviceLibrary
Dictionary<int, string> ngmsglist = new Dictionary<int, string>();
RobotManage.mainMachine.NGInfoList.ForEach(ng=> {
var sindex = RobotManage.AllPositionMapNumList.IndexOf(ng.PosID)-startindex;
ngmsglist.Add(sindex, ng.NgMsg);
if (!ngmsglist.ContainsKey(sindex))
ngmsglist.Add(sindex, ng.NgMsg);
});
int index = 0;
for (int i = 0; i < 5; i++) {
......@@ -150,7 +154,7 @@ namespace DeviceLibrary
List<Point> points = CameraData[Name].ObjectPoint;
if (bmp == null)
return new List<int>(points.Count);
return Enumerable.Repeat(0, points.Count).ToList();
List<int> haslist = new List<int>();
BitmapData bd=null;
......@@ -217,6 +221,87 @@ namespace DeviceLibrary
TestStorePointEvent?.Invoke(tp, bmp);
return haslist;
}
public static TestStorePointPort GetTestStorePointPort(string posname) {
TestStorePointPort testStorePointPort;
if (Regex.IsMatch(posname, "^S[A-G]"))
testStorePointPort= TestStorePointPort.上层左侧;
else if (Regex.IsMatch(posname, "^S[H-N][1-6]$"))
testStorePointPort = TestStorePointPort.下层左侧;
else
testStorePointPort = TestStorePointPort.下层右侧;
LogUtil.info($"GetTestStorePointPort: {posname}={testStorePointPort}");
return testStorePointPort;
}
/// <summary>
/// 检测标签是否被取走
/// </summary>
/// <returns></returns>
public static bool TestHasLabelOnDock(bool checkstatus) {
var r = CameraPointTest.CameraData[TestStorePointPort.接标台.ToString()].PointList;
Point checkpoint = r[0];
var bmp = RobotManage.CameraA.GetImage(0);
if (bmp == null)
return true;
//bmp = new Bitmap("d:\\新建分组1_监控点1_106_20220818172856_3997146.bmp");
BitmapData bd = null;
try
{
bd = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, bmp.PixelFormat);
var p = checkpoint;
p.X = p.X - 8;
p.Y = p.Y - 8;
var cl = new List<ColorHSV>();
for (int j = 0; j < 16; j++)
{
for (int k = 0; k < 16; k++)
{
var x = p.X + j;
var y = p.Y + k;
var addr = y * bd.Stride + x * 4;
var cr = Marshal.ReadByte(bd.Scan0, addr + 2);
var cg = Marshal.ReadByte(bd.Scan0, addr + 1);
var cb = Marshal.ReadByte(bd.Scan0, addr);
var hh = ColorHelper.RgbToHsv(new ColorRGB(cr, cg, cb));
cl.Add(hh);
}
}
var h = cl.Average(cc => cc.H);
var s = cl.Average(cc => cc.S);
var v = cl.Average(cc => cc.V);
var has = (h>180 && h<260) || s<10;
has = s < 15;
LogUtil.info($"TestHasLabelOnDock checkstatus:{checkstatus}, h:{h},s:{s},v:{v},config_s:{CameraData[TestStorePointPort.接标台.ToString()].S}");
if (has != checkstatus)
{
Directory.CreateDirectory("\\image\\LabelDock");
bmp.Save("\\image\\LabelDock\\"+ checkstatus +"_"+ DateTime.Now.ToString("yyyyMMddHHmmss")+".jpg");
}
return has;
}
catch (AccessViolationException ex)
{
LogUtil.error("TestHasLabelOnDock AccessViolationException:" + ex.ToString());
}
catch (Exception ex)
{
LogUtil.error("TestHasLabelOnDock:" + ex.ToString());
}
finally
{
if (bd != null)
bmp.UnlockBits(bd);
}
return false;
}
/// <summary>
/// 按中心点扩展一个矩形区域
/// </summary>
......
using CodeLibrary;
using OnlineStore;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
......@@ -322,6 +323,7 @@ namespace DeviceLibrary
{
public static List<Msg> msg = new List<Msg>();
public string msgtxt;
public string msgkey;
public MsgLevel msgLevel;
public ErrInfo errInfo;
public DateTime datetime;
......@@ -335,13 +337,26 @@ namespace DeviceLibrary
List<Msg> mm = new List<Msg>(msg);
return mm;
}
public static void add(string m, MsgLevel ml, ErrInfo errInfo= ErrInfo.Empty)
public static void add(string m, MsgLevel ml, ErrInfo errInfo = ErrInfo.Empty)
{
lock (msg)
{
var fm = msg.Find((x) => x.msgtxt == m);
if (fm==null)
msg.Add(new Msg { msgtxt = m, msgLevel = ml, datetime = DateTime.Now, errInfo = errInfo });
if (fm == null)
msg.Add(new Msg { msgtxt = m, msgkey = "", msgLevel = ml, datetime = DateTime.Now, errInfo = errInfo });
}
}
public static void add(CrcObject m, MsgLevel ml, ErrInfo errInfo= ErrInfo.Empty)
{
add(m.key, m.msg, ml, errInfo);
}
public static void add(string key,string m, MsgLevel ml, ErrInfo errInfo = ErrInfo.Empty)
{
lock (msg)
{
var fm = msg.Find((x) => x.msgtxt == m);
if (fm == null)
msg.Add(new Msg { msgtxt = m, msgkey = key, msgLevel = ml, datetime = DateTime.Now, errInfo = errInfo });
}
}
static bool _setlogones = false;
......
......@@ -79,6 +79,10 @@ namespace DeviceLibrary
/// 料盘高
/// </summary>
public int plateH { get; set; }
public string batchNo { get; set; }
public bool isNG { get; set; }
public string NgMsg { get; set; }
public string ToStr()
{
......
......@@ -48,7 +48,7 @@ namespace DeviceLibrary
MoveInfo.WaitList.ForEach((w) => {
if (w.WaitType.Equals(WaitEnum.W014_Msg)) {
w.IsEnd = true;
Msg.add(w.ActionMsg, w.Data);
Msg.add("WaitType."+ w.WaitType, w.ActionMsg, w.Data);
}
});
foreach (WaitResultInfo wait in MoveInfo.WaitList)
......@@ -78,7 +78,7 @@ namespace DeviceLibrary
isOk = false;
WarnMsg = msg;
///Alarm(AlarmType.AxisMoveError, WarnMsg);
Msg.add(WarnMsg, MsgLevel.alarm);
Msg.add("WaitType."+wait.WaitType,WarnMsg, MsgLevel.alarm);
RobotManage.UserPause(WarnMsg);
break;
}
......@@ -118,7 +118,7 @@ namespace DeviceLibrary
else if (wait.WaitType.Equals(WaitEnum.W013_Action))
{
wait.IsEnd = wait.Action.Invoke(wait);
LogUtil.info($"{Name} 自定义等待 IsEnd={wait.IsEnd},Type={wait.Action.GetType()}");
LogUtil.info($"{Name} 自定义等待 IsEnd={wait.IsEnd},Msg={wait.ActionMsg}");
}
else if (wait.WaitType.Equals(WaitEnum.W008_BatchAxis))
{
......@@ -183,7 +183,7 @@ namespace DeviceLibrary
}
else if (span.TotalSeconds > MoveInfo.TimeOutSeconds)
{
WarnMsg = MoveInfo.Name + "[" + MoveInfo.MoveStep + "]" + "等待" + "}" + NotOkMsg + "超时" + "[" + Math.Round(span.TotalSeconds, 1) + "]" + "秒";
WarnMsg = MoveInfo.Name + "[" + MoveInfo.MoveStep + "]" + "等待" + "}" + NotOkMsg + "超时";
int second = (int)(MoveInfo.TimeOutSeconds / span.TotalSeconds) * 10;
if (second > 120)
......@@ -197,7 +197,7 @@ namespace DeviceLibrary
LogUtil.error(WarnMsg, logType + 100, second);
//MoveInfo.errlog(WarnMsg);
//Alarm(AlarmType.IoSingleTimeOut, WarnMsg);
Msg.add(WarnMsg, MsgLevel.alarm);
Msg.add("MoveStep.",WarnMsg, MsgLevel.alarm);
}
return true;
}
......@@ -259,8 +259,8 @@ namespace DeviceLibrary
// return;
(IoLowType, IoHighType) = (IoHighType, IoLowType);
}
//if (IOManager.DOValue(IoHighType).Equals(IO_VALUE.HIGH))
// return;
if (IOManager.IOValue(IoHighType).Equals(IO_VALUE.HIGH) && IOManager.IOValue(IoLowType).Equals(IO_VALUE.LOW))
return;
IOMove(IoLowType, IO_VALUE.LOW);
IOMove(IoHighType, IO_VALUE.HIGH);
if (moveInfo != null)
......@@ -270,7 +270,7 @@ namespace DeviceLibrary
}
}
public IO_VALUE IOValue(string ioType) => IOManager.IOValue(ioType);
void IOMove(string IoType, IO_VALUE value, bool isCheck = false, int msTime = 0)
public void IOMove(string IoType, IO_VALUE value, bool isCheck = false, int msTime = 0)
{
if (msTime <= 0)
{
......
......@@ -42,6 +42,12 @@ namespace DeviceLibrary
//{
// RightDoorOpen = false;
//}
if (RobotManage.dauxiKS107.Distance < 180) {
Msg.add(crc.GetString("Res0163.f6ad5099","冷凝液回收桶已满"), MsgLevel.warning);
}
if (IOValue(IO_Type.Airpressure_Check).Equals(IO_VALUE.LOW)) {
Msg.add(crc.GetString("Res0079","未检测到气压信号."), MsgLevel.warning);
}
......
......@@ -73,6 +73,8 @@ namespace DeviceLibrary
/// </summary>
public bool isInSuddenDown = false;
bool selfAuditMode = false;
public List<ReelParam> NGInfoList = new List<ReelParam>();
......@@ -99,7 +101,7 @@ namespace DeviceLibrary
//Y_Axis.ForceSafeCheck = true;
Y_Axis.interference += Y_Axis_interference;
Z_Axis = new AxisBean(Config.Z_Axis, Name);
Z_Axis.interference += Z_Axis_interference;
Flip_Axis = new AxisBean(Config.Flip_Axis, Name);
Rotate_Axis = new AxisBean(Config.Rotate_Axis, Name);
Crc_LanguageChangeEvent(null, EventArgs.Empty);
......@@ -141,13 +143,17 @@ namespace DeviceLibrary
}
private void Entry_Drawer_Open()
{
nglist = new List<string>();
}private void RightDoor_Close()
nglist = new List<string>();
}
private void RightDoor_Close()
{
IOMove(IO_Type.RightDoor_Lock, IO_VALUE.HIGH);
}private void LeftDoor_Close()
RobotManage.mainMachine.NGInfoList = new List<ReelParam>();
}
private void LeftDoor_Close()
{
IOMove(IO_Type.LeftDoor_Lock, IO_VALUE.HIGH);
}private void PrinterDoor_Close()
......@@ -157,6 +163,7 @@ namespace DeviceLibrary
private void Entry_Drawer_Close()
{
IOMove(IO_Type.Entry_Drawer_Lock, IO_VALUE.HIGH);
newDrawer = true;
CameraPointTest.GetThingStoreName(TestStorePointPort.入口);
}
private void Out_Drawer_Close()
......@@ -184,6 +191,15 @@ namespace DeviceLibrary
return (true, crc.GetString("Res0093","Z轴不在待机位,不允许移动"));
}
private (bool, string) Z_Axis_interference(int arg1, int arg2)
{
if (X_Axis.IsBusy)
return (true, "The other axes are moving, and this axis cannot be moved");
if (Y_Axis.IsBusy)
return (true, "The other axes are moving, and this axis cannot be moved");
return (false, "");
}
private void Crc_LanguageChangeEvent(object sender, EventArgs e)
{
StoreMoveInfo.Name = crc.GetString("Res0088","进出库调度");
......@@ -202,7 +218,7 @@ namespace DeviceLibrary
while (mstart) {
try
{
Thread.Sleep(200);
Thread.Sleep(100);
ioMonitor();
canRunning = DeviceCheck();
if (canRunning)
......@@ -217,16 +233,15 @@ namespace DeviceLibrary
continue;
if (runStatus == RunStatus.Running)
{
boxTransport.Process();
if (RobotManage.InoutDebugMode)
AutoInOutTestProcess();
else if (DemoTestMode)
else if (selfAuditMode)
TFIDSelfTestProcess();
else
StoreDemoProcess();
LabelingProcess();
LabelingProcess();
}
else if (runStatus == RunStatus.HomeReset)
{
......@@ -236,7 +251,7 @@ namespace DeviceLibrary
catch (Exception ex)
{
LogUtil.error("Mainprocess:" + ex);
Msg.add(ex.ToString(), MsgLevel.warning);
Msg.add("Mainprocess", ex.ToString(), MsgLevel.warning);
//Msg.setlogones();
}
finally {
......@@ -275,7 +290,7 @@ namespace DeviceLibrary
}
public void Start() {
ServerCM.StartConnectServer();
Msg.add("", MsgLevel.info, ErrInfo.X09_Clear);
Msg.add("","", MsgLevel.info, ErrInfo.X09_Clear);
LeftDoorOpen = false;
RightDoorOpen = false;
PrintDoorOpen = false;
......@@ -301,7 +316,7 @@ namespace DeviceLibrary
Alarm(AlarmType.None);
StopMove(true);
LedProcess(null);
Msg.add("", MsgLevel.info, ErrInfo.X09_Clear);
Msg.add("","", MsgLevel.info, ErrInfo.X09_Clear);
}
public void BeginHomeReset(bool firstRun=false) {
......@@ -342,10 +357,11 @@ namespace DeviceLibrary
ResetMoveInfo.NextMoveStep(MoveStep.H02_HomeReset_01);
ResetMoveInfo.log("锁定抽屉");
//IOMove(IO_Type.Entry_Drawer_Lock, IO_VALUE.HIGH);
IOMove(IO_Type.Entry_Drawer_Lock, IO_VALUE.HIGH);
IOMove(IO_Type.Out_Drawer_Lock, IO_VALUE.HIGH);
IOMove(IO_Type.Label_PasteBlow, IO_VALUE.LOW);
CylinderMove(ResetMoveInfo, IO_Type.Tin_Dock_Rotate_Release, IO_Type.Tin_Dock_Rotate_Clamp, IO_VALUE.LOW);
Msg.add("", MsgLevel.info, ErrInfo.X09_Clear);
Msg.add("","", MsgLevel.info, ErrInfo.X09_Clear);
break;
case MoveStep.H02_HomeReset_01:
ResetMoveInfo.NextMoveStep(MoveStep.H02_HomeReset);
......@@ -381,11 +397,12 @@ namespace DeviceLibrary
ResetMoveInfo.NextMoveStep(MoveStep.HEND_HomeReset);
if (IOValue(IO_Type.Taking_Clamp).Equals(IO_VALUE.LOW))
{
if (Setting_Init.Runtime_Step >= Runtime_StepE.Printed && Setting_Init.Runtime_Step < Runtime_StepE.LabelPasteFinish)
if (false && Setting_Init.Runtime_Step >= Runtime_StepE.Printed && Setting_Init.Runtime_Step < Runtime_StepE.LabelPasteFinish)
{
StoreMoveInfo.log("检测到上次正在贴标:" + Setting_Init.Runtime_Step + "," + Setting_Init.Runtime_Posid);
//LabelingMoveInfo.NextMoveStep(MoveStep.Labeling01);
//StoreMoveInfo.NextMoveStep(MoveStep.StoreIn03);
LabelingMoveInfo.MoveParam.IsNg = true;
Msg.add(crc.GetString("Res0133","重置前物料正在贴标,无法继续,请手动处理"), MsgLevel.warning, ErrInfo.LabelInPaste);
RobotManage.UserPause(crc.GetString("Res0133","重置前物料正在贴标,无法继续,请手动处理"));
}
......@@ -427,7 +444,7 @@ namespace DeviceLibrary
ok = false;
DeviceSuddenStop();
}
Msg.add(crc.GetString("Res0134","打印机维护门未关闭") + (ok ? ignorestring : ""), MsgLevel.alarm);
Msg.add("printdoor",crc.GetString("Res0134","打印机维护门未关闭") + (ok ? ignorestring : ""), MsgLevel.alarm);
}
if (IOValue(IO_Type.LeftDoor_Check).Equals(IO_VALUE.HIGH))
{
......@@ -436,7 +453,7 @@ namespace DeviceLibrary
ok = false;
DeviceSuddenStop();
}
Msg.add(crc.GetString("Res0097","左侧防护门没有关闭") + (ok ? ignorestring : ""), MsgLevel.alarm);
Msg.add("leftsafedoor",crc.GetString("Res0097","左侧防护门没有关闭") + (ok ? ignorestring : ""), MsgLevel.alarm);
}
if (IOValue(IO_Type.RightDoor_Check).Equals(IO_VALUE.HIGH))
{
......@@ -445,7 +462,7 @@ namespace DeviceLibrary
ok = false;
DeviceSuddenStop();
}
Msg.add(crc.GetString("Res0098","右侧防护门没有关闭") + (ok ? ignorestring : ""), MsgLevel.alarm);
Msg.add("rightsafedoor", crc.GetString("Res0098","右侧防护门没有关闭") + (ok ? ignorestring : ""), MsgLevel.alarm);
}
if (IOValue(IO_Type.SafeDoor_Disable).Equals(IO_VALUE.LOW) && IOValue(IO_Type.DoorLock_Check).Equals(IO_VALUE.LOW))
......@@ -453,8 +470,26 @@ namespace DeviceLibrary
Msg.add(crc.GetString("Res0135","防护门没有锁定"), MsgLevel.warning);
DeviceSuddenStop();
ok = false;
}
if (StoreMoveInfo.MoveStep != MoveStep.Wait && IOValue(IO_Type.Entry_Drawer_Lock).Equals(IO_VALUE.LOW))
{
Msg.add(crc.GetString("Res0164.37b8d13a","出入库时请关好入库抽屉"), MsgLevel.alarm);
DeviceSuddenStop();
ok = false;
}
if (StoreMoveInfo.MoveStep != MoveStep.Wait && StoreMoveInfo.MoveStep < MoveStep.StoreOut14 && IOValue(IO_Type.Out_Drawer_Lock).Equals(IO_VALUE.LOW))
{
Msg.add(crc.GetString("Res0165.970b4edb","出入库时请关好出库抽屉"), MsgLevel.alarm);
DeviceSuddenStop();
ok = false;
}
if (ServerCM.selfAuditException)
{
Msg.add(crc.GetString("Res0172.8f1fa034","自检测到有错误物料,请处理"), MsgLevel.alarm);
}
if (!lastSafeCheckStatus && ok)
{
......@@ -514,6 +549,12 @@ namespace DeviceLibrary
ok = false;
}
}
if (ok && !AxisBean.RunMultiAxis(true, out string msg, AxisBean.List))
{
ok = false;
Msg.add(msg, MsgLevel.warning);
}
if (RobotManage.InoutDebugMode)
{
Msg.add(crc.GetString("Res0102","进出库调试模式"), MsgLevel.info);
......@@ -548,7 +589,7 @@ namespace DeviceLibrary
{
if (runStatus == RunStatus.Running || ResetMoveInfo.IsStep(MoveStep.H06_HomeReset))
{
Msg.add(crc.GetString(configMoveAxis.ProName, configMoveAxis.Explain) + $"[{configMoveAxis.GetAxisValue()}]:"
Msg.add(configMoveAxis.ProName,crc.GetString(configMoveAxis.ProName, configMoveAxis.Explain) + $"[{configMoveAxis.GetAxisValue()}]:"
+ crc.GetString("Res0104", "运动报警"), MsgLevel.alarm);
RobotManage.UserPause(crc.GetString("Res0105","压紧轴报警"), true);
AxisManager.AlarmClear(configMoveAxis.DeviceName, configMoveAxis.GetAxisValue());
......@@ -557,7 +598,7 @@ namespace DeviceLibrary
}
else
{
Msg.add(crc.GetString(configMoveAxis.ProName, configMoveAxis.Explain) + $"[{configMoveAxis.GetAxisValue()}]:"
Msg.add(configMoveAxis.ProName, crc.GetString(configMoveAxis.ProName, configMoveAxis.Explain) + $"[{configMoveAxis.GetAxisValue()}]:"
+ crc.GetString("Res0104","运动报警"), MsgLevel.alarm, ErrInfo.SuddenStop);
ButtenEvent?.Invoke(null, ErrInfo.SuddenStop);
}
......
......@@ -36,7 +36,7 @@ namespace DeviceLibrary
LabelingMoveInfo.NextMoveStep(MoveStep.Labeling03);
CylinderMove(LabelingMoveInfo, IO_Type.Tin_Dock_Left, IO_Type.Tin_Dock_Right, IO_VALUE.HIGH);
CylinderMove(LabelingMoveInfo, IO_Type.Label_Dock_Back, IO_Type.Label_Dock_Front, IO_VALUE.HIGH);
//LabelingMoveInfo.log("锡膏横移到右侧");
LabelingMoveInfo.log("锡膏横移到右侧");
ScanTimes = 0;
CodeList = new List<CodeInfo>();
LabelingMoveInfo.MoveParam = new ReelParam();
......@@ -47,8 +47,10 @@ namespace DeviceLibrary
// RotateEquip.LockAndTurnDegree(-20);
// break;
case MoveStep.Labeling03:
if (RotateEquip.TurnWork==null || RotateEquip.TurnWork.IsCompleted) {
if (RotateEquip.TurnWork == null || RotateEquip.TurnWork.IsCompleted)
{
LabelingMoveInfo.NextMoveStep(MoveStep.Labeling04);
LabelingMoveInfo.log("TakePicture");
TakePicture();
}
break;
......@@ -86,6 +88,34 @@ namespace DeviceLibrary
ServerCM.SendInStoreRequest(new string[] { LabelingMoveInfo.MoveParam.WareCode }, LabelingMoveInfo.MoveParam, true);
Setting_Init.Runtime_Posid = LabelingMoveInfo.MoveParam.PosID;
Setting_Init.Runtime_RFID = LabelingMoveInfo.MoveParam.RFID;
if (LabelingMoveInfo.MoveParam.IsNg) {
LabelingMoveInfo.NextMoveStep(MoveStep.Labeling08);
LabelingMoveInfo.log($"获取库位失败,送到NG口:{LabelingMoveInfo.MoveParam.NgMsg}");
return;
}
PrintTask = RobotManage.printerHelper.PrintLabel(LabelingMoveInfo.MoveParam);
Setting_Init.Runtime_Step = Runtime_StepE.Printed;
LabelingMoveInfo.log("开始打印标签:" + LabelingMoveInfo.MoveParam.ToDetailStr());
Task.Run(() =>
{
for (int i = 0; i < 100; i++)
{
if (PrintTask.IsCompleted)
{
var (result, msg) = PrintTask.Result;
if (result)
{
LabelingMoveInfo.log("在线程中检测到打印完成");
Task.Delay(2000).Wait();
CylinderMove(null, IO_Type.Label_Dock_Back, IO_Type.Label_Dock_Front, IO_VALUE.LOW);
IOMove(IO_Type.Label_TakeBlow, IO_VALUE.HIGH, false, 1000);
break;
}
}
Task.Delay(50).Wait();
}
});
return;
}
}
......@@ -105,13 +135,20 @@ namespace DeviceLibrary
break;
case MoveStep.Labeling06:
LabelingMoveInfo.NextMoveStep(MoveStep.Labeling07);
RotateEquip.TurnDegree(-75);
RotateEquip.TurnDegree(-90);
//LabelingMoveInfo.log("滚动锡膏");
break;
case MoveStep.Labeling07:
if (RotateEquip.TurnWork.IsCompleted)
{
LabelingMoveInfo.NextMoveStep(MoveStep.Labeling06);
{
LabelingMoveInfo.NextMoveStep(MoveStep.Labeling08);
LabelingMoveInfo.log("旋转固定贴标位置");
return;
}
var hc = CameraPointTest.ScanRectangle();
ScanTimes++;
if (hc)
......@@ -139,11 +176,11 @@ namespace DeviceLibrary
{
if (LabelingMoveInfo.MoveParam.IsNg)
{
LabelingMoveInfo.NextMoveStep(MoveStep.Labeling50);
LabelingMoveInfo.NextMoveStep(MoveStep.Labeling56);
LabelingMoveInfo.log("物料NG直接退出");
}
else {
LabelingMoveInfo.NextMoveStep(MoveStep.Labeling10);
LabelingMoveInfo.NextMoveStep(MoveStep.Labeling11);
LabelingMoveInfo.log("开始贴标");
}
}
......@@ -155,6 +192,12 @@ namespace DeviceLibrary
LabelingMoveInfo.log("开始打印标签:" + LabelingMoveInfo.MoveParam.ToDetailStr());
break;
case MoveStep.Labeling11:
if (IOValue(IO_Type.Label_Dock_Back).Equals(IO_VALUE.HIGH)) {
LabelingMoveInfo.NextMoveStep(MoveStep.Labeling13);
LabelingMoveInfo.log("检测到接标托盘已到位,开始贴标");
return;
}
if (PrintTask.IsCompleted)
{
var (result, msg) = PrintTask.Result;
......@@ -163,25 +206,43 @@ namespace DeviceLibrary
LabelingMoveInfo.NextMoveStep(MoveStep.Labeling12);
LabelingMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
LabelingMoveInfo.log("打印成功,等待标签被取走");
Task.Run(() => {
Task.Delay(2000).Wait();
IOMove(IO_Type.Label_TakeBlow, IO_VALUE.HIGH, false, 1000);
});
}
else
{
Msg.add(crc.GetString("Res0106","打印机反馈:") + msg, MsgLevel.alarm);
RobotManage.UserPause(crc.GetString("Res0106","打印机反馈:") + msg);
Msg.add("printinfo", crc.GetString("Res0106", "打印机反馈:") + msg, MsgLevel.alarm);
RobotManage.UserPause(crc.GetString("Res0106", "打印机反馈:") + msg);
LabelingMoveInfo.NextMoveStep(MoveStep.Labeling10);
LabelingMoveInfo.log("打印失败,再次打印");
}
} else if (LabelingMoveInfo.IsTimeOut(10)) {
Msg.add(crc.GetString("Res0166.79cee376","打印响应超时"), MsgLevel.alarm);
}
break;
case MoveStep.Labeling12:
LabelingMoveInfo.NextMoveStep(MoveStep.Labeling13);
CylinderMove(LabelingMoveInfo, IO_Type.Label_Dock_Back, IO_Type.Label_Dock_Front, IO_VALUE.LOW);
LabelingMoveInfo.log("开始贴标");
LabelingMoveInfo.log("开始贴标");
break;
case MoveStep.Labeling13:
LabelingMoveInfo.NextMoveStep(MoveStep.Labeling14);
CylinderMove(LabelingMoveInfo, IO_Type.Label_Dock_Down, IO_Type.Label_Dock_Up, IO_VALUE.HIGH);
//LabelingMoveInfo.log("接标台上升");
if (CameraPointTest.TestHasLabelOnDock(true))
{
LabelingMoveInfo.NextMoveStep(MoveStep.Labeling14);
CylinderMove(LabelingMoveInfo, IO_Type.Label_Dock_Down, IO_Type.Label_Dock_Up, IO_VALUE.HIGH);
//LabelingMoveInfo.log("接标台上升");
}
else {
LabelingMoveInfo.NextMoveStep(MoveStep.Labeling56);
Msg.add(crc.GetString("Res0173.8a024375","没有检测到打印出的标签"), MsgLevel.alarm, ErrInfo.LabelInPaste);
LabelingMoveInfo.MoveParam.IsNg = true;
Setting_Init.Runtime_Posid = "NG";
LabelingMoveInfo.MoveParam.NgMsg = crc.GetString("Res0173.8a024375","没有检测到打印出的标签");
RobotManage.UserPause(crc.GetString("Res0173.8a024375","没有检测到打印出的标签"));
}
break;
case MoveStep.Labeling14:
LabelingMoveInfo.NextMoveStep(MoveStep.Labeling15);
......@@ -207,31 +268,61 @@ namespace DeviceLibrary
//LabelingMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
break;
case MoveStep.Labeling51:
if (CameraPointTest.TestHasLabelOnDock(false))
{
LabelingMoveInfo.NextMoveStep(MoveStep.Labeling56);
Msg.add(crc.GetString("Res0167.8453b300","取标失败"), MsgLevel.alarm, ErrInfo.LabelInPaste);
LabelingMoveInfo.MoveParam.IsNg = true;
Setting_Init.Runtime_Posid = "NG";
LabelingMoveInfo.MoveParam.NgMsg = crc.GetString("Res0167.8453b300","取标失败");
IOMove(IO_Type.Label_Vacuum, IO_VALUE.LOW);
RobotManage.UserPause(crc.GetString("Res0167.8453b300","取标失败"));
return;
}
LabelingMoveInfo.NextMoveStep(MoveStep.Labeling52);
CylinderMove(null, IO_Type.Labeling_Down, IO_Type.Labeling_Up, IO_VALUE.LOW);
IOMove(IO_Type.Label_PasteBlow, IO_VALUE.HIGH);
//LabelingMoveInfo.log("贴标下降");
Setting_Init.Runtime_Step = Runtime_StepE.LabelPaste;
//LabelingMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
break;
case MoveStep.Labeling52:
LabelingMoveInfo.NextMoveStep(MoveStep.Labeling53);
LabelingMoveInfo.NextMoveStep(MoveStep.Labeling52_2);
IOMove(IO_Type.Label_Vacuum, IO_VALUE.LOW);
RotateEquip.TurnDouble();
RotateEquip.TurnDegree(30);
break;
case MoveStep.Labeling52_2:
if (RotateEquip.TurnWork.IsCompleted)
{
LabelingMoveInfo.NextMoveStep(MoveStep.Labeling53);
RotateEquip.TurnDouble();
}
break;
case MoveStep.Labeling53:
if (RotateEquip.TurnWork.IsCompleted)
{
LabelingMoveInfo.NextMoveStep(MoveStep.Labeling54);
RotateEquip.TurnDegree(-45);
//RotateEquip.TurnDouble();
}
break;
case MoveStep.Labeling54:
LabelingMoveInfo.NextMoveStep(MoveStep.Labeling55);
CylinderMove(null, IO_Type.Labeling_Down, IO_Type.Labeling_Up, IO_VALUE.HIGH);
//LabelingMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
if (RotateEquip.TurnWork.IsCompleted)
{
LabelingMoveInfo.NextMoveStep(MoveStep.Labeling56);
CylinderMove(null, IO_Type.Labeling_Down, IO_Type.Labeling_Up, IO_VALUE.HIGH);
//RotateEquip.TurnDegree(90);
RotateEquip.TurnDouble();
}
break;
case MoveStep.Labeling55:
LabelingMoveInfo.NextMoveStep(MoveStep.Labeling56);
RotateEquip.TurnDegree(90);
if (RotateEquip.TurnWork.IsCompleted)
{
LabelingMoveInfo.NextMoveStep(MoveStep.Labeling56);
//RotateEquip.TurnDegree(90);
RotateEquip.TurnDouble();
//RotateEquip.TurnDouble();
}
break;
case MoveStep.Labeling56:
if (RotateEquip.TurnWork.IsCompleted)
......@@ -240,7 +331,7 @@ namespace DeviceLibrary
Setting_Init.Runtime_Step = Runtime_StepE.LabelPasteFinish;
LabelingMoveInfo.log("贴标完成");
RotateEquip.TurnToEnd(false);
IOMove(IO_Type.Label_PasteBlow, IO_VALUE.LOW);
if (LabelingMoveInfo.MoveParam.IsNg)
Setting_Init.Runtime_Posid = "NG";
}
......@@ -397,7 +488,7 @@ namespace DeviceLibrary
reelParam.SN = cs[5].Substring(1);
reelParam.WareCode = rightcode;
reelParam.ReeID = reelParam.SN;
reelParam.RFID = reelParam.SN.Substring(1);
reelParam.RFID = "S"+reelParam.SN;
return true;
}
......
using CodeLibrary;
using Newtonsoft.Json;
using OnlineStore;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
......@@ -6,6 +7,7 @@ using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
......@@ -19,6 +21,7 @@ namespace DeviceLibrary
List<string> DemoTestList;
int DemoTestIndex = 0;
int DemoTestCount = 0;
bool issame = false;
void TFIDSelfTestProcess()
{
if (CheckWait(StoreMoveInfo))
......@@ -27,84 +30,152 @@ namespace DeviceLibrary
switch (StoreMoveInfo.MoveStep)
{
case MoveStep.Wait:
if (selfAuditMode&&!ServerCM.selfAudit)
{
StoreMoveInfo.log("自检模式结束");
selfAuditMode = false;
return;
}
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn01);
StoreMoveInfo.log("自检模式开始");
break;
case MoveStep.StoreIn01:
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn02);
Y_Axis.AbsMove(StoreMoveInfo, Config.Y_Axis_P1, Config.Y_Axis_P1_speed);
X_Axis.AbsMove(StoreMoveInfo, Config.X_Axis_P1, Config.X_Axis_P1_speed);
if (IOValue(IO_Type.Out_Drawer).Equals(IO_VALUE.HIGH) && IOValue(IO_Type.Entry_Drawer).Equals(IO_VALUE.HIGH))
{
var slist = CameraPointTest.GetThingStoreName(TestStorePointPort.入口);
if (slist.Count == 0)
{
IOMove(IO_Type.Out_Drawer_Lock, IO_VALUE.HIGH);
IOMove(IO_Type.Entry_Drawer_Lock, IO_VALUE.HIGH);
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn02);
Y_Axis.AbsMove(StoreMoveInfo, 0, Config.Y_Axis_P1_speed);
X_Axis.AbsMove(StoreMoveInfo, 0, Config.X_Axis_P1_speed);
}
else {
IOValue(IO_Type.Entry_Drawer_Lock).Equals(IO_VALUE.LOW);
Msg.add(crc.GetString("Res0174.f33f9554","开始自检时请清空入库抽屉"), MsgLevel.alarm);
}
}
else {
Msg.add(crc.GetString("Res0168.e90e8acf","开始自检时请关好抽屉"), MsgLevel.alarm);
}
break;
case MoveStep.StoreIn02:
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut10);
if (IOManager.IOValue(IO_Type.Tside_Right).Equals(IO_VALUE.HIGH))
DemoTestList = CameraPointTest.GetThingStoreName(TestStorePointPort.上层右侧);
else
DemoTestList = CameraPointTest.GetThingStoreName(TestStorePointPort.上层左侧);
if (DemoTestList.Count == 0)
if (!ServerCM.selfAudit) {
StoreMoveInfo.NextMoveStep(MoveStep.Wait);
return;
DemoTestIndex = 0;
break;
case MoveStep.StoreOut10:
if (IOValue(IO_Type.Out_Drawer).Equals(IO_VALUE.HIGH) && IOValue(IO_Type.Out_Drawer_Lock).Equals(IO_VALUE.HIGH))
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut11);
}
else if (IOValue(IO_Type.Out_Drawer).Equals(IO_VALUE.LOW) && IOValue(IO_Type.Out_Drawer_Lock).Equals(IO_VALUE.HIGH))
{
IOMove(IO_Type.Out_Drawer_Lock, IO_VALUE.LOW);
var job = ServerCM.SelfAudit_getNetPos();
if (job == null) {
Msg.add(crc.GetString("Res0169.ee0b269b","开始自检,但服务器没有返回正确库位信息."), MsgLevel.alarm);
}
else if (IOValue(IO_Type.Out_Drawer).Equals(IO_VALUE.LOW))
else
{
Msg.add(crc.GetString("Res0137","出库任务正在执行,请关好抽屉"), MsgLevel.warning);
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn03);
StoreMoveInfo.MoveParam.WareCode = job.WareNum;
StoreMoveInfo.MoveParam.PosID = job.PosId;
TestStorePointPort tspp = CameraPointTest.GetTestStorePointPort(job.PosId);
if (tspp == TestStorePointPort.上层左侧 || tspp == TestStorePointPort.下层右侧)
{
RobotManage.mainMachine.TPMove.ToLow(StoreMoveInfo);
StoreMoveInfo.log($"{job.WareNum},上层库位移至左侧");
}
else if (tspp == TestStorePointPort.下层左侧)
{
RobotManage.mainMachine.TPMove.ToHigh(StoreMoveInfo);
StoreMoveInfo.log($"{job.WareNum},上层库位移至右侧");
}
}
else {
IOMove(IO_Type.Out_Drawer_Lock, IO_VALUE.HIGH);
break;
case MoveStep.StoreIn03:
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut10);
{
var tspp = CameraPointTest.GetTestStorePointPort(StoreMoveInfo.MoveParam.PosID);
var slist = CameraPointTest.GetThingStoreName(tspp);
var hasthing = slist.Contains(StoreMoveInfo.MoveParam.PosID);
if (!hasthing)
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn02);
ServerCM.SelfAudit_posSelfAuditEnd(StoreMoveInfo.MoveParam.PosID, "", "");
StoreMoveInfo.log($"自检:{StoreMoveInfo.MoveParam.PosID},没有物料");
return;
}
}
break;
case MoveStep.StoreOut11:
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut12);
var from = CSVPositionReader<ACStorePosition>.GetPositon(DemoTestList[DemoTestIndex]);
var to = CSVPositionReader<ACStorePosition>.GetPositon(RFIDP);
case MoveStep.StoreOut10:
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut11);
var from = CSVPositionReader<ACStorePosition>.GetPositon(StoreMoveInfo.MoveParam.PosID);
var to = CSVPositionReader<ACStorePosition>.GetPositon(RFIDP);
StoreMoveInfo.MoveParam.ReelOnFixture = false;
boxTransport.Start(new BoxStorePosition(Config, from, StoreMoveInfo.MoveParam), new BoxStorePosition(Config, to, StoreMoveInfo.MoveParam), StoreMoveType.OutStore, true);
StoreMoveInfo.log($"开始转运出库");
boxTransport.isSelfAudit= true;
StoreMoveInfo.log($"开始转运出库");
break;
case MoveStep.StoreOut11:
case MoveStep.StoreOut12:
if (boxTransport.IsComplateOrFree)
{
bool issame = false;
if (!boxTransport.CheckHasMatetial)
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn02);
ServerCM.SelfAudit_posSelfAuditEnd(StoreMoveInfo.MoveParam.PosID, "", "");
StoreMoveInfo.log($"自检:{StoreMoveInfo.MoveParam.PosID},没有物料");
return;
}
ServerCM.SelfAudit_posOutEnd(StoreMoveInfo.MoveParam.PosID);
issame = false;
string ds="";
for (int i = 0; i < 15; i++)
{
if (RobotManage.RFID.ReadEPC(12, out byte[] data))
if (RobotManage.RFID.ReadEPC(16, out byte[] data))
{
if (data[0] != 0xFF)
{
ds = Encoding.ASCII.GetString(data).Trim();
//if (StoreMoveInfo.MoveParam.WareCode.IndexOf(ds)>-1)
if (!string.IsNullOrEmpty(ds))
{
StoreMoveInfo.MoveParam.RFID = ds;
StoreMoveInfo.log("读取到 RFID:" + ds + " , "+ RobotManage.RFID.HexBuff(data));
issame = true;
break;
StoreMoveInfo.log("读取到 RFID:" + ds + " , " + RobotManage.RFID.HexBuff(data));
if (StoreMoveInfo.MoveParam.WareCode.IndexOf(ds) > -1)
{
issame = true;
break;
}
}
}
}
if (!issame) {
if (RobotManage.RFID2.ReadEPC(16, out data))
{
if (data[0] != 0xFF)
{
ds = Encoding.ASCII.GetString(data).Trim();
if (!string.IsNullOrEmpty(ds))
{
StoreMoveInfo.MoveParam.RFID = ds;
StoreMoveInfo.log("读取到 RFID2:" + ds + " , " + RobotManage.RFID.HexBuff(data));
if (StoreMoveInfo.MoveParam.WareCode.IndexOf(ds) > -1)
{
issame = true;
break;
}
}
}
}
}
Thread.Sleep(200);
}
if (!issame)
{
//StoreMoveInfo.log("读取到 RFID:" + ds);
//Msg.add("读取到的RFID与物料信息不符:" + ds, MsgLevel.alarm);
//RobotManage.UserPause("读取到的RFID与物料信息不符");
}
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut13);
from = CSVPositionReader<ACStorePosition>.GetPositon(RFIDP);
to = CSVPositionReader<ACStorePosition>.GetPositon(DemoTestList[DemoTestIndex]);
to = CSVPositionReader<ACStorePosition>.GetPositon(StoreMoveInfo.MoveParam.PosID);
StoreMoveInfo.MoveParam.ReelOnFixture = true;
boxTransport.Start(new BoxStorePosition(Config, from, StoreMoveInfo.MoveParam), new BoxStorePosition(Config, to, StoreMoveInfo.MoveParam), StoreMoveType.OutStore, true);
StoreMoveInfo.log($"开始转运出库");
......@@ -113,11 +184,26 @@ namespace DeviceLibrary
case MoveStep.StoreOut13:
if (boxTransport.IsComplateOrFree)
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut11);
DemoTestIndex++;
if (DemoTestIndex >= DemoTestList.Count)
DemoTestIndex = 0;
DemoTestCount++;
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn01);
if (!issame)
{
var crfid = StoreMoveInfo.MoveParam.RFID;
if (string.IsNullOrEmpty(crfid))
{
crfid = "Rfid read fail";
StoreMoveInfo.MoveParam.NgMsg = "Rfid read fail";
}else
StoreMoveInfo.MoveParam.NgMsg = crc.GetString("Res0175.61bd5a58","RFID不符");
NGInfoList.Add(StoreMoveInfo.MoveParam.clone());
ServerCM.SelfAudit_posSelfAuditEnd(StoreMoveInfo.MoveParam.PosID, StoreMoveInfo.MoveParam.WareCode, crfid);
StoreMoveInfo.log($"自检:{StoreMoveInfo.MoveParam.PosID},{StoreMoveInfo.MoveParam.WareCode}!={StoreMoveInfo.MoveParam.RFID}物料数据不符");
}
else
{
ServerCM.SelfAudit_posSelfAuditEnd(StoreMoveInfo.MoveParam.PosID, StoreMoveInfo.MoveParam.WareCode, StoreMoveInfo.MoveParam.WareCode);
StoreMoveInfo.log($"自检:{StoreMoveInfo.MoveParam.PosID},{StoreMoveInfo.MoveParam.WareCode}=={StoreMoveInfo.MoveParam.RFID}物料数据符合");
}
}
break;
default:
......
......@@ -16,20 +16,27 @@ namespace DeviceLibrary
{
partial class MainMachine
{
public const string LabelP = "LabelP";
public const string RFIDP = "RFIDP";
StoreJobList OutStoreJobList = new StoreJobList(crc.GetString("Res0108", "批量"));
public bool HasJob { get => OutStoreJobList.Count > 0; }
public void AddOutStoreTask(string warecode, string posId)
public void AddOutStoreTask(string warecode, string posId,bool ngReel, string ngMsg)
{
JobInfo jobInfo = new JobInfo(warecode, posId);
jobInfo.isNG = ngReel;
jobInfo.NgMsg = ngMsg;
OutStoreJobList.Enqueue(jobInfo);
LogUtil.info($"添加出库任务队列: {posId},当前任务数量: {OutStoreJobList.Count}");
}
public bool IsInStoreReady { get => true; }
List<string> nglist = new List<string>();
/// <summary>
/// 是否新入抽屉
/// </summary>
public bool newDrawer=true;
void StoreDemoProcess()
{
......@@ -41,7 +48,7 @@ namespace DeviceLibrary
case MoveStep.Wait:
StoreMoveInfo.MoveParam.ReelOnFixture = false;
if (IOValue(IO_Type.Taking_Clamp).Equals(IO_VALUE.LOW)) {
if (Setting_Init.Runtime_Step == Runtime_StepE.LabelProcess)
if (false && Setting_Init.Runtime_Step == Runtime_StepE.LabelProcess)
{
StoreMoveInfo.log("检测到上次正在贴标:" + Setting_Init.Runtime_Step + "," + Setting_Init.Runtime_Posid + "," + Setting_Init.Runtime_FromPosid);
if (!string.IsNullOrEmpty(Setting_Init.Runtime_FromPosid))
......@@ -57,12 +64,14 @@ namespace DeviceLibrary
return;
}
else if (Setting_Init.Runtime_Step == Runtime_StepE.LabelPasteFinish)
else if (Setting_Init.Runtime_Step >= Runtime_StepE.LabelProcess && Setting_Init.Runtime_Step <= Runtime_StepE.LabelPasteFinish)
{
StoreMoveInfo.log("检测到上次已完成贴标:" + Setting_Init.Runtime_Step + "," + Setting_Init.Runtime_Posid + "," + Setting_Init.Runtime_RFID);
StoreMoveInfo.NewMove(MoveStep.StoreIn03);
if (Setting_Init.Runtime_Posid.Val == "NG")
LabelingMoveInfo.MoveParam.IsNg = true;
LabelingMoveInfo.MoveParam.IsNg = true;
LabelingMoveInfo.MoveParam.PosID = Setting_Init.Runtime_Posid;
LabelingMoveInfo.MoveParam.RFID = Setting_Init.Runtime_RFID;
StoreMoveInfo.MoveParam.PosID = Setting_Init.Runtime_Posid;
StoreMoveInfo.MoveParam.RFID = Setting_Init.Runtime_RFID;
return;
......@@ -93,6 +102,10 @@ namespace DeviceLibrary
//StoreMoveInfo.log($"检测到入库抽屉已锁定");
}
Setting_Init.Runtime_Step = Runtime_StepE.None;
if (ServerCM.selfAudit) {
selfAuditMode = true;
}
return;
}
if (Setting_Init.Runtime_Step!= Runtime_StepE.None)
......@@ -178,7 +191,7 @@ namespace DeviceLibrary
if (StoreMoveInfo.MoveParam.IsNg)
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn06);
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn08);
StoreMoveInfo.log($"收到完成贴标NG");
}
else
......@@ -217,16 +230,22 @@ namespace DeviceLibrary
case MoveStep.StoreIn05:
if (boxTransport.IsComplateOrFree)
{
if (StoreMoveInfo.MoveParam.RFID.Length > 12)
StoreMoveInfo.MoveParam.RFID = StoreMoveInfo.MoveParam.RFID.Substring(0, 12);
if (StoreMoveInfo.MoveParam.RFID.Length > 16)
StoreMoveInfo.MoveParam.RFID = StoreMoveInfo.MoveParam.RFID.Substring(0, 16);
bool writeok = false;
var r=RobotManage.RFID.ReOpen();
var r1=RobotManage.RFID2.ReOpen();
StoreMoveInfo.log("连接rfid:" + r+ "rfid2:" + r1);
for (int i = 0; i < 15; i++)
{
if (string.IsNullOrEmpty(StoreMoveInfo.MoveParam.RFID))
break;
RobotManage.RFID.WriteEPC(Encoding.ASCII.GetBytes(StoreMoveInfo.MoveParam.RFID));
var epc = StoreMoveInfo.MoveParam.RFID.PadRight(16);
RobotManage.RFID.WriteByte(550, new byte[] { 0x40, 0x00 });
Thread.Sleep(300);
RobotManage.RFID.WriteEPC(Encoding.ASCII.GetBytes(epc));
Thread.Sleep(500);
if (RobotManage.RFID.ReadEPC(12, out byte[] data))
if (RobotManage.RFID.ReadEPC(16, out byte[] data))
{
if (data[0] != 0xFF)
{
......@@ -243,9 +262,33 @@ namespace DeviceLibrary
}
}
}
if (!writeok) {
RobotManage.RFID2.WriteByte(550, new byte[] { 0x40, 0x00 });
Thread.Sleep(300);
RobotManage.RFID2.WriteEPC(Encoding.ASCII.GetBytes(epc));
Thread.Sleep(500);
if (RobotManage.RFID2.ReadEPC(16, out data))
{
if (data[0] != 0xFF)
{
var ds = Encoding.ASCII.GetString(data).Trim();
if (ds == StoreMoveInfo.MoveParam.RFID)
{
StoreMoveInfo.log("RFID2 写入成功:" + ds);
writeok = true;
break;
}
else
{
StoreMoveInfo.log("失败的 RFID2:" + ds);
}
}
}
}
if (!writeok)
{
var of = i * 1000 * (i % 2 == 0 ? 1 : -1);
var of = i * 2000 * (i % 2 == 0 ? 1 : -1);
var zp = Z_Axis.GetAclPosition() + of;
var yp = Y_Axis.GetAclPosition() + of;
var zt = Z_Axis.AbsMoveASYNC(zp, Config.Z_Axis_P1_speed);
......@@ -255,14 +298,13 @@ namespace DeviceLibrary
//Thread.Sleep(100);
}
if (!writeok) {
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn06);
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn08);
StoreMoveInfo.MoveParam.ReelOnFixture = true;
StoreMoveInfo.MoveParam.IsNg = true;
StoreMoveInfo.MoveParam.NgMsg = crc.GetString("Res0139", "RFID 写入失败");
StoreMoveInfo.log($"RFID 写入失败 NG");
ServerCM.cancelPutInTask("", StoreMoveInfo.MoveParam.WareCode);
//Msg.add(crc.GetString("Res0139","RFID 写入失败"),MsgLevel.alarm);
//RobotManage.UserPause(crc.GetString("Res0139","RFID 写入失败"));
Z_Axis.AbsMove(StoreMoveInfo, Config.Z_Axis_P1, Config.Z_Axis_P1_speed);
return;
}
......@@ -303,7 +345,7 @@ namespace DeviceLibrary
// StoreMoveInfo.log($"检测到空库位:{outposid}, 其他空库位:{string.Join(",", olist)}");
//}
//nglist.Add(outposid);
ServerCM.cancelPutInTask("", StoreMoveInfo.MoveParam.PosID);
ServerCM.cancelPutInTask("", StoreMoveInfo.MoveParam.WareCode);
nglist.Add(Setting_Init.Runtime_FromPosid);
StoreMoveInfo.MoveParam.PosID = Setting_Init.Runtime_FromPosid;
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn09);
......@@ -322,8 +364,11 @@ namespace DeviceLibrary
case MoveStep.StoreIn09:
if (boxTransport.IsComplateOrFree)
{
if(!StoreMoveInfo.MoveParam.IsNg)
ServerCM.SendStoreState(StoreMoveInfo.MoveParam.PosID, StoreStatus.InStoreEnd);
if (!StoreMoveInfo.MoveParam.IsNg)
{
if (!ServerCM.SendStoreState(StoreMoveInfo.MoveParam.PosID, StoreStatus.InStoreEnd))
{ }
}
if (OutStoreJobList.Count==0)
StoreMoveInfo.NewMove(MoveStep.StoreIn01);
else
......@@ -344,7 +389,7 @@ namespace DeviceLibrary
}
else if (IOValue(IO_Type.Out_Drawer).Equals(IO_VALUE.LOW))
{
Msg.add(crc.GetString("Res0137","出库任务正在执行,请关好抽屉"), MsgLevel.warning);
Msg.add(crc.GetString("Res0137","出库任务正在执行,请关好抽屉"), MsgLevel.alarm);
}
else {
IOMove(IO_Type.Out_Drawer_Lock, IO_VALUE.HIGH);
......@@ -357,25 +402,61 @@ namespace DeviceLibrary
Setting_Init.Runtime_WareCode = StoreMoveInfo.MoveParam.WareCode;
{
var outposid="";
var olist = CameraPointTest.GetThingStoreName(TestStorePointPort.出口);
StoreMoveInfo.log($"检测到出库口有料库位:{string.Join(",", olist)}");
olist = RobotManage.AllPositionMapNumList.ToList().Where(p => { return p.StartsWith("U") && !olist.Contains(p); }).ToList();
if (olist.Count == 0)
if (!ServerCM.selfAuditException)
{
OutStoreJobList.ClearLastPosid();
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut13);
StoreMoveInfo.log($"没有检测到出库未有空位");
return;
var olist = CameraPointTest.GetThingStoreName(TestStorePointPort.出口);
StoreMoveInfo.log($"检测到出库口有料库位:{string.Join(",", olist)}");
olist = RobotManage.AllPositionMapNumList.ToList().Where(p => { return p.StartsWith("U") && !olist.Contains(p); }).ToList();
olist.Reverse();
if (olist.Count == 0)
{
OutStoreJobList.ClearLastPosid();
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut13);
StoreMoveInfo.log($"没有检测到出库未有空位");
return;
}
else
{
outposid = olist[0];
StoreMoveInfo.log($"检测到出库位有料:{outposid}, 其他有料出库位:{string.Join(",", olist)}");
}
StoreMoveInfo.MoveParam.IsNg = false;
}
else
{
outposid = olist[0];
StoreMoveInfo.log($"检测到出库位有料:{outposid}, 其他有料出库位:{string.Join(",", olist)}");
else {
var olist = CameraPointTest.GetThingStoreName(TestStorePointPort.入口);
StoreMoveInfo.log($"检测到入库口有料库位:{string.Join(",", olist)}");
olist = RobotManage.AllPositionMapNumList.ToList().Where(p => { return p.StartsWith("L") && !p.StartsWith("La") && !olist.Contains(p); }).ToList();
StoreMoveInfo.log($"检测到入库口无料库位:{string.Join(",", olist)}");
if (olist.Count == 0)
{
OutStoreJobList.ClearLastPosid();
StoreMoveInfo.NextMoveStep(MoveStep.Wait);
StoreMoveInfo.log($"没有检测到NG出库未有空位");
return;
}
else
{
outposid = olist[0];
StoreMoveInfo.log($"检测到NG出库可用:{outposid}, 其他NG可用出库位:{string.Join(",", olist)}");
}
StoreMoveInfo.MoveParam.IsNg = true;
StoreMoveInfo.MoveParam.dateTime = DateTime.Now;
var n = StoreMoveInfo.MoveParam.clone();
n.PosID = outposid;
NGInfoList.Add(n);
Setting_Init.Runtime_NGINFOLIST = JsonConvert.SerializeObject(NGInfoList);
}
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut11);
from = CSVPositionReader<ACStorePosition>.GetPositon(inposid);
to = CSVPositionReader<ACStorePosition>.GetPositon(RFIDP);
if (StoreMoveInfo.MoveParam.IsNg)
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut12);
to = CSVPositionReader<ACStorePosition>.GetPositon(outposid);//NG出库直接去入口库位
}
else
{
to = CSVPositionReader<ACStorePosition>.GetPositon(RFIDP);
}
StoreMoveInfo.MoveParam.OutPosID = outposid;
//StoreMoveInfo.MoveParam.ReelOnFixture = false;
boxTransport.Start(new BoxStorePosition(Config, from, StoreMoveInfo.MoveParam), new BoxStorePosition(Config, to, StoreMoveInfo.MoveParam), StoreMoveType.OutStore, true);
......@@ -391,7 +472,7 @@ namespace DeviceLibrary
string ds="";
for (int i = 0; i < 15; i++)
{
if (RobotManage.RFID.ReadEPC(12, out byte[] data))
if (RobotManage.RFID.ReadEPC(16, out byte[] data))
{
if (data[0] != 0xFF)
{
......@@ -402,8 +483,23 @@ namespace DeviceLibrary
StoreMoveInfo.log("读取到 RFID:" + ds + " , "+ RobotManage.RFID.HexBuff(data));
issame = true;
break;
}
}
}
if (!issame) {
if (RobotManage.RFID2.ReadEPC(16, out data))
{
if (data[0] != 0xFF)
{
ds = Encoding.ASCII.GetString(data).Trim();
if (StoreMoveInfo.MoveParam.WareCode.IndexOf(ds) > -1)
{
StoreMoveInfo.MoveParam.RFID = ds;
StoreMoveInfo.log("读取到 RFID2:" + ds + " , " + RobotManage.RFID2.HexBuff(data));
issame = true;
break;
}
}
}
}
Thread.Sleep(200);
......@@ -412,7 +508,7 @@ namespace DeviceLibrary
if (!issame)
{
StoreMoveInfo.log("读取到 RFID:" + ds);
Msg.add(crc.GetString("Res0140","读取到的RFID与物料信息不符:") + ds, MsgLevel.alarm);
Msg.add("rfid.nomatch", crc.GetString("Res0140","读取到的RFID与物料信息不符:") + ds, MsgLevel.alarm);
RobotManage.UserPause(crc.GetString("Res0141","读取到的RFID与物料信息不符"));
}
......@@ -427,23 +523,41 @@ namespace DeviceLibrary
case MoveStep.StoreOut12:
if (boxTransport.IsComplateOrFree)
{
ServerCM.SendStoreState(StoreMoveInfo.MoveParam.PosID, StoreStatus.OutStoreEnd);
ServerCM.SendStoreState(StoreMoveInfo.MoveParam.PosID, StoreStatus.OutStoreBoxEnd);
ServerCM.SendStoreState(StoreMoveInfo.MoveParam.PosID, StoreStatus.OutStoreEnd);
StoreMoveInfo.log("出库完成");
StoreMoveInfo.NextMoveStep(MoveStep.Wait);
OutStoreJobList.ClearLastPosid();
var olist = CameraPointTest.GetThingStoreName(TestStorePointPort.出口);
StoreMoveInfo.log($"检测到出库口有料库位:{string.Join(",", olist)}");
olist = RobotManage.AllPositionMapNumList.ToList().Where(p => { return p.StartsWith("U") && !olist.Contains(p); }).ToList();
if (olist.Count == 0) {
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut13);
StoreMoveInfo.log($"出库库位已用完");
if (!StoreMoveInfo.MoveParam.IsNg)
{
var olist = CameraPointTest.GetThingStoreName(TestStorePointPort.出口);
StoreMoveInfo.log($"检测到出库口有料库位:{string.Join(",", olist)}");
olist = RobotManage.AllPositionMapNumList.ToList().Where(p => { return p.StartsWith("U") && !olist.Contains(p); }).ToList();
if (olist.Count == 0)
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut13);
StoreMoveInfo.log($"出库库位已用完");
}
}
if (OutStoreJobList.Count==0)
else {
var olist = CameraPointTest.GetThingStoreName(TestStorePointPort.入口);
StoreMoveInfo.log($"检测到NG出库口有料库位:{string.Join(",", olist)}");
olist = RobotManage.AllPositionMapNumList.ToList().Where(p => { return p.StartsWith("L") && !p.StartsWith("Lab") && !olist.Contains(p); }).ToList();
StoreMoveInfo.log($"检测到NG出库口无料库位:{string.Join(",", olist)}");
//if (olist.Count == 0)
{
StoreMoveInfo.NextMoveStep(MoveStep.Wait);
StoreMoveInfo.log($"NG出库库位已完成");
return;
}
}
if (OutStoreJobList.Count == 0)
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut13);
StoreMoveInfo.log($"没有出库任务了");
}
}
break;
case MoveStep.StoreOut13:
......@@ -480,7 +594,11 @@ namespace DeviceLibrary
case MoveStep.StoreOut17:
if (IOValue(IO_Type.Out_Drawer).Equals(IO_VALUE.HIGH))
{
StoreMoveInfo.NewMove(MoveStep.StoreIn01);
StoreMoveInfo.log("抽屉已经上锁 newDrawer:"+ newDrawer);
if (!newDrawer)
StoreMoveInfo.NewMove(MoveStep.StoreIn01);
else
StoreMoveInfo.NewMove(MoveStep.Wait);
}
else
{
......
......@@ -131,6 +131,7 @@ namespace DeviceLibrary
Labeling50,
Labeling51,
Labeling52,
Labeling52_2,
Labeling53,
Labeling54,
Labeling55,
......
......@@ -79,6 +79,7 @@ namespace DeviceLibrary
//public static HIKCamera CameraD=new HIKCamera();
public static DauxiKS107Controller dauxiKS107 = new DauxiKS107Controller();
public static PuYueRFID_FR540SP_C2S RFID = new PuYueRFID_FR540SP_C2S();
public static PuYueRFID_FR540SP_C2S RFID2 = new PuYueRFID_FR540SP_C2S();
public static PrinterHelper printerHelper = new PrinterHelper();
public static void Init() {
string msg = "";
......@@ -147,6 +148,14 @@ namespace DeviceLibrary
else
{
CameraA.Open();
for (int i = 0; i < 4;i++) {
if (CameraA.GetImage(i) == null)
{
msg += string.Format(crc.GetString("Res0176.7352b919","第{0}个相机打开失败"), i) + "\r\n";
IsLoadOk = false;
}
}
}
mainMachine = new MainMachine(RobotManage.Config);
if (!dauxiKS107.OpenPort(Setting_Init.Device_DauxiKS107_Port, out _)) {
......@@ -172,7 +181,17 @@ namespace DeviceLibrary
}
else
LogUtil.info("RFID连接成功,IP:"+ Setting_Init.Device_RFID_IP);
//RFID.Init();
RFID2.IP = Setting_Init.Device_RFID_IP2;
RFID2.Open(Setting_Init.Device_RFID_IP2);
if (!RFID2.IsConn)
{
IsLoadOk = false;
msg += crc.GetString("Res0142","RFID2连接失败,IP:") + $"{Setting_Init.Device_RFID_IP2}\n";
}
else
LogUtil.info("RFID2连接成功,IP:"+ Setting_Init.Device_RFID_IP2);
//RFID.AntennaPower = 4;
IOManager.IOMove(IO_Type.Camera_Led, IO_VALUE.HIGH);
......
......@@ -287,6 +287,11 @@ namespace DeviceLibrary
{
return;
}
if (!currentAxis.IsSafe(0, out string msg))
{
MessageBox.Show(msg);
return;
}
if (btnAddMove.BackColor.Equals(Color.White))
{
int speed = Convert.ToInt32(comjSpeed.Text);
......@@ -316,6 +321,11 @@ namespace DeviceLibrary
{
return;
}
if (!currentAxis.IsSafe(0, out string msg))
{
MessageBox.Show(msg);
return;
}
if (btnDelMove.BackColor.Equals(Color.White))
{
int speed = Convert.ToInt32(comjSpeed.Text);
......
......@@ -83,3 +83,5 @@ DO,0,锡膏旋转定位夹紧气缸夹紧,Tin_Dock_Rotate_Clamp,26,HC,Y26,,,,,,,,,,
DO,0,锡膏翻转机构前进,Tin_Dock_Right,27,HC,Y27,,,,,,,,,,
DO,0,锡膏翻转机构后退,Tin_Dock_Left,28,HC,Y28,,,,,,,,,,
DO,0,标签吸盘取料,Label_Vacuum,29,HC,Y29,,,,,,,,,,
DO,0,标签出标吹气,Label_TakeBlow,30,HC,Y30,,,,,,,,,,
DO,0,标签贴标吹气,Label_PasteBlow,31,HC,Y31,,,,,,,,,,
\ No newline at end of file
......@@ -213,6 +213,15 @@ namespace OnlineStore.LoadCSVLibrary
public static string Label_Vacuum = "Label_Vacuum";
/// <summary>
/// DO,0,标签出标吹气,Label_TakeBlow,30,HC,Y30,,,,,,,,,,
/// </summary>
public static string Label_TakeBlow = "Label_TakeBlow";
/// <summary>
/// DO,0,标签贴标吹气,Label_PasteBlow,31,HC,Y31,,,,,,,,,,
/// </summary>
public static string Label_PasteBlow = "Label_PasteBlow";
}
public enum IO_VALUE
{
......
......@@ -430,10 +430,11 @@ namespace TheMachine
}
else if (msg.errInfo == ErrInfo.LabelInPaste)
{
RobotManage.mainMachine.IOMove(IO_Type.PrinterDoor_Lock, IO_VALUE.LOW);
if (FrmAlarm.ShowAlarmDialog(crc.GetString("Res0143","贴标区内可能有物料未完成贴标,请手动取出")) == DialogResult.OK)
{
{
LogUtil.info("用户确认已处理");
Setting_Init.Runtime_Step = Runtime_StepE.None;
//Setting_Init.Runtime_Step = Runtime_StepE.None;
RobotManage.UserPause(false);
}
else {
......
......@@ -79,6 +79,7 @@ namespace TheMachine
this.Name = "FrmAlarm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "FrmAlarm";
this.Load += new System.EventHandler(this.FrmAlarm_Load);
this.ResumeLayout(false);
}
......
using System;
using OnlineStore;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
......@@ -34,5 +35,10 @@ namespace TheMachine
DialogResult = DialogResult.OK;
Close();
}
private void FrmAlarm_Load(object sender, EventArgs e)
{
crc.LanguageProcess(this);
}
}
}
......@@ -118,7 +118,6 @@ namespace TheMachine
this.button10.TabIndex = 6;
this.button10.Text = "写入RFID EPC";
this.button10.UseVisualStyleBackColor = false;
this.button10.Visible = false;
this.button10.Click += new System.EventHandler(this.button10_Click);
//
// button9
......
......@@ -88,12 +88,23 @@ namespace TheMachine
private void button9_Click(object sender, EventArgs e)
{
var r= RobotManage.RFID.ReOpen();
RobotManage.RFID2.ReOpen();
LogUtil.info("RFID.ReOpen:" + r);
for (int i = 0; i < 6;i++) {
Thread.Sleep(200);
if (RobotManage.RFID.ReadEPC(12,out byte[] data)) {
if (RobotManage.RFID.ReadEPC(16,out byte[] data)) {
if (data[0] != 0xFF)
{
MessageBox.Show(RobotManage.RFID.HexBuff(data) + "\r\n" + Encoding.ASCII.GetString(data).Trim());
MessageBox.Show("RFID:"+Encoding.ASCII.GetString(data).Trim());
return;
}
}
if (RobotManage.RFID2.ReadEPC(16, out data))
{
if (data[0] != 0xFF)
{
MessageBox.Show("RFID2:" + RobotManage.RFID2.HexBuff(data) + "\r\n" + Encoding.ASCII.GetString(data).Trim());
return;
}
}
......@@ -103,16 +114,82 @@ namespace TheMachine
private void button10_Click(object sender, EventArgs e)
{
var epc = InputBox("Write EPC, maximum 16 words.", "Please enter EPC data, maximum 16 words.", "");
var r = RobotManage.RFID.ReOpen();
RobotManage.RFID2.ReOpen();
LogUtil.info("RFID.ReOpen:" + r+",epc="+ epc);
epc = epc.PadRight(16);
RobotManage.RFID.WriteByte(550, new byte[] { 0x40, 0x00 });
Thread.Sleep(300);
var epc = "20418002Z-203";
epc = "20418002Z-20";
epc = epc.PadRight(12);
var result = RobotManage.RFID.WriteEPC(Encoding.ASCII.GetBytes(epc));
result = RobotManage.RFID2.WriteEPC(Encoding.ASCII.GetBytes(epc));
if (result)
{
MessageBox.Show(crc.GetString("Res0144","写入成功"));
return;
}
}
private string InputBox(string Caption, string Hint, string Default)
{
Form InputForm = new Form();
InputForm.MinimizeBox = false;
InputForm.MaximizeBox = false;
InputForm.StartPosition = FormStartPosition.CenterScreen;
InputForm.Width = 360;
InputForm.Height = 150;
//InputForm.Font.Name = "宋体";
//InputForm.Font.Size = 10;
InputForm.Text = Caption;
Label lbl = new Label();
lbl.Text = Hint;
lbl.Left = 10;
lbl.Top = 20;
lbl.Parent = InputForm;
lbl.AutoSize = true;
TextBox tb = new TextBox();
tb.Left = 30;
tb.Top = 45;
tb.Width = 300;
tb.Parent = InputForm;
tb.Text = Default;
tb.SelectAll();
Button btnok = new Button();
btnok.Left = 30;
btnok.Top = 80;
btnok.Parent = InputForm;
btnok.Text = "Ok";
InputForm.AcceptButton = btnok;//回车响应
btnok.DialogResult = DialogResult.OK;
Button btncancal = new Button();
btncancal.Left = 120;
btncancal.Top = 80;
btncancal.Parent = InputForm;
btncancal.Text = "Cancel";
btncancal.DialogResult = DialogResult.Cancel;
try
{
if (InputForm.ShowDialog() == DialogResult.OK)
{
return tb.Text;
}
else
{
return "";
}
}
finally
{
InputForm.Dispose();
}
}
}
}
\ No newline at end of file
using ConfigHelper;
using DeviceLibrary;
using log4net.Config;
using OnlineStore;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
......@@ -25,12 +26,13 @@ namespace TheMachine
static void Main()
{
CameraPointTest.Init();
CameraPointTest.TestHasLabelOnDock(true);
//CameraPointTest.ScanRectangle();
//var bmpfile = @"D:\rick\vs\SO20031_TinStorage\TheMachine\bin\Debug\test.bmp";
//var bmp = new Bitmap(bmpfile);
//var r = CameraPointTest.TestStorePoint(bmp, TestStorePointPort.入口);
_ = new Mutex(true, Application.ProductName, out bool ret);
if (!ret)
{
......
......@@ -133,6 +133,9 @@ namespace TheMachine
haslistStoreName = CameraPointTest.GetThingStoreName(TestStorePointPort.下层右侧);
LogUtil.info("下层右侧:" + string.Join(",", haslistStoreName));
}
var haslabel = CameraPointTest.TestHasLabelOnDock(true);
LogUtil.info("标签台:" + haslabel);
});
RobotManage.mainMachine.ScanCode();
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!