Commit 5819f363 刘韬

优化入库超时

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