Commit 5819f363 刘韬

优化入库超时

1 个父辈 7f9ed739
...@@ -52,6 +52,80 @@ namespace DeviceLibrary ...@@ -52,6 +52,80 @@ namespace DeviceLibrary
<Command>GetCarrierList</Command> <Command>GetCarrierList</Command>
<Parameter/> <Parameter/>
</XmlCommand>"; </XmlCommand>";
public const string NewCarrier = @"<XmlCommand>
<Command>NewCarrier</Command>
<Parameter>
<CarrierInformation>
<ID>0</ID>
<Carrier>{1}</Carrier>
<CreateDate>0001-01-01T00:00:00</CreateDate>
<Article>0</Article>
<ArticleName>{2}</ArticleName>
<DepotDate>0001-01-01T00:00:00</DepotDate>
<Stock>{3}</Stock>
<StockMin>0</StockMin>
<StockNew>0</StockNew>
<StockUsed>0</StockUsed>
<StockTPSys>0</StockTPSys>
<Guessed>false</Guessed>
<Cycles>0</Cycles>
<Outtime>0</Outtime>
<Unleaded>false</Unleaded>
<PriceP>0</PriceP>
<Height>0</Height>
<HCode>0</HCode>
<Diameter>0</Diameter>
<StepWidth>0</StepWidth>
<Duration>0</Duration>
<Frequency>0</Frequency>
<Amplitude>0</Amplitude>
<MSLWatch>false</MSLWatch>
<MSLDate>0001-01-01T00:00:00</MSLDate>
<DryDate>0001-01-01T00:00:00</DryDate>
<Expiry>0001-01-01T00:00:00</Expiry>
<Core>0</Core>
<TapeHeight>0</TapeHeight>
</CarrierInformation>
</Parameter>
</XmlCommand>";
public const string UpdateCarrier = @"<XmlCommand>
<Command>UpdateCarrier</Command>
<Parameter>
<CarrierInformation>
<ID>0</ID>
<Carrier>{1}</Carrier>
<CreateDate>0001-01-01T00:00:00</CreateDate>
<Article>0</Article>
<ArticleName>{2}</ArticleName>
<DepotDate>0001-01-01T00:00:00</DepotDate>
<Stock>{3}</Stock>
<StockMin>0</StockMin>
<StockNew>0</StockNew>
<StockUsed>0</StockUsed>
<StockTPSys>0</StockTPSys>
<Guessed>false</Guessed>
<Cycles>0</Cycles>
<Outtime>0</Outtime>
<Unleaded>false</Unleaded>
<PriceP>0</PriceP>
<Height>0</Height>
<HCode>0</HCode>
<Diameter>0</Diameter>
<StepWidth>0</StepWidth>
<Duration>0</Duration>
<Frequency>0</Frequency>
<Amplitude>0</Amplitude>
<MSLWatch>false</MSLWatch>
<MSLDate>0001-01-01T00:00:00</MSLDate>
<DryDate>0001-01-01T00:00:00</DryDate>
<Expiry>0001-01-01T00:00:00</Expiry>
<Core>0</Core>
<TapeHeight>0</TapeHeight>
</CarrierInformation>
</Parameter>
</XmlCommand>";
static VCmd() static VCmd()
{ {
wslist.Add("GetTowers", @"<XmlCommand> wslist.Add("GetTowers", @"<XmlCommand>
......
...@@ -9,9 +9,6 @@ using System.Collections.Concurrent; ...@@ -9,9 +9,6 @@ using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.ServiceModel; using System.ServiceModel;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml; using System.Xml;
namespace DeviceLibrary namespace DeviceLibrary
...@@ -23,10 +20,12 @@ namespace DeviceLibrary ...@@ -23,10 +20,12 @@ namespace DeviceLibrary
/// 出库,reelid /// 出库,reelid
/// </summary> /// </summary>
public event EventHandler<JobInfo> OutStoreEvent; public event EventHandler<JobInfo> OutStoreEvent;
public StoreStatus storeStatus { public StoreStatus storeStatus
{
get => _storeStatus; get => _storeStatus;
set { set
if (_storeStatus!= value) {
if (_storeStatus != value)
VLog.Info($"set storeStatus to {value}"); VLog.Info($"set storeStatus to {value}");
_storeStatus = value; _storeStatus = value;
} }
...@@ -34,15 +33,16 @@ namespace DeviceLibrary ...@@ -34,15 +33,16 @@ namespace DeviceLibrary
static string server = Setting_Init.Device_Server_Address; static string server = Setting_Init.Device_Server_Address;
string CID;//= Setting_Init.Device_CID; string CID;//= Setting_Init.Device_CID;
int StoreID = 1; int StoreID = 1;
string StoreName=""; string StoreName = "";
string WarnMsg = ""; string WarnMsg = "";
System.Timers.Timer serverConnectTimer = new System.Timers.Timer(); System.Timers.Timer serverConnectTimer = new System.Timers.Timer();
VLog VLog; VLog VLog;
object serverclock = new object(); object serverclock = new object();
public VServerComm(string cid , VLog vLog) { public VServerComm(string cid, VLog vLog)
{
VLog = vLog; VLog = vLog;
CID = cid; CID = cid;
serverConnectTimer.Interval = 1000; serverConnectTimer.Interval = 1000;
...@@ -61,14 +61,14 @@ namespace DeviceLibrary ...@@ -61,14 +61,14 @@ namespace DeviceLibrary
binding.AllowCookies = false; binding.AllowCookies = false;
Uri baseAddress = new Uri(Setting_Init.Device_StoreServerURL); Uri baseAddress = new Uri(Setting_Init.Device_StoreServerURL);
EndpointAddress endpointAddress = new EndpointAddress(baseAddress.ToString()); EndpointAddress endpointAddress = new EndpointAddress(baseAddress.ToString());
towerAppWSClient = new MydataWcfServiceTest.ServiceReference2.TowerAppWSClient(binding, endpointAddress); towerAppWSClient = new MydataWcfServiceTest.ServiceReference3.WSInterfaceClient(binding, endpointAddress);
} }
private void ServerConnectTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) private void ServerConnectTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{ {
try try
{ {
if (RobotManage.isRunning && storeStatus >0) if (RobotManage.isRunning && storeStatus > 0)
{ {
//ProcessMsg(VMsg.msg); //ProcessMsg(VMsg.msg);
SendLineStatus(); SendLineStatus();
...@@ -78,7 +78,8 @@ namespace DeviceLibrary ...@@ -78,7 +78,8 @@ namespace DeviceLibrary
{ {
VLog.Error($"ServerConnectTimer_Elapsed:{ex}"); VLog.Error($"ServerConnectTimer_Elapsed:{ex}");
} }
finally { finally
{
//Monitor.Exit(serverConnectTimer); //Monitor.Exit(serverConnectTimer);
} }
} }
...@@ -132,7 +133,7 @@ namespace DeviceLibrary ...@@ -132,7 +133,7 @@ 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, 5000,out string log); Operation resultOperation = HttpHelper.Post(GetPostApi(), operation, 5000, out string log);
if (resultOperation == null) if (resultOperation == null)
{ {
...@@ -150,7 +151,7 @@ namespace DeviceLibrary ...@@ -150,7 +151,7 @@ namespace DeviceLibrary
} }
return true; return true;
} }
/// <summary> /// <summary>
/// 获取整个料仓的状态 /// 获取整个料仓的状态
/// </summary> /// </summary>
...@@ -198,8 +199,9 @@ namespace DeviceLibrary ...@@ -198,8 +199,9 @@ namespace DeviceLibrary
{ {
sendmsg = string.Join(",", new string[] { WarnMsg }); sendmsg = string.Join(",", new string[] { WarnMsg });
} }
else if (!RobotManage.isRunning){ else if (!RobotManage.isRunning)
sendmsg = crc.GetString("Res0155","设备未启动"); {
sendmsg = crc.GetString("Res0155", "设备未启动");
} }
lineOperation.msg = sendmsg; lineOperation.msg = sendmsg;
...@@ -250,13 +252,14 @@ namespace DeviceLibrary ...@@ -250,13 +252,14 @@ namespace DeviceLibrary
} }
} }
if (lineOperation.status != laststatus) { if (lineOperation.status != laststatus)
{
laststatus = lineOperation.status; laststatus = lineOperation.status;
printlog = true; printlog = true;
} }
Operation resultOperation = HttpHelper.Post(GetPostApi(), lineOperation,700, out string log); Operation resultOperation = HttpHelper.Post(GetPostApi(), lineOperation, 700, out string log);
if (resultOperation != null) if (resultOperation != null)
getthtime = 0; getthtime = 0;
//LogUtil.info(JsonHelper.SerializeObject(resultOperation.data)); //LogUtil.info(JsonHelper.SerializeObject(resultOperation.data));
...@@ -268,7 +271,7 @@ namespace DeviceLibrary ...@@ -268,7 +271,7 @@ namespace DeviceLibrary
} }
} }
} }
public int queueTaskCount=-1; public int queueTaskCount = -1;
ConcurrentQueue<string> commandResultMsg = new ConcurrentQueue<string>(); ConcurrentQueue<string> commandResultMsg = new ConcurrentQueue<string>();
void ResultProcess(Operation resultOperation) void ResultProcess(Operation resultOperation)
{ {
...@@ -337,7 +340,7 @@ namespace DeviceLibrary ...@@ -337,7 +340,7 @@ namespace DeviceLibrary
{ {
//出入库没有找到服务器发送的库位,需要打印日志方便查询原因 //出入库没有找到服务器发送的库位,需要打印日志方便查询原因
//SetWarnMsg(ResourceControl.InStoreNoPosition, message, posId); //SetWarnMsg(ResourceControl.InStoreNoPosition, message, posId);
WarnMsg = crc.GetString("Res0049","入库未找到库位:") + posId;//0505 WarnMsg = crc.GetString("Res0049", "入库未找到库位:") + posId;//0505
VLog.Info("收到服务器入库命令:入库未找到库位:二维码【" + message + "】库位【" + posId + "】"); VLog.Info("收到服务器入库命令:入库未找到库位:二维码【" + message + "】库位【" + posId + "】");
return; return;
} }
...@@ -354,7 +357,7 @@ namespace DeviceLibrary ...@@ -354,7 +357,7 @@ namespace DeviceLibrary
//} //}
//else //else
{ {
SendStoreState("","", StoreStatus.InStoreError); SendStoreState("", "", StoreStatus.InStoreError);
} }
} }
...@@ -377,13 +380,13 @@ namespace DeviceLibrary ...@@ -377,13 +380,13 @@ namespace DeviceLibrary
{ {
string maxHumidity = data[ParamDefine.maxHumidity]; string maxHumidity = data[ParamDefine.maxHumidity];
string maxTemp = data[ParamDefine.maxTemperature]; string maxTemp = data[ParamDefine.maxTemperature];
VLog.Info( "收到服务器温湿度预警值:maxHumidity=" + maxHumidity + ",maxTemperature=" + maxTemp); VLog.Info("收到服务器温湿度预警值:maxHumidity=" + maxHumidity + ",maxTemperature=" + maxTemp);
try try
{ {
this.Max_Humidity = (float)Convert.ToDouble(maxHumidity); this.Max_Humidity = (float)Convert.ToDouble(maxHumidity);
this.Max_Temperature = (float)Convert.ToDouble(maxTemp); this.Max_Temperature = (float)Convert.ToDouble(maxTemp);
VLog.Info( "保存温湿度预警值:Max_Humidity=" + Max_Humidity + ",Max_Temperature=" + Max_Temperature); VLog.Info("保存温湿度预警值:Max_Humidity=" + Max_Humidity + ",Max_Temperature=" + Max_Temperature);
} }
catch (Exception ex) catch (Exception ex)
{ {
...@@ -416,7 +419,7 @@ namespace DeviceLibrary ...@@ -416,7 +419,7 @@ namespace DeviceLibrary
int.TryParse(plateHStr, out int plateH); int.TryParse(plateHStr, out int plateH);
//根据发送的posId获取位置列表 //根据发送的posId获取位置列表
if (string.IsNullOrEmpty(code)) if (string.IsNullOrEmpty(code))
{ {
//WarnMsg = StoreName + "没有:【" + cid + "】"; //WarnMsg = StoreName + "没有:【" + cid + "】";
...@@ -435,7 +438,7 @@ namespace DeviceLibrary ...@@ -435,7 +438,7 @@ namespace DeviceLibrary
JobInfo jobInfo = new JobInfo(code, posIdStr, plateW, plateH); JobInfo jobInfo = new JobInfo(code, posIdStr, plateW, plateH);
jobInfo.isNG = ngReel; jobInfo.isNG = ngReel;
jobInfo.NgMsg = ngMsg; jobInfo.NgMsg = ngMsg;
OutStoreEvent?.Invoke(crc.GetString("Res0064","服务器"), jobInfo); OutStoreEvent?.Invoke(crc.GetString("Res0064", "服务器"), jobInfo);
} }
TimeSpan span = DateTime.Now - time; TimeSpan span = DateTime.Now - time;
...@@ -572,10 +575,16 @@ namespace DeviceLibrary ...@@ -572,10 +575,16 @@ namespace DeviceLibrary
vLog.Error(data); vLog.Error(data);
return false; return false;
} }
vLog.Info("出库指令发送成功");
return true; return true;
} }
public bool BeginInStore(string towerid, JobInfo jobInfo) public bool BeginInStore(string towerid, JobInfo jobInfo)
{ {
if (!NewOrUpdateCarrier(towerid, jobInfo))
{
VLog.Error("更新Carrier失败");
return false;
}
if (!SendCommand(VCmd.SimulateStartButton, true, out string data, towerid, jobInfo.WareNum)) if (!SendCommand(VCmd.SimulateStartButton, true, out string data, towerid, jobInfo.WareNum))
{ {
VLog.Error(data); VLog.Error(data);
...@@ -589,8 +598,44 @@ namespace DeviceLibrary ...@@ -589,8 +598,44 @@ namespace DeviceLibrary
} }
return true; return true;
} }
public bool NewOrUpdateCarrier(string towerid, JobInfo jobInfo)
{
string[] substrings = jobInfo.WareNum.Split('#');
if (substrings.Length < 3)
{
VLog.Error($"条码格式不正确:{jobInfo.WareNum}");
return false;
}
string RI = substrings[1].Substring(1);
string PN = substrings[0].Substring(1);
string QTY = substrings[2];
if (!SendCommand(VCmd.NewCarrier, true, out string data, towerid, RI, PN, QTY))
{
VLog.Error(data);
return false;
}
var result = XmlCommandSerializer.DeserializeResult(data);
if (result.Errorcode != 0)
{
if (!SendCommand(VCmd.UpdateCarrier, true, out string data2, towerid, RI, PN, QTY))
{
VLog.Error(data);
VLog.Error(data2);
return false;
}
var result2 = XmlCommandSerializer.DeserializeResult(data2);
if (result2.Errorcode != 0)
{
VLog.Error(data);
VLog.Error(data2);
return false;
}
}
return true;
}
MydataWcfServiceTest.ServiceReference2.TowerAppWSClient towerAppWSClient; MydataWcfServiceTest.ServiceReference3.WSInterfaceClient towerAppWSClient;
/// <summary> /// <summary>
/// 存储MyCronic料仓的剩余容量 7X8=1000;7X12=345;13X32=100; /// 存储MyCronic料仓的剩余容量 7X8=1000;7X12=345;13X32=100;
/// </summary> /// </summary>
...@@ -634,7 +679,7 @@ namespace DeviceLibrary ...@@ -634,7 +679,7 @@ namespace DeviceLibrary
{ {
errmsg = "Failed to send request." + command + ex; errmsg = "Failed to send request." + command + ex;
msg = errmsg; msg = errmsg;
communicationError= true; communicationError = true;
return false; return false;
} }
} }
...@@ -676,5 +721,5 @@ namespace DeviceLibrary ...@@ -676,5 +721,5 @@ namespace DeviceLibrary
} }
return XmlCommandSerializer.DeserializeTowerDetailInformation(result.Data); return XmlCommandSerializer.DeserializeTowerDetailInformation(result.Data);
} }
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -139,7 +139,7 @@ namespace DeviceLibrary ...@@ -139,7 +139,7 @@ namespace DeviceLibrary
InStoreJobInfo = null; InStoreJobInfo = null;
} }
} }
else if ((DateTime.Now - LastStatusTime).TotalSeconds > 30) else if ((DateTime.Now - LastStatusTime).TotalSeconds > 90)
{ {
if (InStoreJobInfo != null) if (InStoreJobInfo != null)
...@@ -191,7 +191,7 @@ namespace DeviceLibrary ...@@ -191,7 +191,7 @@ namespace DeviceLibrary
VLog.Info("料仓异常状态 TerminalError=true"); VLog.Info("料仓异常状态 TerminalError=true");
return; return;
} }
if ((DateTime.Now - LastStatusTime).TotalSeconds > 30) if ((DateTime.Now - LastStatusTime).TotalSeconds > 90)
{ {
RTStoreStatus = RTStoreStatus.InStoreDataTimeOut; RTStoreStatus = RTStoreStatus.InStoreDataTimeOut;
} }
......
...@@ -42,6 +42,7 @@ namespace DeviceLibrary ...@@ -42,6 +42,7 @@ namespace DeviceLibrary
VStore vStore = new VStore(s, this); VStore vStore = new VStore(s, this);
VStoreList[s.TowerID] = vStore; VStoreList[s.TowerID] = vStore;
}); });
UploadCarrierInformationData();
} }
private void Service_OnCommand(object sender, string xmlString) private void Service_OnCommand(object sender, string xmlString)
...@@ -219,7 +220,7 @@ namespace DeviceLibrary ...@@ -219,7 +220,7 @@ namespace DeviceLibrary
binding.ReceiveTimeout = TimeSpan.FromMinutes(10); binding.ReceiveTimeout = TimeSpan.FromMinutes(10);
Uri baseAddress = new Uri(Setting_Init.Device_StoreServerURL); Uri baseAddress = new Uri(Setting_Init.Device_StoreServerURL);
EndpointAddress endpointAddress = new EndpointAddress(baseAddress.ToString()); EndpointAddress endpointAddress = new EndpointAddress(baseAddress.ToString());
var towerAppWSClient = new MydataWcfServiceTest.ServiceReference2.TowerAppWSClient(binding, endpointAddress); var towerAppWSClient = new MydataWcfServiceTest.ServiceReference3.WSInterfaceClient(binding, endpointAddress);
VLog.Info("开始查询 CarrierList"); VLog.Info("开始查询 CarrierList");
var result = await towerAppWSClient.XmlActionAsync(VCmd.GetCarrierList); var result = await towerAppWSClient.XmlActionAsync(VCmd.GetCarrierList);
VLog.Info("结束查询 CarrierList"); VLog.Info("结束查询 CarrierList");
...@@ -233,46 +234,80 @@ namespace DeviceLibrary ...@@ -233,46 +234,80 @@ namespace DeviceLibrary
VLog.Error("GetCarrierList:" + ex.ToString()); VLog.Error("GetCarrierList:" + ex.ToString());
} }
} }
Dictionary<string, List<string>> SNList;
Dictionary<string, string> SNFullList;
public void UploadCarrierInformationData() public void UploadCarrierInformationData()
{ {
var cril = new List<CarrierInformationData>(); lock (this)
try
{ {
XmlDocument xml = new XmlDocument(); SNList = new Dictionary<string, List<string>>();
xml.Load("logs\\CarrierList.xml"); SNFullList = new Dictionary<string, string>();
var en = xml.SelectSingleNode("/XmlResult/Errorcode"); var cril = new List<CarrierInformationData>();
if (en.InnerText != "0") try
return;
var crl = xml.SelectNodes("/XmlResult/Data/CarrierInformation");
foreach (XmlNode cr in crl)
{ {
var ci = new CarrierInformationData(); XmlDocument xml = new XmlDocument();
var Depot = cr.SelectSingleNode("Depot"); xml.Load("logs\\CarrierList.xml");
if (Depot == null) var en = xml.SelectSingleNode("/XmlResult/Errorcode");
if (en.InnerText != "0")
return;
var crl = xml.SelectNodes("/XmlResult/Data/ArrayOfCarrierInformation/CarrierInformation");
foreach (XmlNode cr in crl)
{ {
continue; var ci = new CarrierInformationData();
} var Depot = cr.SelectSingleNode("Depot");
var carrier = cr.SelectSingleNode("Carrier").InnerText; if (Depot == null)
//var carriers = carrier.Split('#'); {
//if (carriers.Count()!=4) { continue;
// continue; }
//} var carrier = cr.SelectSingleNode("Carrier").InnerText;
ci.carrier = carrier;
//ci.partnumber = cr.SelectSingleNode("Carrier").InnerText; ci.carrier = AddToSNList(carrier);
ci.depot = cr.SelectSingleNode("Depot").InnerText; //ci.partnumber = cr.SelectSingleNode("Carrier").InnerText;
ci.depot = cr.SelectSingleNode("Depot").InnerText;
ci.ArticleName = cr.SelectSingleNode("ArticleName").InnerText;
ci.Stock = int.Parse(cr.SelectSingleNode("Stock").InnerText);
ci.diameter = int.Parse(cr.SelectSingleNode("Diameter").InnerText);
ci.height = int.Parse(cr.SelectSingleNode("Height").InnerText);
ci.diameter = int.Parse(cr.SelectSingleNode("Diameter").InnerText); SNFullList.Add(ci.carrier, $"P{ci.ArticleName}#S{ci.carrier}#{ci.Stock}#");
ci.height = int.Parse(cr.SelectSingleNode("Height").InnerText); cril.Add(ci);
cril.Add(ci); }
TheLine.UploadCarrierInformation(cril);
VLog.Info("上传库位信息:" + cril.Count);
}
catch (Exception ex)
{
VLog.Error("上传库位信息失败:" + ex);
} }
TheLine.UploadCarrierInformation(cril);
VLog.Info("上传库位信息:" + cril.Count);
} }
catch (Exception ex) }
public string GetSNFullString(string sn)
{
lock (this)
{
return SNFullList.ContainsKey(sn) ? SNFullList[sn] : sn;
}
}
string AddToSNList(string carrierstring)
{
var carrier = carrierstring;
var carriers = carrierstring.Split('#');
if (carriers.Count() >= 2)
{
carrier = carriers[1];
}
if (SNList.ContainsKey(carrier))
{
if (!SNList[carrier].Contains(carrierstring))
SNList[carrier].Add(carrierstring);
}
else
{ {
VLog.Error("上传库位信息失败:" + ex); SNList.Add(carrier, new List<string>() { carrierstring });
} }
return carrier;
} }
} }
} }
...@@ -84,10 +84,15 @@ namespace DeviceLibrary ...@@ -84,10 +84,15 @@ namespace DeviceLibrary
public void Stop() public void Stop()
{ {
robotHelper.Stop(); try
Robot.StopRobot(); {
DeviceState = DeviceStateE.Stop; DeviceState = DeviceStateE.Stop;
MoveInfo.log("停止运行"); robotHelper.Stop();
Robot?.StopRobot();
}
catch {
}
MoveInfo.log("停止运行");
} }
public void Process() public void Process()
{ {
......
...@@ -3,6 +3,7 @@ using Newtonsoft.Json; ...@@ -3,6 +3,7 @@ using Newtonsoft.Json;
using OnlineStore; using OnlineStore;
using OnlineStore.Common; using OnlineStore.Common;
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Diagnostics; using System.Diagnostics;
...@@ -375,6 +376,8 @@ namespace RemoteSheardObject ...@@ -375,6 +376,8 @@ namespace RemoteSheardObject
public string carrier; public string carrier;
public string partnumber; public string partnumber;
public string depot; public string depot;
public string ArticleName;
public int Stock;
public int diameter; public int diameter;
public int height; public int height;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!