Commit 1587d8a9 刘韬

稳定版本

1 个父辈 04115036
......@@ -73,5 +73,7 @@ namespace OnlineStore.Common
public static MyConfig<string> Runtime_Robot_ReelInfo;
public static MyConfig<string> Runtime_Robot_FromPos;
public static MyConfig<string> Runtime_Robot_ToPos;
public static MyConfig<string> RuntimeRobot_Arm_MoveStep;
public static MyConfig<string> RuntimeRobot_MoveStep;
}
}
......@@ -107,6 +107,7 @@
<Compile Include="DeviceLibrary\LineRunMonitor.cs" />
<Compile Include="DeviceLibrary\C8WeightSensor.cs" />
<Compile Include="DeviceLibrary\OKLEController.cs" />
<Compile Include="DeviceLibrary\RobotMoveHelper.cs" />
<Compile Include="DeviceLibrary\ServerCommunication.cs" />
<Compile Include="DeviceLibrary\AxisBean.cs" />
<Compile Include="theMachine\Common.cs" />
......
......@@ -119,6 +119,9 @@ namespace DeviceLibrary
LogUtil.info("ServoOff【" + AxisName + "】");
AxisManager.ServoOff(Config.DeviceName, Config.GetAxisValue());
}
public bool HasHome() {
return AxisManager.GetHomeEndStatus(Config.DeviceName, (short)Config.GetAxisValue()) == 3;
}
public void HomeMove(MoveInfo MoveInfo,bool force=true)
{
if (!force && AxisManager.GetHomeEndStatus(Config.DeviceName, (short)Config.GetAxisValue()) == 3)
......
......@@ -26,8 +26,8 @@ namespace DeviceLibrary
currentIOvalue = IO_VALUE.HIGH;
if (moveInfo != null)
{
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(Low, IO_VALUE.LOW));
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(High, IO_VALUE.HIGH));
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(Low, IO_VALUE.LOW, true));
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(High, IO_VALUE.HIGH, true));
}
Resume(false);
if (moveInfo!=null)
......@@ -40,8 +40,8 @@ namespace DeviceLibrary
currentIOvalue = IO_VALUE.LOW;
if (moveInfo != null)
{
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(Low, IO_VALUE.HIGH));
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(High, IO_VALUE.LOW));
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(Low, IO_VALUE.HIGH, true));
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(High, IO_VALUE.LOW, true));
}
Resume(false);
if (moveInfo != null)
......
using OnlineStore.Common;
using Robot.UR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace DeviceLibrary
{
class RobotHelper
{
int lastMoveCmd = 0;
URRobotControl robot;
System.Timers.Timer RobotCheck;
public RobotHelper(URRobotControl _robot) {
robot = _robot;
RobotCheck = new System.Timers.Timer(5000);
RobotCheck.Elapsed += RobotCheck_Elapsed;
}
public volatile bool RobotStatus = false;
private void RobotCheck_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
if (!robot.IsRun)
{
robot.StartRobot();
RobotStatus = false;
}
robot.SendCMD("safetymode", 0);
Thread.Sleep(100);
if (!robot.CurDashboardReponse.Contains("NORMAL"))
{
RobotStatus = false;
//Msg.add(POS_Start + "机器人状态异常:" + Robot.CurDashboardReponse, MsgLevel.alarm);
if (robot.CurDashboardReponse.Contains("PROTECTIVE_STOP"))
{
robot.SendCMD("unlock protective stop", 0);
}
}
robot.SendCMD("programState", 0);
Thread.Sleep(300);
if (!robot.CurDashboardReponse.Contains("PLAYING"))
{
RobotStatus = false;
//Msg.add(POS_Start + "机器人状态异常:" + Robot.CurDashboardReponse, MsgLevel.alarm);
robot.PlayProgram();
}
else if (!robot.ClientIsConnected) {
RobotStatus = false;
robot.StopProgram();
}
else
RobotStatus = true;
}
public void Move(MoveInfo moveInfo, int movecmd) {
if (moveInfo != null)
{
moveInfo.WaitList.Add(WaitResultInfo.WaitAction(new Func<WaitResultInfo, bool>(IsMoveOk), "等待" + $"[{robot.Name}]" + "移动到位"));
}
lastMoveCmd = movecmd;
robot.SendMoveCmd(movecmd, Setting_Init.URRobot_MI1_Speed_Rate);
}
internal void Start()
{
RobotCheck.Enabled = true;
}
public bool IsMoveOk(WaitResultInfo waitResultInfo) {
if (robot.CurCmdReponse.Contains($"{lastMoveCmd},done"))
return true;
else if (robot.CurCmdReponse.Contains($"done"))
{
LogUtil.error($"机器人没有移动到位,重新移动:{lastMoveCmd}");
robot.SendMoveCmd(lastMoveCmd);
return false;
}
else
return false;
}
internal void Stop()
{
RobotCheck.Enabled = false;
}
}
}
......@@ -78,8 +78,11 @@ namespace DeviceLibrary
{
VLog.Info("入库成功:" + InStoreJobInfo.ToStr());
string[] substrings = InStoreJobInfo.WareNum.Split('#');
string secondSubstring = substrings[1].Substring(1);
InStoreEnd(secondSubstring);
if (substrings.Length > 2)
{
string secondSubstring = substrings[1].Substring(1);
InStoreEnd(secondSubstring);
}
InStoreJobInfo = null;
}
}
......
using OnlineStore;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using RemoteSheardObject;
using System;
using System.Collections.Generic;
using System.Linq;
......@@ -18,6 +19,32 @@ namespace DeviceLibrary
public MsgService Msg { get; set; }
public string Name { get; set; }
public string GroupName { get; set; }
System.Timers.Timer timer;
public DeviceBase() {
timer = new System.Timers.Timer(5000);
timer.Elapsed += Timer_Elapsed;
timer.Enabled = true;
}
private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
EquipMsgData equipMsg = new EquipMsgData();
equipMsg.msgList = new List<EquipMessage>();
equipMsg.status = 0;
Msg.msg.ForEach(ml =>
{
equipMsg.msgList.Add(new EquipMessage()
{
msg = ml.msgtxt,
status = ml.msgLevel == MsgLevel.alarm ? 1 : 0
});
if (ml.msgLevel == MsgLevel.alarm)
equipMsg.status = 1;
});
equipMsg.equipName = GroupName;
TheLine.UploadStatus(equipMsg);
}
public static bool FwdFree(int curaddr) {
int nextaddr = curaddr + 1;
......@@ -32,7 +59,7 @@ namespace DeviceLibrary
public void StopMove(bool ServoOff = false)
{
//runStatus = RunStatus.Stop;
MoveInfo.List.ForEach((m) => { m.EndMove(); });
//MoveInfo.List.ForEach((m) => { m.EndMove(); });
if (AxisBean.List.ContainsKey(GroupName))
AxisBean.StopMultiAxis(AxisBean.List[GroupName]);
......@@ -69,8 +96,7 @@ namespace DeviceLibrary
{
isOk = false;
}
MoveInfo.WaitList.ForEach((w) => {
MoveInfo.WaitList.ToList().ForEach((w) => {
if (w.WaitType.Equals(WaitEnum.W014_Msg)) {
w.IsEnd = true;
Msg.add(w.ActionMsg, w.Data);
......@@ -122,7 +148,10 @@ namespace DeviceLibrary
WarnMsg = MoveInfo.Name + "[" + MoveInfo.MoveStep + "] " + crc.GetString("Res0157", "等待") + "(" + io.DisplayStr + "=" + wait.IoValue + $")" + crc.GetString("Res0158", "超时");
Msg.add(WarnMsg, MsgLevel.alarm);
Msg.add(WarnMsg, wait.NeedAlarm?MsgLevel.alarm: MsgLevel.warning);
if (wait.NeedAlarm)
RobotManage.UserPause(WarnMsg);
if (NoAlarm())
{
//Alarm(AlarmType.IoSingleTimeOut, WarnMsg);
......@@ -254,8 +283,8 @@ namespace DeviceLibrary
IOMove(IoHighType, IO_VALUE.HIGH);
if (moveInfo != null)
{
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IoLowType, IO_VALUE.LOW));
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IoHighType, IO_VALUE.HIGH));
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IoLowType, IO_VALUE.LOW, true));
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IoHighType, IO_VALUE.HIGH, true));
}
}
public IO_VALUE IOValue(string ioType) => IOManager.IOValue(ioType, GroupName);
......
......@@ -55,7 +55,7 @@ namespace DeviceLibrary
});
//ProcessMoveinfoEvent?.Invoke(MoveInfo.List);
if (!RobotManage.mainMachine.UserPause)
if (!RobotManage.mainMachine.UserPause && RobotManage.mainMachine.mstart)
{
DevicesList.ForEach(x =>
{
......
......@@ -42,13 +42,20 @@ namespace DeviceLibrary
RobotManage.UserPause("Reset_BTN", false);
}
}
bool isfirstrun = true;
void Run_BTN() {
if (IOValue(IO_Type.SuddenStop_BTN).Equals(IO_VALUE.HIGH))
{
if (!RobotManage.isRunning)
Msg.add(crc.GetString("Res0163","检测到自动运行状态,开始启动."), MsgLevel.info, ErrInfo.RunBtn);
{
if (isfirstrun)
{
isfirstrun = false;
Msg.add(crc.GetString("Res0163", "检测到自动运行状态,开始启动."), MsgLevel.info, ErrInfo.RunBtn);
}
}
else
Msg.add( crc.GetString("Res0164","系统正在运行."), MsgLevel.info);
Msg.add(crc.GetString("Res0164", "系统正在运行."), MsgLevel.info);
}
else
{
......
......@@ -138,7 +138,7 @@ namespace DeviceLibrary
currnetstoreStatus = isInSuddenDown ? StoreStatus.SuddenStop : StoreStatus.Warning;
}
//ProcessMoveinfoEvent?.Invoke(MoveInfo.List);
if (!UserPause)
if (!UserPause && mstart)
Msg.clear();
else
currnetstoreStatus = StoreStatus.Debugging;
......@@ -150,6 +150,7 @@ namespace DeviceLibrary
LogUtil.info("主线程已退出.");
}
public void Start() {
MoveInfo.List.ForEach((m) => { m.EndMove(); });
Run();
}
public void Stop() {
......
......@@ -47,6 +47,7 @@ namespace DeviceLibrary
public bool IsInWait { get; set; }
MoveStep preMoveStep;
MoveStep moveStep;
public int CanWhileCount = 0;
......@@ -66,7 +67,10 @@ namespace DeviceLibrary
{
get { return moveStep; }
}
public MoveStep PreMoveStep
{
get { return preMoveStep; }
}
public void NewMove(MoveStep step)
{
this.MoveParam = new ReelParam();
......@@ -74,7 +78,7 @@ namespace DeviceLibrary
}
public void NextMoveStep(MoveStep step)
{
// PreMoveStep = moveStep;
preMoveStep = moveStep;
moveStep = step;
LastSetpTime = DateTime.Now;
IsInWait = true;
......@@ -169,12 +173,13 @@ namespace DeviceLibrary
CanWhileMoveCount = 0;
}
public static WaitResultInfo WaitIO(string ioType, IO_VALUE ioValue)
public static WaitResultInfo WaitIO(string ioType, IO_VALUE ioValue,bool needAlarm=false)
{
WaitResultInfo wait = new WaitResultInfo();
wait.WaitType = WaitEnum.W002_IOValue;
wait.IoType = ioType;
wait.IoValue = ioValue;
wait.NeedAlarm = needAlarm;
//wait.Devicegroup = devicegroup;
return wait;
}
......@@ -350,6 +355,7 @@ namespace DeviceLibrary
public Func<WaitResultInfo, bool> Action { get; set; }
public string ActionMsg { get; set; }
public dynamic Data { get; set; }
public bool NeedAlarm { get; set; }
}
internal class WaitEnum
......
......@@ -24,7 +24,7 @@ namespace DeviceLibrary
/// <param name="addr"></param>
/// <param name="trayInfo"></param>
/// <returns>是否放行 放行true, 拦截false</returns>
public static bool Process(MoveInfo moveInfo,string rfid, int addr, out TrayInfo trayInfo) {
public static bool Process(MoveInfo moveInfo,string rfid, int addr,int reelcheck, out TrayInfo trayInfo) {
lock (Traylist)
{
moveInfo.log($"处理RFID:{rfid},地址{addr},设备:{(AddrDesc.ContainsKey(addr)? AddrDesc[addr]:"")}");
......@@ -37,6 +37,10 @@ namespace DeviceLibrary
Traylist[rfid].LastAddr = addr;
Traylist[rfid].Destination = TrayManager.AddrDesc[Traylist[rfid].DestinationAddr];
Traylist[rfid].LastPosition = TrayManager.AddrDesc[Traylist[rfid].LastAddr];
if (reelcheck == 0)
Traylist[rfid].HasLoadCheck--;
else if (reelcheck == 1)
Traylist[rfid].HasLoadCheck = 1;
trayInfo = Traylist[rfid];
//Statistics();
}
......@@ -61,6 +65,7 @@ namespace DeviceLibrary
Traylist[rfid].LoadType = (TrayTypeE)Enum.Parse(typeof(TrayTypeE), requestLoadInfo.TrayType);
Traylist[rfid].TrayParam = requestLoadInfo.LoadParam.clone();
Traylist[rfid].DestinationAddr = GetAddrByGroupName(requestLoadInfo.DeviceGroupName);
Traylist[rfid].HasLoadCheck = 1;
LogUtil.info("设置托盘信息:" + Traylist[rfid].LoadType + "," + Traylist[rfid].TrayParam.ToStr() + "," + requestLoadInfo.DeviceGroupName);
}
SaveTrayInfo();
......@@ -315,7 +320,7 @@ namespace DeviceLibrary
public TrayTypeE TrayType;
public DateTime LastUpdateTime;
public ReelParam TrayParam;
public bool SenSorStatus = false;
public int HasLoadCheck = 0;
public DirectionE Direction { get => (Destination ==StoreCID.AMH_ML5_1 || Destination == StoreCID.AMH_ML5_2) ? DirectionE.Out : DirectionE.In; }
public bool isOnline = true;
public void SetToEmpty() {
......@@ -323,7 +328,7 @@ namespace DeviceLibrary
LoadType = TrayTypeE.None;
DestinationAddr = -1;
TrayParam = new ReelParam();
SenSorStatus = false;
HasLoadCheck = 0;
}
}
......
......@@ -34,7 +34,8 @@ namespace DeviceLibrary
public PuYueRFID_C2S RFID_2 = null;
public LineRunMonitor Line;
LS_TypeE LS_Type = LS_TypeE.NoRfid;
public SideMove(DeviceGroup device,out string msg) {
public SideMove(DeviceGroup device,out string msg) : base()
{
msg = "";
Name = device.Name+"("+ device.GroupName + ")";
DeviceGroup = device;
......@@ -143,8 +144,7 @@ namespace DeviceLibrary
LSAMoveInfo.NextMoveStep(MoveStep.SideMove_02);
Location_A.ToLow(LSAMoveInfo);
//Location_B.ToLow(LSAMoveInfo);
if (!Forcetry)
IOMove(IO_Type.Ls_A_BufStop_Fwd, IO_VALUE.HIGH, StopBufDelayMS);
LSAMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
}
......@@ -166,6 +166,7 @@ namespace DeviceLibrary
}
if (IOValue(IO_Type.Ls_A_Tray_Check).Equals(IO_VALUE.HIGH)) {
LSAMoveInfo.NextMoveStep(MoveStep.SideMove_04);
LSAMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1500));
LastGoInFail = false;
}
else if (LSAMoveInfo.IsTimeOut(10))
......@@ -213,6 +214,7 @@ namespace DeviceLibrary
Line.LineStop("n");
Location_A.ToLow(LSAMoveInfo);
Location_B.ToLow(LSAMoveInfo);
IOMove(IO_Type.Ls_A_BufStop_Fwd, IO_VALUE.HIGH, StopBufDelayMS);
break;
case MoveStep.SideMove_10:
LSAMoveInfo.NextMoveStep(MoveStep.SideMove_01);
......@@ -322,7 +324,7 @@ namespace DeviceLibrary
Minfo.NextMoveStep(MoveStep.SideMove_04);
Minfo.log($"检测到进入的托盘");
Minfo.CanWhileCount = 3;
//Minfo.WaitList.Add(WaitResultInfo.WaitTime(500));
Minfo.WaitList.Add(WaitResultInfo.WaitTime(500));
}
else if (Minfo.IsTimeOut(10))
{
......@@ -344,13 +346,14 @@ namespace DeviceLibrary
Location_a.ToLow(Minfo);
return;
}
Minfo.CanWhileCount = 3;
//Location_a.ToHigh(Minfo);
break;
case MoveStep.SideMove_05:
if (RFID.ReadByte(0x20,16,out byte[] data, out string errmsg))
{
var rfid = Common.RfidFilter(data);
TrayManager.Process(Minfo,rfid, addr, out TrayInfo trayInfo);
TrayManager.Process(Minfo,rfid, addr,-1, out TrayInfo trayInfo);
if (TrayManager.CalcNeedTrans(addr, trayInfo.DestinationAddr, trayInfo.HasLoad))
Minfo.NextMoveStep(MoveStep.SideMove_10);
......
......@@ -35,7 +35,8 @@ namespace DeviceLibrary
CylinderManger Transplant;
public DeviceStateE DeviceState { get ; set ; }
public TransplantMove(DeviceGroup device, Robot_Config config, out string msg) {
public TransplantMove(DeviceGroup device, Robot_Config config, out string msg) : base()
{
msg = "";
Name = device.Name+"("+ device.GroupName + ")";
Config = config;
......@@ -98,17 +99,19 @@ namespace DeviceLibrary
}
else if (IOValue(IO_Type.AMH_Front_Check).Equals(IO_VALUE.HIGH))
{
if (GroupName == "AMH-SBSH2" && !canpass()) //SBSH2 等待前面空闲再放行
return;
MoveInfo.NextMoveStep(MoveStep.TransplantMove_01);
Location.ToLow(MoveInfo);
Location.ToLow(MoveInfo);
}
else
{
//Msg.add(crc.GetString("Res0184", "空闲中"), MsgLevel.info);
}
if (TrayManager.TestTrayRequest(GroupName)) {
Transplant.ToHigh(null);
}
//if (TrayManager.TestTrayRequest(GroupName)) {
// Transplant.ToHigh(null);
//}
break;
case MoveStep.TransplantMove_01:
MoveInfo.NextMoveStep(MoveStep.TransplantMove_02);
......@@ -123,7 +126,7 @@ namespace DeviceLibrary
{
MoveInfo.NextMoveStep(MoveStep.TransplantMove_03);
MoveInfo.CanWhileCount = 3;
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
//Location.ToHigh(MoveInfo);
}
else if (MoveInfo.IsTimeOut(10)) {
......@@ -136,7 +139,7 @@ namespace DeviceLibrary
{
CurrrentRFID = Common.RfidFilter(data);
MoveInfo.MoveParam.RFID = CurrrentRFID;
var through = TrayManager.Process(MoveInfo,CurrrentRFID, DeviceGroup.addr_1, out TrayInfo trayInfo);
var through = TrayManager.Process(MoveInfo,CurrrentRFID, DeviceGroup.addr_1, IOValue(IO_Type.AMH_Reel_Check).Equals(IO_VALUE.HIGH)?1:0, out TrayInfo trayInfo);
MoveInfo.log($"rfid:{CurrrentRFID},TrayManager.Process:{trayInfo.DestinationAddr},{DeviceGroup.addr_1},AMH_Reel_Check:{IOValue(IO_Type.AMH_Reel_Check)},HasLoad:{trayInfo.HasLoad}");
//入库判断
if (trayInfo.DestinationAddr == DeviceGroup.addr_1 && trayInfo.HasLoad)
......@@ -244,7 +247,8 @@ namespace DeviceLibrary
{
IOMove(IO_Type.AMH_Tray_Stop, IO_VALUE.LOW);
MoveInfo.NextMoveStep(MoveStep.Wait);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
if (GroupName == "AMH-SBSH2")
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(3000));
MoveInfo.log("托盘已放行");
} else if (MoveInfo.IsTimeOut(10)) {
MoveInfo.log("托盘放行失败,重新放行");
......@@ -328,7 +332,9 @@ namespace DeviceLibrary
IOMove(IO_Type.AMH_Tray_Stop, IO_VALUE.LOW);
MoveInfo.log("托盘放行结束");
SRec.info(crc.GetString("Res0024","物料横移"), GroupName, crc.GetString("Res0030","空托盘"), crc.GetString("Res0037","物料已取走"));
MoveInfo.NewMove(MoveStep.Wait);
MoveInfo.NewMove(MoveStep.Wait);
if (GroupName == "AMH-SBSH2")
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(3000));
break;
//从料仓=>线体
case MoveStep.TransplantMove_20:
......@@ -442,7 +448,9 @@ namespace DeviceLibrary
case MoveStep.TransplantMove_30:
MoveInfo.NextMoveStep(MoveStep.TransplantMove_31);
IOMove(IO_Type.AMH_Tray_Stop, IO_VALUE.LOW);
//MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
MoveInfo.NewMove(MoveStep.Wait);
if (GroupName == "AMH-SBSH2")
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(3000));
break;
case MoveStep.TransplantMove_31:
SRec.error(crc.GetString("Res0024","物料横移"), GroupName, crc.GetString("Res0025","载物托盘"), crc.GetString("Res0038","物料已到托盘"), CurrrentRFID, MoveInfo.MoveParam.ToStr());
......@@ -530,7 +538,7 @@ namespace DeviceLibrary
{
if (string.IsNullOrEmpty(CurrrentRFID))
CurrrentRFID = ConfigHelper.Config.Get($"Runtime_{GroupName}_CurrrentRFID");
TrayManager.Process(MoveInfo, CurrrentRFID, DeviceGroup.addr_1, out _);
TrayManager.Process(MoveInfo, CurrrentRFID, DeviceGroup.addr_1,-1, out _);
MoveInfo.log("检测到上次已打开吸盘,CurrrentRFID:"+ CurrrentRFID);
//入库过程
if (ConfigHelper.Config.Get($"Runtime_{GroupName}_IsInStore", false) && IOValue(IO_Type.AMH_Reel_Check).Equals(IO_VALUE.LOW))
......@@ -576,7 +584,7 @@ namespace DeviceLibrary
{
if (IOManager.IOValue(IO_Type.Ls_B_Front_Check, "LS2").Equals(IO_VALUE.HIGH))
{
Msg.add(crc.GetString("Res0039","LS2-2 堵塞中,暂缓放行"), MsgLevel.warning);
Msg.add(crc.GetString("Res0039","LS2-2 堵塞中,暂缓放行"), MsgLevel.info);
return false;
}
}
......@@ -584,7 +592,7 @@ namespace DeviceLibrary
{
if (IOManager.IOValue(IO_Type.Ls_A_Front_Check, "LS2").Equals(IO_VALUE.HIGH))
{
Msg.add(crc.GetString("Res0040","LS2-1 堵塞中,暂缓放行"), MsgLevel.warning);
Msg.add(crc.GetString("Res0040","LS2-1 堵塞中,暂缓放行"), MsgLevel.info);
return false;
}
}
......
......@@ -34,9 +34,10 @@ namespace DeviceLibrary
public AxisBean axis;
public AxisBean axis2;
public TrayStop(DeviceGroup device,out string msg) {
public TrayStop(DeviceGroup device, out string msg) : base()
{
msg = "";
Name = device.Name+"("+ device.GroupName + ")";
Name = device.Name + "(" + device.GroupName + ")";
DeviceGroup = device;
GroupName = DeviceGroup.GroupName;
Msg = new MsgService(GroupName);
......@@ -44,15 +45,16 @@ namespace DeviceLibrary
if (!string.IsNullOrEmpty(DeviceGroup.RFID_1))
{
RFID_1 = new PuYueRFID_C2S(DeviceGroup.RFID_1);
if (!RFID_1.Open()) {
msg += DeviceGroup.GroupName + " RFID 1:" + DeviceGroup.RFID_1 +","+crc.GetString("Res0183","打开失败")+ "\r\n";
if (!RFID_1.Open())
{
msg += DeviceGroup.GroupName + " RFID 1:" + DeviceGroup.RFID_1 + "," + crc.GetString("Res0183", "打开失败") + "\r\n";
}
}
Location = new CylinderManger($"托盘顶升", GroupName, IO_Type.MI_Location_Up, IO_Type.MI_Location_Down);
var axisc = RobotManage.Config.moveAxisList.Find(ma => ma.GetAxisValue() == RobotManage.DeviceGroup[GroupName].AxisID);
if (axisc != null)
axis = new AxisBean(axisc, GroupName);
axis = new AxisBean(axisc, GroupName);
axisc = RobotManage.Config.moveAxisList.Find(ma => ma.GetAxisValue() == RobotManage.DeviceGroup[GroupName].Axis2ID);
if (axisc != null)
axis2 = new AxisBean(axisc, GroupName);
......@@ -80,7 +82,6 @@ namespace DeviceLibrary
OneWayProcess();
}
}
int isalivetrytimes = 0;
int StopBufDelayMS = 500;
int StopDelayMS = 1500;
public void OneWayProcess()
......@@ -142,7 +143,7 @@ namespace DeviceLibrary
if (RFID_1.ReadByte(0x20, 16, out byte[] data, out string errmsg))
{
CurrrentRFID = Common.RfidFilter(data);
TrayManager.Process(MoveInfo, CurrrentRFID, DeviceGroup.addr_1, out TrayInfo trayInfo);
TrayManager.Process(MoveInfo, CurrrentRFID, DeviceGroup.addr_1, IOValue(IO_Type.MI_Reel_Check).Equals(IO_VALUE.HIGH)?1:0, out TrayInfo trayInfo);
var stop = TrayManager.TryGetTrayRequest(GroupName, CurrrentRFID, out _);
MoveInfo.log($"CurrrentRFID:{CurrrentRFID},HasLoad:{trayInfo.HasLoad},MI_Reel_Check:{IOValue(IO_Type.MI_Reel_Check)},NeedStop:{stop}");
#region 张东亮处理
......@@ -332,7 +333,7 @@ namespace DeviceLibrary
case MoveStep.TrayStop_07:
MoveInfo.NextMoveStep(MoveStep.TrayStop_WaitLoadProcess);
Location.ToHigh(MoveInfo);
isalivetrytimes = 0;
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
break;
case MoveStep.TrayStop_WaitLoadProcess:
Msg.add(crc.GetString("Res0046","等待处理物料"),MsgLevel.info);
......@@ -360,9 +361,17 @@ namespace DeviceLibrary
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
MoveInfo.WaitList.Add(WaitResultInfo.WaitMsg(crc.GetString("Res0046","等待处理物料"), MsgLevel.info));
}
}
}
break;
case MoveStep.TrayStop_LoadProcessed:
if (TrayManager.Traylist.ContainsKey(CurrrentRFID) && TrayManager.Traylist[CurrrentRFID].HasLoad)
{
if (IOValue(IO_Type.MI_Reel_Check).Equals(IO_VALUE.LOW))
{
Msg.add("托盘放料后没有检测到物料", MsgLevel.alarm);
return;
}
}
MoveInfo.NextMoveStep(MoveStep.TrayStop_04);
Location.ToLow(MoveInfo);
MoveInfo.log("物料离开, 顶升下降");
......@@ -428,15 +437,32 @@ namespace DeviceLibrary
switch (MoveInfo.MoveStep)
{
case MoveStep.Wait:
if ((GroupName == "AMH-ML5-1" || GroupName == "AMH-ML5-2") && RobotManage.mainMachine.IOValue(IO_Type.ML5_DoorSafeCheck).Equals(IO_VALUE.LOW))
{
Msg.add(crc.GetString("Res0041","ML5料口门光栅被遮挡"), MsgLevel.warning);
break;
}
MoveInfo.NextMoveStep(MoveStep.H01_HomeReset);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
break;
case MoveStep.H01_HomeReset:
if ((GroupName == "AMH-ML5-1" || GroupName == "AMH-ML5-2") && RobotManage.mainMachine.IOValue(IO_Type.ML5_DoorSafeCheck).Equals(IO_VALUE.LOW))
{
Msg.add(crc.GetString("Res0041", "ML5料口门光栅被遮挡"), MsgLevel.warning);
break;
}
var dl = new string[] { "AMH-MI1" };//, "AMH-MI2" };
foreach (var d in dl)
{
if (GroupName == d && MI.DeviceList[d].DeviceState != DeviceStateE.Run
&& MI.DeviceList[d].MoveInfo.MoveStep != MoveStep.Wait)
{
Msg.add("等待" + d + "完成复位", MsgLevel.warning);
}
else if (GroupName == d && MI.DeviceList[d].DeviceState == DeviceStateE.Run
&& MI.DeviceList[d].MoveInfo.MoveStep != MoveStep.Wait)
{
MoveInfo.NextMoveStep(MoveStep.TrayStop_WaitLoadProcess);
DeviceState = DeviceStateE.Run;
return;
}
}
MoveInfo.NextMoveStep(MoveStep.H02_HomeReset);
Location.ToLow(MoveInfo);
break;
......
......@@ -33,50 +33,30 @@ namespace RemoteSheardObject
return !string.IsNullOrEmpty(SubmitPostData("/service/store/robotBox/updateLocInfo", postData));
}
public static string SubmitPostData(string url, Dictionary<string, string> postData)
public static Dictionary<string,int> GetTaskCount()
{
url = CombineUrl(Config.Get("Device_Server_Address"), url);
//创建WebClient对象
using (var client = new WebClient())
//pizzaBox,pcb,tray,reel
var postData = new Dictionary<string, string>()
{
//设置提交数据的方式为"application/x-www-form-urlencoded"
client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
try
{
//将POST请求参数字典转换为参数字符串
var postDataString = new StringBuilder();
foreach (var item in postData)
{
if (!string.IsNullOrEmpty(item.Value))
{
postDataString.AppendFormat("{0}={1}&", item.Key, Uri.EscapeDataString(item.Value));
}
}
//去掉最后一个"&"符号
postDataString.Length--;
//将POST请求参数转换为字节数组
byte[] bytes = Encoding.UTF8.GetBytes(postDataString.ToString());
//提交POST请求并获取响应
byte[] response = client.UploadData(url, "POST", bytes);
};
Dictionary<string, int> taskdata = new Dictionary<string, int>();
taskdata["pizzaBox"] = 0;
taskdata["pcb"] = 0;
taskdata["tray"] = 0;
taskdata["reel"] = 0;
//将响应转换为字符串并输出
return Encoding.UTF8.GetString(response);
var result= JsonConvert.DeserializeObject<ResultData>(SubmitPostData("/rest/micron/device/getTaskCount", postData));
if (result.code != 0)
return taskdata;
}
catch (Exception ex)
{
// 捕获任何网络异常,并输出错误信息
Console.WriteLine("提交POST请求时发生错误:" + ex.Message);
// 请求失败,返回false
return "";
}
foreach (var k in taskdata.Keys)
{
if (result.data.ContainsKey(k))
taskdata[k] = int.Parse(result.data[k]);
}
return taskdata;
}
public static string CombineUrl(string baseUrl, string relativeUrl)
{
if (string.IsNullOrEmpty(baseUrl))
......@@ -112,6 +92,12 @@ namespace RemoteSheardObject
return default;
}
public static void UploadStatus(EquipMsgData equipMsgData)
{
string url = CombineUrl(Config.Get("Device_Server_Address"), "/rest/micron/device/updateStatus");
var resultStr = HttpHelper.Post<EquipMsgData, ResultData>(url, equipMsgData);
}
public class ResultData
{
//{"code":0,"msg":"ok","data":"7"}
......@@ -121,5 +107,49 @@ namespace RemoteSheardObject
public Dictionary<string, string> data { get; set; }
}
public static string SubmitPostData(string url, Dictionary<string, string> postData)
{
url = CombineUrl(Config.Get("Device_Server_Address"), url);
//创建WebClient对象
using (var client = new WebClient())
{
//设置提交数据的方式为"application/x-www-form-urlencoded"
client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
try
{
//将POST请求参数字典转换为参数字符串
var postDataString = new StringBuilder();
foreach (var item in postData)
{
if (!string.IsNullOrEmpty(item.Value))
{
postDataString.AppendFormat("{0}={1}&", item.Key, Uri.EscapeDataString(item.Value));
}
}
//去掉最后一个"&"符号
postDataString.Length--;
//将POST请求参数转换为字节数组
byte[] bytes = Encoding.UTF8.GetBytes(postDataString.ToString());
//提交POST请求并获取响应
byte[] response = client.UploadData(url, "POST", bytes);
//将响应转换为字符串并输出
return Encoding.UTF8.GetString(response);
}
catch (Exception ex)
{
// 捕获任何网络异常,并输出错误信息
Console.WriteLine("提交POST请求时发生错误:" + ex.Message);
// 请求失败,返回false
return "";
}
}
}
}
}
......@@ -367,6 +367,7 @@ namespace TheMachine
// RobotManage.mainMachine.Msg.Show();
// //return;
//}
LogUtil.info("用户按下启动:"+ sender.ToString());
RobotManage.Start();
userpause = false;
if (RobotManage.isRunning)
......@@ -375,7 +376,7 @@ namespace TheMachine
RobotManage_UserPauseSet(this, false);
//(sender as Button).Text = "暂停运行";
}
LogUtil.info("用户按下启动");
}
else if (!userpause)
{
......
......@@ -46,7 +46,7 @@ namespace TheMachine
}
}
}
Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true).SetValue(Application.ProductName, Application.ExecutablePath);
Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true).SetValue(Application.ProductName, Application.ExecutablePath);
Config.LoadMyConfig(new Setting_Init().GetType());
Application.ThreadException += Application_ThreadException;
......
......@@ -145,6 +145,9 @@ namespace TheMachine
listView1.Items[ti.RFID].ForeColor = Color.DarkGray;
else
listView1.Items[ti.RFID].ForeColor = Color.Black;
if (ti.HasLoad && ti.HasLoadCheck<0)
listView1.Items[ti.RFID].ForeColor = Color.Red;
}
ListView2.Items.Clear();
foreach (var tivk in TrayManager.TrayRequest.ToArray())
......
......@@ -80,5 +80,16 @@ namespace TheMachine.device.Other
stateView.Items.Add(lvi);
}
}
private void btn_ResetRobot_Click(object sender, EventArgs e)
{
if (RobotManage.isRunning)
{
MessageBox.Show("请先停止系统运行");
return;
}
MI.DeviceList["AMH-MI1"].
}
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!