Commit 6a43eea1 几米阳光

AI模块BUG修改,增加出库缓存功能。

1 个父辈 8f4fffc6
......@@ -61,6 +61,9 @@
20190306修改
通电和待机白灯亮,出入库过程中绿灯亮,报警黄灯亮2秒灭掉后红灯亮
20190312修改
1.测高AI模块BUG修改。
2.出库增加缓存功能,若出库失败也放入缓存。
......
......@@ -241,83 +241,73 @@ namespace OnlineStore.DeviceLibrary
private void ReviceDataProcess()
{
int lengthIndex = 5;
byte[] rdata = Receive();
if (rdata != null)
if (rdata == null)
{
string str = "";
foreach (byte by in rdata)
{
str = str + " " + by;
//if (str.Length > 200)
//{
// break;
//}
}
//这里rdata就是接收到的数据,
IPEndPoint clientipe = (IPEndPoint)socketClient.RemoteEndPoint;
//ushort id = BitConverter.ToUInt16(rdata, 0);
//byte function = rdata[7];
byte dataLength = rdata[lengthIndex];
return;
}
string str = "";
foreach (byte by in rdata)
{
str = str + " " + by;
}
int allLength = lengthIndex + 1 + dataLength;
if (rdata.Length > allLength)
{
//LogUtil.info(clientipe.ToString() + "收到数据(需要分包):" + str);
int currStartIndex = 0;
for (int i = 0; i < 100; i++)
int lengthIndex = 5;
//这里rdata就是接收到的数据,
IPEndPoint clientipe = (IPEndPoint)socketClient.RemoteEndPoint;
byte dataLength = rdata[lengthIndex];
int allLength = lengthIndex + 1 + dataLength;
if (rdata.Length <= allLength)
{
LogUtil.debug(LOGGER, clientipe.ToString() + "收到数据(无需分包):" + str);
ushort id = BitConverter.ToUInt16(rdata, 0);
byte function = rdata[7];
DataProcess(clientipe.ToString(), id, function, rdata);
return;
}
int currStartIndex = 0;
try
{
for (int i = 0; i < 100; i++)
{
if (rdata.Length < currStartIndex + lengthIndex)
{
try
{
if (rdata.Length < currStartIndex + lengthIndex)
{
LogUtil.error(clientipe.ToString() + "收到数据:" + str + "分包出错 [" + currStartIndex + "]");
break;
}
else
{
dataLength = rdata[currStartIndex + lengthIndex];
allLength = lengthIndex + 1 + dataLength;
byte[] thisData = new byte[allLength];
Array.Copy(rdata, currStartIndex, thisData, 0, allLength);
ushort id = BitConverter.ToUInt16(thisData, 0);
byte function = thisData[7];
DataProcess(clientipe.ToString(), id, function, thisData);
//剩余的数据处理
LogUtil.error(clientipe.ToString() + "收到数据:" + str + "分包出错 [" + currStartIndex + "]");
break;
}
else
{
dataLength = rdata[currStartIndex + lengthIndex];
allLength = lengthIndex + 1 + dataLength;
byte[] thisData = new byte[allLength];
Array.Copy(rdata, currStartIndex, thisData, 0, allLength);
ushort id = BitConverter.ToUInt16(thisData, 0);
byte function = thisData[7];
DataProcess(clientipe.ToString(), id, function, thisData);
//剩余的数据处理
if (rdata.Length <= currStartIndex + allLength)
{
break;
}
currStartIndex = currStartIndex + allLength;
}
}
catch (Exception ex)
if (rdata.Length <= currStartIndex + allLength)
{
LogUtil.error(clientipe.ToString() + "收到数据:" + str + "分包出错 [" + currStartIndex + "]:" + ex.ToString());
break;
}
currStartIndex = currStartIndex + allLength;
}
}
else
{
LogUtil.debug(LOGGER, clientipe.ToString() + "收到数据(无需分包):" + str);
ushort id = BitConverter.ToUInt16(rdata, 0);
byte function = rdata[7];
DataProcess(clientipe.ToString(),id,function,rdata);
}
}
catch (Exception ex)
{
LogUtil.error(clientipe.ToString() + "收到数据:" + str + "分包出错 [" + currStartIndex + "]:" + ex.ToString());
}
}
private void DataProcess(string clientIp, ushort id, byte function, byte[] rdata)
{
byte[] data;
if ((function >= fctWriteSingleCoil) && (function != fctReadWriteMultipleRegister))
if (rdata.Length <= 9)
{
return;
}
if ((function >= fctWriteSingleCoil) && (function != fctReadWriteMultipleRegister) )
{
data = new byte[2];
Array.Copy(rdata, 10, data, 0, 2);
......@@ -431,15 +421,8 @@ namespace OnlineStore.DeviceLibrary
if ((socketClient != null) && (socketClient.Connected))
{
try
{
//发送的数据打印出来
string str = "";
foreach (byte by in write_data)
{
str = str + " " + by;
}
//LogUtil.info( clientipe.ToString()+"发送数据:" + str);
{
//LogUtil.info( clientipe.ToString()+"发送数据:" + AcSerialBean.byteToHexStr(write_data));
socketClient.BeginSend(write_data, 0, write_data.Length, SocketFlags.None, new AsyncCallback(OnSend), null);
//socketClient.BeginReceive(tcpSocketReviceBuffer, 0, tcpSocketReviceBuffer.Length, SocketFlags.None, new AsyncCallback(OnReceive), socketClient);
ReviceDataProcess();
......
......@@ -68,11 +68,11 @@ namespace OnlineStore.DeviceLibrary
MBmaster.OnException += new AITcpClient.ExceptionData(MBmaster_OnException);
MBmaster.autoConnectOfBreak = false;
mastMap.Add(ioIp, MBmaster);
LogUtil.info(LOGGER, "连接AI模块[" + ioIp + "]成功");
Thread.Sleep(10);
WriteAIScope(ioIp, 1);
Thread.Sleep(10);
ReadAll(ioIp);
LogUtil.info(LOGGER, "连接AI模块[" + ioIp + "]成功");
}
catch (Exception error)
{
......@@ -284,7 +284,7 @@ namespace OnlineStore.DeviceLibrary
}
try
{
if (StoreManager.Store.KNDIOValue(IO_Type.TrayCheck_Door).Equals(IO_VALUE.HIGH))
if (StoreManager.Store!=null&&StoreManager.Store.KNDIOValue(IO_Type.TrayCheck_Door).Equals(IO_VALUE.HIGH))
{
//每次上传后验证下
int v1 = (int)GetAIValue(ioIp, StoreManager.Config.AIDI1_Addr);
......
类型,说明,名称,属性值,设备名称,默认值,描述,电器定义,代码定义,SlaveID,
DI,急停,SuddenStop_BTN,200,192.168.200.31,0,急停,X01,DI-01,0,
DI,复位,Reset_BTN,201,192.168.200.31,0,复位,X02,DI-02,0,
DI,自动,AutoRun_Signal,202,192.168.200.31,0,自动,X03,DI-03,0,
DI,气压检测,Airpressure_Check,203,192.168.200.31,0,气压检测,X04,DI-04,0,
DI,料盘检测1(进料口),TrayCheck_Door,204,192.168.200.31,0,料盘检测1(进料口),X05,DI-05,0,
DI,料盘检测2(料叉),TrayCheck_Fixture,205,192.168.200.31,0,料盘检测2(料叉),X06,DI-06,0,
DI,进料口门上升端,Door_Up,206,192.168.200.31,0,进料口门上升端,X07,DI-07,0,
DI,进料口门下降端,Door_Down,207,192.168.200.31,0,进料口门下降端,X08,DI-08,0,
,,,208,192.168.200.31,0,,X09,DI-09,0,
,,,209,192.168.200.31,0,,X10,DI-10,0,
DI,前门限位,Door_LimitSingle,210,192.168.200.31,0,前门限位,X11,DI-11,0,
,,,211,192.168.200.31,0,,X12,DI-12,0,
DI,安全光栅,SafetyLightCurtains,212,192.168.200.31,0,安全光栅,X13,DI-13,0,
,,,213,192.168.200.31,0,,X14,DI-14,0,
,,,214,192.168.200.31,0,,X15,DI-15,0,
DI,压紧机构计量检测,CompressAxis_Check,215,192.168.200.31,0,压紧机构计量检测,X16,DI-16,0,
DO,自动指示灯,AutoRun_HddLed,100,192.168.200.31,0,自动指示灯,Y01,DO-01,0,
DO,故障指示灯,Alarm_HddLed,101,192.168.200.31,0,故障指示灯,Y02,DO-02,0,
DO,待机指示灯,RunSign_HddLed,102,192.168.200.31,0,待机指示灯,Y03,DO-03,0,
DO,吹气SOL ON,StartOrStopBlow,103,192.168.200.31,0,吹气SOL ON,Y04,DO-04,0,
DO,料仓运转ON,Run_Signal,104,192.168.200.31,0,料仓运转ON,Y05,DO-05,0,
DO,轴2刹车电源ON,Axis_Brake,105,192.168.200.31,0,轴2刹车电源ON,Y06,DO-06,0,
DO,进料口门上升SOL,Door_Up,106,192.168.200.31,0,进料口门上升SOL,Y07,DO-07,0,
DO,进料口门下降SOL,Door_Down,107,192.168.200.31,0,进料口门下降SOL,Y08,DO-08,0,
,,,108,192.168.200.31,0,,Y09,DO-09,0,
,,,109,192.168.200.31,0,,Y10,DO-10,0,
DO,相机照明开,CameraLight_Power,110,192.168.200.31,0,相机照明开,Y11,DO-11,0,
,,,111,192.168.200.31,0,,Y12,DO-12,0,
,,,112,192.168.200.31,0,,Y13,DO-13,0,
,,,113,192.168.200.31,0,,Y14,DO-14,0,
,,,114,192.168.200.31,0,,Y15,DO-15,0,
,,,115,192.168.200.31,0,,Y16,DO-16,0,
DI,急停,SuddenStop_BTN,200,192.168.200.11,0,急停,X01,DI-01,0,
DI,复位,Reset_BTN,201,192.168.200.11,0,复位,X02,DI-02,0,
DI,自动,AutoRun_Signal,202,192.168.200.11,0,自动,X03,DI-03,0,
DI,气压检测,Airpressure_Check,203,192.168.200.11,0,气压检测,X04,DI-04,0,
DI,料盘检测1(进料口),TrayCheck_Door,204,192.168.200.11,0,料盘检测1(进料口),X05,DI-05,0,
DI,料盘检测2(料叉),TrayCheck_Fixture,205,192.168.200.11,0,料盘检测2(料叉),X06,DI-06,0,
DI,进料口门上升端,Door_Up,206,192.168.200.11,0,进料口门上升端,X07,DI-07,0,
DI,进料口门下降端,Door_Down,207,192.168.200.11,0,进料口门下降端,X08,DI-08,0,
,,,208,192.168.200.11,0,,X09,DI-09,0,
,,,209,192.168.200.11,0,,X10,DI-10,0,
DI,前门限位,Door_LimitSingle,210,192.168.200.11,0,前门限位,X11,DI-11,0,
,,,211,192.168.200.11,0,,X12,DI-12,0,
DI,安全光栅,SafetyLightCurtains,212,192.168.200.11,0,安全光栅,X13,DI-13,0,
,,,213,192.168.200.11,0,,X14,DI-14,0,
,,,214,192.168.200.11,0,,X15,DI-15,0,
DI,压紧机构计量检测,CompressAxis_Check,215,192.168.200.11,0,压紧机构计量检测,X16,DI-16,0,
DO,自动指示灯,AutoRun_HddLed,100,192.168.200.11,0,自动指示灯,Y01,DO-01,0,
DO,故障指示灯,Alarm_HddLed,101,192.168.200.11,0,故障指示灯,Y02,DO-02,0,
DO,待机指示灯,RunSign_HddLed,102,192.168.200.11,0,待机指示灯,Y03,DO-03,0,
DO,吹气SOL ON,StartOrStopBlow,103,192.168.200.11,0,吹气SOL ON,Y04,DO-04,0,
DO,料仓运转ON,Run_Signal,104,192.168.200.11,0,料仓运转ON,Y05,DO-05,0,
DO,轴2刹车电源ON,Axis_Brake,105,192.168.200.11,0,轴2刹车电源ON,Y06,DO-06,0,
DO,进料口门上升SOL,Door_Up,106,192.168.200.11,0,进料口门上升SOL,Y07,DO-07,0,
DO,进料口门下降SOL,Door_Down,107,192.168.200.11,0,进料口门下降SOL,Y08,DO-08,0,
,,,108,192.168.200.11,0,,Y09,DO-09,0,
,,,109,192.168.200.11,0,,Y10,DO-10,0,
DO,相机照明开,CameraLight_Power,110,192.168.200.11,0,相机照明开,Y11,DO-11,0,
,,,111,192.168.200.11,0,,Y12,DO-12,0,
,,,112,192.168.200.11,0,,Y13,DO-13,0,
,,,113,192.168.200.11,0,,Y14,DO-14,0,
,,,114,192.168.200.11,0,,Y15,DO-15,0,
,,,115,192.168.200.11,0,,Y16,DO-16,0,
AXIS,(轴一)旋转轴,Middle_Axis,1,COM6,0,,,,,
AXIS,(轴二)升降轴轴,UpDown_Axis,1,COM5,0,,,,,
AXIS,(轴三)进出轴,InOut_Axis,1,COM4,0,,,,,
......@@ -117,7 +117,7 @@ PRO,硕科步进电机(压紧轴)控制减速度,CompressAxis_DelSpeed,3000,,,,,,,,
PRO,硕科步进电机(压紧轴)控制归零速度(原点返回速度),CompressAxis_HomeSpeed,5000,,,,,,,,
PRO,硕科步进电机轴地址(压紧轴),CompressAxis_Slv,1,,,,,,,,
,,,,,,,,, ,
PRO,模拟量IO模块的IP地址,AIDevice_IP,192.168.200.32,,,,,,,,
PRO,模拟量IO模块的IP地址,AIDevice_IP,192.168.200.12,,,,,,,,
PRO,模拟信号1默认高度,AIDI1_DefaultPosition,2920,,,,,,,,
PRO,模拟信号2默认高度,AIDI2_DefaultPosition,2960,,,,,,,,
PRO,模拟信号3默认高度,AIDI3_DefaultPosition,2500,,,,,,, ,
......
......@@ -1305,7 +1305,12 @@ namespace OnlineStore.DeviceLibrary
if (currInOutFixture.WareNum.Equals(""))
{
LogUtil.info(LOGGER, StoreName + "开始执行排队中的出库【" + currInOutFixture.ToStr() + "】");
StartOutStoreMove(new InOutStoreParam("", currInOutFixture.PosId, currInOutFixture.plateH, currInOutFixture.plateW));
bool result = StartOutStoreMove(new InOutStoreParam("", currInOutFixture.PosId, currInOutFixture.plateH, currInOutFixture.plateW));
if (!result)
{
LogUtil.info(LOGGER, StoreName + " 执行排队中的出库【" + currInOutFixture.ToStr() + "】失败,重新加入等待队列");
AddWaitOutInfo(currInOutFixture);
}
}
}
}
......@@ -1950,13 +1955,20 @@ namespace OnlineStore.DeviceLibrary
}
else
{
FixtureCodeInfo currInOutFixture = new FixtureCodeInfo(0, "", posId, plateW, plateH);
if (CanStarInOut())
{
StartOutStoreMove(new InOutStoreParam("", posId, position));
bool result= StartOutStoreMove(new InOutStoreParam("", posId, position));
if (!result)
{
LogUtil.info(LOGGER, StoreName + " 执行出库【" + currInOutFixture.ToStr() + "】失败,加入等待队列");
AddWaitOutInfo(currInOutFixture);
}
}
else
{
LogUtil.error(LOGGER, "收到服务器出库命令:出库【" + posId + "】失败,当前在忙碌中");
LogUtil.error(LOGGER, "执行出库【" + currInOutFixture.ToStr() + "】失败,当前在忙碌中,加入等待队列");
AddWaitOutInfo(currInOutFixture);
}
}
......
......@@ -534,7 +534,7 @@ namespace OnlineStore.DeviceLibrary
/// <summary>
/// 开始出库运动
/// </summary>
public override void StartOutStoreMove(InOutStoreParam param)
public override bool StartOutStoreMove(InOutStoreParam param)
{
startOutStoreTime = DateTime.Now;
string posId = param != null ? param.PositionNum : "";
......@@ -543,12 +543,12 @@ namespace OnlineStore.DeviceLibrary
if (!LoadParamPosition(param))
{
LogUtil.error(LOGGER, StoreName + " 启动出库【" + posId + "】出错,找不到库位信息");
return;
return false ;
}
if (KNDIOValue(IO_Type.TrayCheck_Fixture).Equals(IO_VALUE.HIGH))
{
LogUtil.error(LOGGER, StoreName + " 启动出库【" + posId + "】出错,叉子料盘检测有料");
return;
return false ;
}
storeStatus = StoreStatus.OutStoreExecute;
LogUtil.info(LOGGER, StoreName + "启动出库【" + posId + "】 ", storeMoveColor);
......@@ -569,11 +569,13 @@ namespace OnlineStore.DeviceLibrary
OutStoreLog("出库:SO_01 定位气缸下降");
LocationDownAndWait();
}
return true;
}
else
{
LogUtil.error(LOGGER, StoreName + " 启动出库出错,当前状态,storeStatus=" + storeRunStatus);
}
return false;
}
protected override void OutStoreProcess()
{
......
......@@ -89,7 +89,7 @@ namespace OnlineStore.DeviceLibrary
/// <summary>
/// 开始出库运动
/// </summary>
public abstract void StartOutStoreMove(InOutStoreParam param);
public abstract bool StartOutStoreMove(InOutStoreParam param);
protected abstract void OutStoreProcess();
#endregion
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!