Commit d6d176be 刘韬

1

1 个父辈 93afe3d7
...@@ -89,7 +89,7 @@ namespace OnlineStore.Common ...@@ -89,7 +89,7 @@ namespace OnlineStore.Common
try try
{ {
using (var wc = new MyWebClient(10000)) using (var wc = new MyWebClient(timeOut))
{ {
if (string.IsNullOrEmpty(wc.Headers["Content-Type"])) if (string.IsNullOrEmpty(wc.Headers["Content-Type"]))
{ {
...@@ -110,31 +110,12 @@ namespace OnlineStore.Common ...@@ -110,31 +110,12 @@ namespace OnlineStore.Common
return result; return result;
} }
static object lockpost = new object(); static object lockpost = new object();
public static Operation Post(string url, Operation operation, bool simulate, bool printlog=false) public static Operation Post(string url, Operation operation,int timeout=5000, bool printlog=false)
{ {
try try
{ {
if (simulate)
{//模拟服务器返回
operation.status = 200;
operation.data.Clear();
operation.data.Add("posId", "A001");
string pos = "D100-111#D102-222#D104-333";
operation.data.Add("pos", pos);
if (operation.op == 1 || operation.op == 2)
{//入库或出库
string json = JsonHelper.SerializeObject(operation); string json = JsonHelper.SerializeObject(operation);
LogUtil.error( "模拟HTTP服务器返回出库入库信息:" + json); string result = Post(url, json, timeout);
return operation;
}
}
else
{
//lock (lockpost)
{
string json = JsonHelper.SerializeObject(operation);
string result = Post(url, json,2000);
Operation op = JsonHelper.DeserializeJsonToObject<Operation>(result); Operation op = JsonHelper.DeserializeJsonToObject<Operation>(result);
if (printlog) if (printlog)
...@@ -143,8 +124,6 @@ namespace OnlineStore.Common ...@@ -143,8 +124,6 @@ namespace OnlineStore.Common
} }
return op; return op;
} }
}
}
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error("Post 出错【operation.op=" + operation.op + "】:" + ex); LogUtil.error("Post 出错【operation.op=" + operation.op + "】:" + ex);
......
...@@ -36,12 +36,22 @@ namespace DeviceLibrary ...@@ -36,12 +36,22 @@ namespace DeviceLibrary
serverConnectTimer.AutoReset = true; serverConnectTimer.AutoReset = true;
serverConnectTimer.Enabled = true; serverConnectTimer.Enabled = true;
serverConnectTimer.Elapsed += ServerConnectTimer_Elapsed; serverConnectTimer.Elapsed += ServerConnectTimer_Elapsed;
GC.KeepAlive(serverConnectTimer);
} }
int lockerrtime = 0;
private void ServerConnectTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) private void ServerConnectTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{ {
if (!Monitor.TryEnter(serverConnectTimer)) //if (!Monitor.TryEnter(serverConnectTimer))
return; //{
// LogUtil.error("ServerConnectTimer_Elapsed locked");
// lockerrtime++;
// if (lockerrtime > 3)
// {
// lockerrtime = 0;
// Monitor.Exit(serverConnectTimer);
// }
// return;
//}
try try
{ {
if (!RobotManage.isRunning) if (!RobotManage.isRunning)
...@@ -53,7 +63,7 @@ namespace DeviceLibrary ...@@ -53,7 +63,7 @@ namespace DeviceLibrary
} }
finally { finally {
Monitor.Exit(serverConnectTimer); //Monitor.Exit(serverConnectTimer);
} }
} }
public void StartConnectServer() { public void StartConnectServer() {
...@@ -93,7 +103,7 @@ namespace DeviceLibrary ...@@ -93,7 +103,7 @@ namespace DeviceLibrary
{ {
operation.data.Add("singleIn", "false"); operation.data.Add("singleIn", "false");
} }
Operation resultOperation = HttpHelper.Post(GetPostApi(), operation, false, printlog); Operation resultOperation = HttpHelper.Post(GetPostApi(), operation, 5000, printlog);
if (operation.seq != resultOperation.seq) if (operation.seq != resultOperation.seq)
{ {
Thread.Sleep(1000); Thread.Sleep(1000);
...@@ -107,7 +117,6 @@ namespace DeviceLibrary ...@@ -107,7 +117,6 @@ namespace DeviceLibrary
{ {
lock (serverclock) lock (serverclock)
{ {
retry:
Operation operation = getLineBoxStatus(); Operation operation = getLineBoxStatus();
if (!string.IsNullOrEmpty(posid)) if (!string.IsNullOrEmpty(posid))
operation.boxStatus[StoreID].data.Add(ParamDefine.posId, posid); operation.boxStatus[StoreID].data.Add(ParamDefine.posId, posid);
...@@ -117,14 +126,18 @@ namespace DeviceLibrary ...@@ -117,14 +126,18 @@ namespace DeviceLibrary
LogUtil.info(JsonHelper.SerializeObject(operation)); LogUtil.info(JsonHelper.SerializeObject(operation));
if (RobotManage.InoutDebugMode) if (RobotManage.InoutDebugMode)
return true; return true;
Operation resultOperation = HttpHelper.Post(GetPostApi(), operation, false); Operation resultOperation = HttpHelper.Post(GetPostApi(), operation, 5000);
if (resultOperation == null) if (resultOperation == null)
{ {
LogUtil.info($"SendStoreState error,posid:{posid}, storeStatus:{storeStatus}"); LogUtil.info($"SendStoreState error,posid:{posid}, storeStatus:{storeStatus}");
//goto retry;
return false; return false;
} }
if (operation.seq != resultOperation.seq) {
LogUtil.info($"SendStoreState seq error,posid:{posid}, storeStatus:{storeStatus}");
return false;
}
LogUtil.info($"SendStoreState success,posid:{posid}, storeStatus:{storeStatus}"); LogUtil.info($"SendStoreState success,posid:{posid}, storeStatus:{storeStatus}");
ResultProcess(resultOperation); ResultProcess(resultOperation);
...@@ -267,7 +280,7 @@ namespace DeviceLibrary ...@@ -267,7 +280,7 @@ namespace DeviceLibrary
printlog = true; printlog = true;
} }
Operation resultOperation = HttpHelper.Post(GetPostApi(), lineOperation, printlog); Operation resultOperation = HttpHelper.Post(GetPostApi(), lineOperation,700, printlog);
if (resultOperation != null) if (resultOperation != null)
getthtime = 0; getthtime = 0;
//LogUtil.info(JsonHelper.SerializeObject(resultOperation.data)); //LogUtil.info(JsonHelper.SerializeObject(resultOperation.data));
...@@ -376,17 +389,17 @@ namespace DeviceLibrary ...@@ -376,17 +389,17 @@ namespace DeviceLibrary
return map; return map;
if (RobotManage.mainMachine.IOValue(IO_Type.StringDoor_Close).Equals(IO_VALUE.HIGH) if (//RobotManage.mainMachine.IOValue(IO_Type.StringDoor_Close).Equals(IO_VALUE.HIGH) &&
&& (RobotManage.mainMachine.StringMoveInfo.MoveStep == MoveStep.StringOut_Released (RobotManage.mainMachine.StringMoveInfo.MoveStep == MoveStep.StringOut_Released
|| RobotManage.mainMachine.StringMoveInfo.MoveStep == MoveStep.Wait)) || RobotManage.mainMachine.StringMoveInfo.MoveStep == MoveStep.Wait))
{ {
map.Add(ParamDefine.doorStatus, "料串门关闭"); //map.Add(ParamDefine.doorStatus, "料串门关闭");
map[ParamDefine.openLock] = ParamDefine.enable; map[ParamDefine.openLock] = ParamDefine.enable;
} }
else if (RobotManage.mainMachine.IOValue(IO_Type.StringDoor_Open).Equals(IO_VALUE.HIGH)) //else// if (RobotManage.mainMachine.IOValue(IO_Type.StringDoor_Open).Equals(IO_VALUE.HIGH))
{ {
map[ParamDefine.closeLock] = ParamDefine.enable; map[ParamDefine.closeLock] = ParamDefine.enable;
map.Add(ParamDefine.doorStatus, "料串门打开"); //map.Add(ParamDefine.doorStatus, "料串门打开");
} }
if (RobotManage.mainMachine.StringMoveInfo.MoveStep >= MoveStep.StringLoad_04 if (RobotManage.mainMachine.StringMoveInfo.MoveStep >= MoveStep.StringLoad_04
&& RobotManage.mainMachine.StringMoveInfo.MoveStep < MoveStep.StringOut_01) && RobotManage.mainMachine.StringMoveInfo.MoveStep < MoveStep.StringOut_01)
......
...@@ -113,13 +113,12 @@ namespace DeviceLibrary ...@@ -113,13 +113,12 @@ namespace DeviceLibrary
case MoveStep.StoreTS01: case MoveStep.StoreTS01:
if (IOManager.IOValue(IO_Type.TrayCheck_Fixture).Equals(IO_VALUE.HIGH)) if (IOManager.IOValue(IO_Type.TrayCheck_Fixture).Equals(IO_VALUE.HIGH))
{ {
if (!IgnoreX09 && IOMonitor.IODebound(IO_Type.TrayCheck_Fixture,Config,IO_VALUE.HIGH,5000)) if (!IgnoreX09 && IOMonitor.IODebound(IO_Type.TrayCheck_Fixture, Config, IO_VALUE.HIGH, 5000))
Msg.add(crc.GetString(L.out_store_detect_material,"出库时料叉X30检测到有物料无法继续,请检查."), MsgLevel.alarm, ErrInfo.X09_BoxNotDetect); Msg.add(crc.GetString(L.out_store_detect_material, "出库时料叉X30检测到有物料无法继续,请检查."), MsgLevel.alarm, ErrInfo.X09_BoxNotDetect);
//RobotManage.UserPause("出库时料叉X30检测到有物料无法继续,请检查"); //RobotManage.UserPause("出库时料叉X30检测到有物料无法继续,请检查");
} }
else else
{ {
Msg.add("", MsgLevel.info, ErrInfo.X09_Clear); Msg.add("", MsgLevel.info, ErrInfo.X09_Clear);
IgnoreX09 = false; IgnoreX09 = false;
MoveInfo.NextMoveStep(MoveStep.StoreTS02); MoveInfo.NextMoveStep(MoveStep.StoreTS02);
......
...@@ -154,7 +154,7 @@ namespace DeviceLibrary ...@@ -154,7 +154,7 @@ namespace DeviceLibrary
Comp_PL = Comp_PL < 0 ? 0 : Comp_PL; Comp_PL = Comp_PL < 0 ? 0 : Comp_PL;
posid = aCStorePosition.PositionNum; posid = aCStorePosition.PositionNum;
Reel = reel.clone(); Reel = reel.clone();
LogUtil.info($"BSP:{posid},Comp_PH:{Comp_PH}={aCStorePosition.BagHigh},Comp_PL:{Comp_PL}={reel.PlateH},Comp_PL_MM:{Config.Comp_PL_MM},{JsonHelper.SerializeObject(this)}"); LogUtil.info($"BSP:{posid},Comp_PH:{Comp_PH}={Config.Comp_P2}-({aCStorePosition.BagHigh}-{8}+{Config.Comp_PH_MM})*{Config.Clamp_PoToMM},Comp_PL:{Comp_PL}={reel.PlateH},Comp_PL_MM:{Config.Comp_PL_MM},{JsonHelper.SerializeObject(this)}");
} }
public const string ngdoor = "单料口"; public const string ngdoor = "单料口";
public const string strings = "料串口"; public const string strings = "料串口";
......
...@@ -51,12 +51,6 @@ namespace DeviceLibrary ...@@ -51,12 +51,6 @@ namespace DeviceLibrary
} }
LogUtil.info("按下启动按钮"); LogUtil.info("按下启动按钮");
ProcessMsgEvent?.Invoke(Msg.get()); ProcessMsgEvent?.Invoke(Msg.get());
//未启动时按钮
//if (!RobotManage.isRunning)
//{
//
//}
} }
} }
} }
...@@ -37,16 +37,16 @@ namespace DeviceLibrary ...@@ -37,16 +37,16 @@ namespace DeviceLibrary
Current_Temperate = temp.Temperate; Current_Temperate = temp.Temperate;
//var tempIsOK = Current_Temperate < ServerCM.Max_Temperature; //var tempIsOK = Current_Temperate < ServerCM.Max_Temperature;
var humiIsOK = Current_Humidity < ServerCM.Max_Humidity - ConfigHelper.Config.Get("Device_HumidityStartOffser", 1) var humiNeedStart = Current_Humidity > ServerCM.Max_Humidity - ConfigHelper.Config.Get("Device_HumidityStartOffser", 1);
&& Current_Humidity > ServerCM.Max_Humidity - ConfigHelper.Config.Get("Device_HumidityEndOffser", 10); var humiNeedStop = Current_Humidity < ServerCM.Max_Humidity - ConfigHelper.Config.Get("Device_HumidityEndOffser", 10);
if (!humiIsOK && !airisopen) if (humiNeedStart && !airisopen)
{ {
IOMove(IO_Type.NitrogenValve, IO_VALUE.HIGH); IOMove(IO_Type.NitrogenValve, IO_VALUE.HIGH);
airisopen = true; airisopen = true;
LogUtil.info($"开始吹气,当前最大湿度:{Current_Humidity} > {ServerCM.Max_Humidity}-{ConfigHelper.Config.Get("Device_HumidityStartOffser", 1)}."); LogUtil.info($"开始吹气,当前最大湿度:{Current_Humidity} > {ServerCM.Max_Humidity}-{ConfigHelper.Config.Get("Device_HumidityStartOffser", 1)}.");
} }
else if (humiIsOK && airisopen) else if (humiNeedStop && airisopen)
{ {
IOMove(IO_Type.NitrogenValve, IO_VALUE.LOW); IOMove(IO_Type.NitrogenValve, IO_VALUE.LOW);
airisopen = false; airisopen = false;
...@@ -57,7 +57,7 @@ namespace DeviceLibrary ...@@ -57,7 +57,7 @@ namespace DeviceLibrary
DateTime lastTHoutRangeTime = DateTime.MaxValue; DateTime lastTHoutRangeTime = DateTime.MaxValue;
bool IsTHoutRange() bool IsTHoutRange()
{ {
if (HumitureController.LastData.Humidity > ServerCM.Max_Humidity if (HumitureController.LastData.Humidity > ServerCM.Max_Humidity// || HumitureController.LastData.Humidity < ServerCM.Min_Humidity
|| HumitureController.LastData.Temperate > ServerCM.Max_Temperature) || HumitureController.LastData.Temperate > ServerCM.Max_Temperature)
{ {
if (!lastTHoutRangeStatus) if (!lastTHoutRangeStatus)
......
...@@ -305,7 +305,7 @@ namespace DeviceLibrary ...@@ -305,7 +305,7 @@ namespace DeviceLibrary
return; return;
} }
if (!ConfigHelper.Config.Get("Device_Disable_StringDoor", false)) if (!ConfigHelper.Config.Get("Device_Disable_StringDoor", false))
CylinderMove(StringMoveInfo, IO_Type.StringDoor_Close, IO_Type.StringDoor_Open, IO_VALUE.LOW); CylinderMove(ResetMoveInfo, IO_Type.StringDoor_Close, IO_Type.StringDoor_Open, IO_VALUE.LOW);
break; break;
case MoveStep.H02_HomeReset_01: case MoveStep.H02_HomeReset_01:
ResetMoveInfo.NextMoveStep(MoveStep.H02_HomeReset); ResetMoveInfo.NextMoveStep(MoveStep.H02_HomeReset);
......
...@@ -162,9 +162,12 @@ namespace DeviceLibrary ...@@ -162,9 +162,12 @@ namespace DeviceLibrary
case MoveStep.StoreOut12: case MoveStep.StoreOut12:
if (boxTransport.IsPutOnOut) if (boxTransport.IsPutOnOut)
{ {
if (!ServerCM.SendStoreState(StoreMoveInfo.MoveParam.PosID, StoreStatus.OutStoreEnd))
{
Msg.add("服务器连接异常", MsgLevel.warning);
return;
}
StoreMoveInfo.log($"料盘已到达目的地"); StoreMoveInfo.log($"料盘已到达目的地");
ServerCM.SendStoreState(StoreMoveInfo.MoveParam.PosID, StoreStatus.OutStoreEnd);
if (StoreMoveInfo.MoveParam.IsNg) if (StoreMoveInfo.MoveParam.IsNg)
{ {
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!