Commit 5229fc72 张东亮

治具出入库更改

1 个父辈 7c97fdf2
正在显示 43 个修改的文件 包含 3164 行增加2819 行删除

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2024
# Visual Studio Version 17
VisualStudioVersion = 17.5.33414.496
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "source\Common\Common.csproj", "{43CDD09E-FCF3-4960-A01D-3BBFE9933122}"
EndProject
......@@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LoadCSVLibrary", "source\Lo
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ACPackingStore", "source\ACPackingStore\ACPackingStore.csproj", "{0D2542F5-DD62-4352-82D0-383D9A045E74}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConfigHelper", "..\..\..\CSharp-Workspace\MyProject\DLL\ConfigHelper\ConfigHelper\ConfigHelper.csproj", "{290182DB-D949-434E-9FF7-C59BDE3F433A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -39,6 +41,10 @@ Global
{0D2542F5-DD62-4352-82D0-383D9A045E74}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0D2542F5-DD62-4352-82D0-383D9A045E74}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0D2542F5-DD62-4352-82D0-383D9A045E74}.Release|Any CPU.Build.0 = Release|Any CPU
{290182DB-D949-434E-9FF7-C59BDE3F433A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{290182DB-D949-434E-9FF7-C59BDE3F433A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{290182DB-D949-434E-9FF7-C59BDE3F433A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{290182DB-D949-434E-9FF7-C59BDE3F433A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
......@@ -181,6 +181,10 @@
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\..\CSharp-Workspace\MyProject\DLL\ConfigHelper\ConfigHelper\ConfigHelper.csproj">
<Project>{290182DB-D949-434E-9FF7-C59BDE3F433A}</Project>
<Name>ConfigHelper</Name>
</ProjectReference>
<ProjectReference Include="..\Common\Common.csproj">
<Project>{43cdd09e-fcf3-4960-a01d-3bbfe9933122}</Project>
<Name>Common</Name>
......
......@@ -3,64 +3,6 @@
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
</configSections>
<appSettings>
<!--是否开机自动启动料仓-->
<add key="App_AutoRun" value="1" />
<add key="App_Title" value="包装料料仓" />
<!-- 开始吹气的判断值(配置值=服务器发送的湿度值-开始吹气值)-->
<add key="StartBlowValue" value="4" />
<!-- 停止吹气的判断值(配置值=服务器发送的湿度值-停止吹气值)-->
<add key="StopBlowValue" value="4" />
<!--Server address-->
<add key="http.server" value="http://10.85.160.25/myproject/" />
<!--storeType-->
<add key="store_count" value="2" />
<add key="Store_ConfigPath" value="\StoreConfig\StoreConfig.csv" />
<!--start one store config-->
<add key="Shelf_Position_Config" value="\StoreConfig\shelfPosition.csv" />
<add key="Store_Position_Config" value="\StoreConfig\linePositions.csv" />
<add key="BOX_ConfigPath" value="\StoreConfig\BoxConfig.csv" />
<add key="Store_Type" value="RC_AC_PA" />
<add key="Store_CID" value="packing-store" />
<add key="Store_CID_1" value="packing-19" />
<add key="Store_CID_2" value="packing-20" />
<!--end one store config-->
<add key="ACBaudRate" value="115200" />
<add key="InOutDefaultPosition" value="52000" />
<add key="Config_Pwd" value="123456" />
<!--二维码类型列表配置,用#分割,一维码=Barcode 二维码: QR Code#Data Matrix ECC 200#Micro QR Code-->
<add key="CodeType" value="QR Code#Data Matrix ECC 200" />
<!--二维码参数文件所在路径,文件名与二维码类型名一样-->
<add key="CodeParamPath" value="\CodeParam\" />
<!--出库等待料盘拿走的时间,秒-->
<add key="OutStoreWaitSeconds" value="1" />
<!--温控器类型,0=壁挂王字壳温湿度变送器,1=妙昕温湿度记录仪-->
<add key="HumitureControllerType" value="0" />
<add key="UseAIOBOX" value="1" />
<add key="DIMS" value="60" />
<add key="DOMS" value="300" />
<!--流水线地址和端口配置-->
<add key="LineServerIp" value="192.168.101.11" />
<add key="LineServerPort" value="5246" />
<!--是否调试状态-->
<add key="IsInDebug" value="1" />
<add key="UseBuzzer" value="0" />
<!--IO模块是否主动上传-->
<add key="AIOAutoUpload" value="0" />
<!--AGV调度服务器地址-->
<add key="AgvServerIp" value="10.85.160.20" />
<add key="CodeCount" value="3" />
<add key="Tool_P3_Offset" value="7000" />
<add key="Tool_P4_Offset" value="-2000" />
<add key="Tool_P5_Offset" value="-2000" />
<add key="Tool_P6_Offset" value="7000" />
<add key="Tool_TargetSpeed" value="20" />
<add key="Tool_TargetPosition" value="1835000" />
<!--是否启用入料口移门,1=启用,0=禁用-->
<add key="UseDoor" value="1" />
<add key="Agv_Log_Open" value="1" />
<add key="AutoShelfInstore" value="1" />
</appSettings>
<log4net>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="logs/Packing-store-19-20.log" />
......@@ -69,7 +11,7 @@
<rollingStyle value="Date" />
<datePattern value="yyyy-MM-dd" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t]%-5p %m%n" />
<conversionPattern value="[%d][%t]%-5p %m%n" />
</layout>
</appender>
<appender name="TheRFID" type="log4net.Appender.RollingFileAppender">
......@@ -79,7 +21,7 @@
<rollingStyle value="Date" />
<datePattern value="yyyy-MM-dd" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t]%-5p %m%n" />
<conversionPattern value="[%d][%t]%-5p %m%n" />
</layout>
</appender>
<logger name="RollingLogFileAppender">
......@@ -87,13 +29,9 @@
<appender-ref ref="RollingLogFileAppender" />
</logger>
<logger name="TheRFID">
<level value="Debug" />
<level value="info" />
<appender-ref ref="TheRFID" />
</logger>
<root>
<level value="Info" />
<appender-ref ref="RollingLogFileAppender" />
</root>
</log4net>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
......
......@@ -59,6 +59,7 @@
this.lblVersion.TabIndex = 276;
this.lblVersion.Text = "版本号:1.1.0000.0000";
this.lblVersion.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.lblVersion.Click += new System.EventHandler(this.lblVersion_Click);
//
// lblTime
//
......@@ -94,7 +95,7 @@
//
// FrmAbout
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(553, 222);
this.Controls.Add(this.btnCopy);
......
......@@ -37,5 +37,10 @@ namespace OnlineStore.ACPackingStore
{
Clipboard.SetDataObject(GetCodeNum(), true);
}
private void lblVersion_Click(object sender, EventArgs e)
{
ConfigHelper.AdvanceConfigForm.ShowEditDialog(this);
}
}
}
......@@ -61,7 +61,7 @@ namespace OnlineStore.ACPackingStore
/// </summary>
private bool InOutIsIsP1()
{
int InOutDefaultPosition = ConfigAppSettings.GetIntValue(Setting_Init.InOutDefaultPosition);
int InOutDefaultPosition = Setting_Init.InOutDefaultPosition;
//if (InOutDefaultPosition > 3000 || InOutDefaultPosition.Equals(0))
//{
// InOutDefaultPosition = 3000;
......
......@@ -383,7 +383,7 @@ namespace OnlineStore.ACPackingStore
//位置配置
string appPath = Application.StartupPath;
//如果总配置文件存在,保存到总的配置文件
string positionConfigFile = appPath + ConfigAppSettings.GetValue(Setting_Init.Store_Position_Config);
string positionConfigFile = appPath + Setting_Init.Store_Position_Config;
if (!File.Exists(positionConfigFile))
{
string nameStr = BoxBean.DeviceID.ToString();
......@@ -476,7 +476,7 @@ namespace OnlineStore.ACPackingStore
/// </summary>
private bool InOutIsIsP1()
{
int InOutDefaultPosition = ConfigAppSettings.GetIntValue(Setting_Init.InOutDefaultPosition);
int InOutDefaultPosition = Setting_Init.InOutDefaultPosition;
int currValue = ACServerManager.GetActualtPosition(BoxBean.Config.InOut_Axis.DeviceName, BoxBean.Config.InOut_Axis.GetAxisValue());
if (currValue <= InOutDefaultPosition)
{
......@@ -869,7 +869,7 @@ namespace OnlineStore.ACPackingStore
pso.UpDownAxis_HP102 = FormUtil.GetIntValue(txtUpdownP102);
}
//位置配置
string positionConfigFile = Application.StartupPath + ConfigAppSettings.GetValue(Setting_Init.Shelf_Position_Config);
string positionConfigFile = Application.StartupPath + Setting_Init.Shelf_Position_Config;
if (!File.Exists(positionConfigFile))
{
string nameStr = BoxBean.DeviceID.ToString();
......@@ -970,10 +970,10 @@ namespace OnlineStore.ACPackingStore
private void btnSaveCID_Click(object sender, EventArgs e)
{
string cid = txtCID.Text.Trim();
DialogResult result = MessageBox.Show("确定将CID修改为【" + cid + "】,修改后需要重启生效", "", MessageBoxButtons.YesNo);
DialogResult result = MessageBox.Show("确定将CID修改为【" + cid + "】", "", MessageBoxButtons.YesNo);
if (result.Equals(DialogResult.Yes))
{
ConfigAppSettings.SaveValue(Setting_Init.Store_CID + "_" + BoxBean.DeviceID, cid);
ConfigAppSettings.SaveValue("Store_CID" + "_" + BoxBean.DeviceID, cid);
}
}
......@@ -1019,7 +1019,7 @@ namespace OnlineStore.ACPackingStore
{
string appPath = Application.StartupPath;
//如果总配置文件存在,保存到总的配置文件
string positionConfigFile = appPath + ConfigAppSettings.GetValue(Setting_Init.Store_Position_Config);
string positionConfigFile = appPath + Setting_Init.Store_Position_Config;
if (!File.Exists(positionConfigFile))
{
string nameStr = BoxBean.DeviceID.ToString();
......
......@@ -31,11 +31,11 @@ namespace OnlineStore.ACPackingStore
private void btnNext_Click(object sender, EventArgs e)
{
string pwd = txtPwd.Text;
string configPwd = ConfigAppSettings.GetValue(Setting_Init.Config_Pwd);
string configPwd = Setting_Init.Config_Pwd;
if (configPwd.Equals(""))
{
configPwd = "123456";
ConfigAppSettings.SaveValue(Setting_Init.Config_Pwd,configPwd);
Setting_Init.Config_Pwd=configPwd;
}
if (pwd.Equals(configPwd))
{
......
......@@ -57,9 +57,9 @@ namespace OnlineStore.ACPackingStore
chbAutoRun.Checked = store.UseBuzzer;
chbAutoShelfInstore.Checked = store.AutoShelfInstore;
this.Text = ConfigAppSettings.GetValue(Setting_Init.App_Title);
chbAutoRun.Checked =( ConfigAppSettings.GetIntValue(Setting_Init.App_AutoRun).Equals(1));
chbDoorCanMove.Checked =( ConfigAppSettings.GetIntValue(Setting_Init.UseDoor).Equals(1));
this.Text = Setting_Init.App_Title;
chbAutoRun.Checked = Setting_Init.App_AutoRun;
chbDoorCanMove.Checked = Setting_Init.UseDoor;
// LogUtil.logBox = this.logBox;
// HideForm();
LoadOk = true;
......@@ -182,16 +182,16 @@ namespace OnlineStore.ACPackingStore
//如果料仓还在运行状态,先关闭料仓
if (!store.storeRunStatus.Equals(StoreRunStatus.Wait))
{
LogUtil.info( "ExitApp 停止"+store.Name+"运行 ");
LogUtil.info("ExitApp 停止" + store.Name + "运行 ");
store.StopRun();
}
else
{
foreach(AC_BOX_Bean bean in store.BoxMap.Values)
foreach (AC_BOX_Bean bean in store.BoxMap.Values)
{
if (bean.storeRunStatus.Equals(StoreRunStatus.Wait).Equals(false))
{
LogUtil.info( "ExitApp 停止" + bean.Name + "运行 ");
LogUtil.info("ExitApp 停止" + bean.Name + "运行 ");
bean.StopRun();
}
}
......@@ -245,7 +245,7 @@ namespace OnlineStore.ACPackingStore
MessageBox.Show(store.Name + "当前状态:" + store.storeRunStatus + ",不能启动!");
return;
}
LogUtil.info( "开始启动");
LogUtil.info("开始启动");
startTimer.Interval = 300;
startTimer.Elapsed += timer_Elapsed;
startTimer.AutoReset = false;
......@@ -373,8 +373,8 @@ namespace OnlineStore.ACPackingStore
{
sbResult.AppendFormat(DateTime.Now.ToLongTimeString() + ", 名称:{0} 内存大小:{1}M ", process.ProcessName, process.PrivateMemorySize64 / 1024 / 1024F);
totalMemery += process.PrivateMemorySize64 / 1024;
double value = (process.TotalProcessorTime - prevCpuTime).TotalMilliseconds / interval / Environment.ProcessorCount ;
sbResult.AppendFormat(" CPU : " +Math.Round(value,2) + "%");
double value = (process.TotalProcessorTime - prevCpuTime).TotalMilliseconds / interval / Environment.ProcessorCount;
sbResult.AppendFormat(" CPU : " + Math.Round(value, 2) + "%");
// string result = string.Format("进程总数 {0} 个,共占内存:{1}MB \n", processes.Length, totalMemery / 1024) + sbResult.ToString();
LogUtil.info(sbResult.ToString());
}
......@@ -384,7 +384,7 @@ namespace OnlineStore.ACPackingStore
}
catch (Exception ex)
{
LogUtil.error("LogM Error: "+ex.ToString());
LogUtil.error("LogM Error: " + ex.ToString());
}
}
private void timer1_Tick(object sender, EventArgs e)
......@@ -396,12 +396,12 @@ namespace OnlineStore.ACPackingStore
lblServerMsg.Text = HttpHelper.LastServerMsg;
ReadIOList();
string msg = "";
foreach(AC_BOX_Bean box in StoreManager.Store.BoxMap.Values)
foreach (AC_BOX_Bean box in StoreManager.Store.BoxMap.Values)
{
string s = box.GetWarnMsg();
if (!s.Equals(""))
{
msg += box.Name+":"+s+ "\r" ;
msg += box.Name + ":" + s + "\r";
}
}
if (!chbAGV.Checked.Equals(AgvClient.CurrCancelState))
......@@ -410,7 +410,7 @@ namespace OnlineStore.ACPackingStore
}
if (!chbAutoShelfInstore.Checked.Equals(store.AutoShelfInstore))
{
chbAutoShelfInstore.Checked=store.AutoShelfInstore;
chbAutoShelfInstore.Checked = store.AutoShelfInstore;
}
label1.Text = "agvClient.CancelState=" + AgvClient.getState();
lblWarnMsg.Text = msg;
......@@ -425,12 +425,12 @@ namespace OnlineStore.ACPackingStore
}
if (chbAutoRun.Checked)
{
ConfigAppSettings.SaveValue(Setting_Init.App_AutoRun, 1);
Setting_Init.App_AutoRun = true;
ManagerUtil.AutoRun(Application.ExecutablePath, true);
}
else
{
ConfigAppSettings.SaveValue(Setting_Init.App_AutoRun, 0);
Setting_Init.App_AutoRun = false;
ManagerUtil.AutoRun(Application.ExecutablePath, false);
}
}
......@@ -489,9 +489,9 @@ namespace OnlineStore.ACPackingStore
private void toolStripMenuItem2_Click(object sender, EventArgs e)
{
if (toolStripMenuItem2.Text .Equals("启用调试"))
if (toolStripMenuItem2.Text.Equals("启用调试"))
{
DebugOpen(true );
DebugOpen(true);
}
else
{
......@@ -544,14 +544,14 @@ namespace OnlineStore.ACPackingStore
if (chbUseBuzzer.Checked)
{
store.UseBuzzer = true;
ConfigAppSettings.SaveValue(Setting_Init.UseBuzzer, 1);
Setting_Init.UseBuzzer = store.UseBuzzer;
LogUtil.info("勾选:启用蜂鸣器");
}
else
{
store.UseBuzzer = false;
ConfigAppSettings.SaveValue(Setting_Init.UseBuzzer, 0);
Setting_Init.UseBuzzer = store.UseBuzzer;
LogUtil.info("去掉:启用蜂鸣器");
}
}
......@@ -581,14 +581,14 @@ namespace OnlineStore.ACPackingStore
if (chbAutoShelfInstore.Checked)
{
store.AutoShelfInstore = true;
ConfigAppSettings.SaveValue(Setting_Init.AutoShelfInstore, 1);
Setting_Init.AutoShelfInstore = store.AutoShelfInstore;
LogUtil.info("勾选:检测到料架自动入库");
}
else
{
store.AutoShelfInstore = false;
ConfigAppSettings.SaveValue(Setting_Init.AutoShelfInstore, 0);
Setting_Init.AutoShelfInstore = store.AutoShelfInstore;
LogUtil.info("去掉:检测到料架自动入库");
}
}
......@@ -620,14 +620,14 @@ namespace OnlineStore.ACPackingStore
if (chbDoorCanMove.Checked)
{
// store.AutoShelfInstore = true;
ConfigAppSettings.SaveValue(Setting_Init.UseDoor, 1);
Setting_Init.UseDoor = true;
LogUtil.info("勾选:启用入料口移门");
}
else
{
// store.AutoShelfInstore = false;
ConfigAppSettings.SaveValue(Setting_Init.UseDoor, 0);
Setting_Init.UseDoor = false;
LogUtil.info("去掉:启用入料口移门");
}
}
......
......@@ -9,6 +9,8 @@ using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Windows.Forms;
using OnlineStore.DeviceLibrary;
using log4net.Repository.Hierarchy;
namespace OnlineStore.ACPackingStore
{
......@@ -59,9 +61,8 @@ namespace OnlineStore.ACPackingStore
// 因为方法三只能是最小化的窗体显示出来,如果隐藏到托盘中则不能把运行的程序显示出来
Process currentproc = Process.GetCurrentProcess();
Process[] processcollection = Process.GetProcessesByName(currentproc.ProcessName.Replace(".vshost", string.Empty));
bool isShow=false;
// 该程序已经运行,
bool isShow = false;
if (processcollection.Length >= 1)
{
foreach (Process process in processcollection)
......@@ -71,7 +72,7 @@ namespace OnlineStore.ACPackingStore
// 如果进程的句柄为0,即代表没有找到该窗体,即该窗体隐藏的情况时
if (process.MainWindowHandle.ToInt32().Equals(0))
{
string formTitle = ConfigAppSettings.GetValue(Setting_Init.App_Title);
string formTitle = Setting_Init.App_Title;
// 获得窗体句柄
formhwnd = FindWindow(null, formTitle);
// 重新显示该窗体并切换到带入到前台
......@@ -94,6 +95,7 @@ namespace OnlineStore.ACPackingStore
if (!isShow)
{
System.Net.ServicePointManager.DefaultConnectionLimit = 512;
Setting_Init.Init();
XmlConfigurator.Configure();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
......
......@@ -66,12 +66,12 @@ namespace OnlineStore.ACPackingStore
IOManager.instance.ConnectionIOList(new List<string> { /*IoIp*/ });
}
P3Offset = ConfigAppSettings.GetIntValue(Setting_Init.Tool_P3_Offset);
P4Offset = ConfigAppSettings.GetIntValue(Setting_Init.Tool_P4_Offset);
P5Offset = ConfigAppSettings.GetIntValue(Setting_Init.Tool_P5_Offset);
P6Offset = ConfigAppSettings.GetIntValue(Setting_Init.Tool_P6_Offset);
int tSpeed = ConfigAppSettings.GetIntValue(Setting_Init.Tool_TargetSpeed);
int tPosition = ConfigAppSettings.GetIntValue(Setting_Init.Tool_TargetPosition);
P3Offset = Setting_Init.Tool_P3_Offset;
P4Offset = Setting_Init.Tool_P4_Offset;
P5Offset = Setting_Init.Tool_P5_Offset;
P6Offset = Setting_Init.Tool_P6_Offset;
int tSpeed = Setting_Init.Tool_TargetSpeed;
int tPosition = Setting_Init.Tool_TargetPosition;
if (P3Offset.Equals(0)) P3Offset = 6000;
if (P4Offset.Equals(0)) P4Offset = -6000;
......@@ -197,12 +197,12 @@ namespace OnlineStore.ACPackingStore
private void SaveConfig(int speed, int position)
{
//保存配置
ConfigAppSettings.SaveValue(Setting_Init.Tool_P3_Offset, P3Offset);
ConfigAppSettings.SaveValue(Setting_Init.Tool_P4_Offset, P4Offset);
ConfigAppSettings.SaveValue(Setting_Init.Tool_P5_Offset, P5Offset);
ConfigAppSettings.SaveValue(Setting_Init.Tool_P6_Offset, P6Offset);
ConfigAppSettings.SaveValue(Setting_Init.Tool_TargetSpeed, speed);
ConfigAppSettings.SaveValue(Setting_Init.Tool_TargetPosition, position);
Setting_Init.Tool_P3_Offset= P3Offset;
Setting_Init.Tool_P4_Offset=P4Offset;
Setting_Init.Tool_P5_Offset=P5Offset;
Setting_Init.Tool_P6_Offset=P6Offset;
Setting_Init.Tool_TargetSpeed=speed;
Setting_Init.Tool_TargetPosition= position;
}
private void btnAbsMove_Click(object sender, EventArgs e)
{
......
......@@ -66,7 +66,7 @@ namespace OnlineStore.ACPackingStore
/// </summary>
private bool InOutIsIsP1()
{
int InOutDefaultPosition = ConfigAppSettings.GetIntValue(Setting_Init.InOutDefaultPosition);
int InOutDefaultPosition = Setting_Init.InOutDefaultPosition;
int currValue = ACServerManager.GetActualtPosition(BoxBean.Config.InOut_Axis.DeviceName, BoxBean.Config.InOut_Axis.GetAxisValue());
if (currValue <= InOutDefaultPosition)
{
......
......@@ -74,6 +74,12 @@
<ItemGroup>
<WCFMetadata Include="Service References\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\..\CSharp-Workspace\MyProject\DLL\ConfigHelper\ConfigHelper\ConfigHelper.csproj">
<Project>{290182db-d949-434e-9ff7-c59bde3f433a}</Project>
<Name>ConfigHelper</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ConfigHelper;
namespace OnlineStore.Common
......@@ -11,97 +8,92 @@ namespace OnlineStore.Common
/// </summary>
public class Setting_Init
{
public static string Agv_Log_Open = "Agv_Log_Open";
public static string Server_Log_Open = "Server_Log_Open";
/// <summary>
/// 系统启动时自动启动料仓,=1时自动启动,并隐藏窗口,=0时不需要
/// </summary>
public static string App_AutoRun = "App_AutoRun";
/// <summary>
/// 系统主界面标题
/// </summary>
public static string App_Title = "App_Title";
public static string http_server = "http.server";
public static string Store_CID = "Store_CID";
/// <summary>
/// 料仓数量
/// </summary>
public static string store_count = "store_count";
/// <summary>
/// 料仓类型,1=在线料仓
/// </summary>
public static string Store_Type = "Store_Type";
public static string BOX_ConfigPath = "BOX_ConfigPath";
public static string Store_Position_Config = "Store_Position_Config";
/// <summary>
/// 摄像机名称,多个中间使用#分割
/// </summary>
public static string CameraName = "CameraName";
/// <summary>
/// 需要识别的二维码类型,多个中间使用#分割
/// </summary>
public static string CodeType = "CodeType";
/// <summary>
/// 开始吹气的判断值(配置值=服务器发送的湿度值-开始吹气值)
/// </summary>
public static string StartBlowValue = "StartBlowValue";
/// <summary>
/// 停止吹气的判断值(配置值=服务器发送的湿度值-停止吹气值)
/// </summary>
public static string StopBlowValue = "StopBlowValue";
/// <summary>
/// 配置文件路径 Data Matrix ECC 200.dcm
/// </summary>
public static string CodeParamPath = "CodeParamPath";
/// <summary>
/// 进出轴最大待机点,需要小于3000
/// </summary>
public static string InOutDefaultPosition = "InOutDefaultPosition";
public static string Config_Pwd = "Config_Pwd";
/// <summary>
/// 出库等待料盘拿走的时间,秒
/// </summary>
public static string OutStoreWaitSeconds = "OutStoreWaitSeconds";
/// <summary>
/// 温控器类型,0=壁挂王字壳温湿度变送器,1=妙昕温湿度记录仪
/// </summary>
public static string HumitureControllerType = "HumitureControllerType";
public static string UseAIOBOX = "UseAIOBOX";
public static string LineServerIp = "LineServerIp";
public static string LineServerPort = "LineServerPort";
public static string ACBaudRate = "ACBaudRate";
public static string Store_ConfigPath = "Store_ConfigPath";
public static string UseBuzzer = "UseBuzzer";
public static string Shelf_Position_Config = "Shelf_Position_Config";
public static string Tool_P3_Offset = "Tool_P3_Offset";
public static string Tool_P4_Offset = "Tool_P4_Offset";
public static string Tool_P5_Offset = "Tool_P5_Offset";
public static string Tool_P6_Offset = "Tool_P6_Offset";
public static string Tool_TargetSpeed = "Tool_TargetSpeed";
public static string Tool_TargetPosition = "Tool_TargetPosition";
public static string AgvServerIp = "AgvServerIp";
public static string CodeCount = "CodeCount";
public static string AutoShelfInstore = "AutoShelfInstore";
public static string UseDoor = "UseDoor";
public static void Init()
{
ConfigHelper.Config.MyConfig = typeof(Setting_Init);
}
[MyConfigComment("是否打开AGV日志")]
public static MyConfig<bool> Log_OpenAgv = true;
[MyConfigComment("是否打开AGV日志")]
public static MyConfig<bool> Log_OpenServer = true;
[MyConfigComment("系统启动时自动启动料仓,true时自动启动,并隐藏窗口;false时不需要")]
public static MyConfig<bool> App_AutoRun = true;
[MyConfigComment("系统主界面标题")]
public static MyConfig<string> App_Title = "包装料仓";
[MyConfigComment("料仓配置路径")]
public static MyConfig<string> BOX_ConfigPath = "\\StoreConfig\\BoxConfig.csv";
[MyConfigComment("料仓点位配置路径")]
public static MyConfig<string> Store_Position_Config = "\\StoreConfig\\linePositions.csv";
[MyConfigComment("服务器地址")]
public static MyConfig<string> http_server = "http://172.16.77.86/myproject/";
[MyConfigComment("料仓CID,每个仓唯一")]
public static MyConfig<string> Store_CID = "packing-store";
[MyConfigComment("软件上料仓数量")]
public static MyConfig<int> store_count = 2;
[MyConfigComment("料仓类型")]
public static MyConfig<string> Store_Type = "RC_AC_PA";
[MyConfigComment("摄像机名称,多个中间使用#分割")]
public static MyConfig<string> CameraName = "";
[MyConfigComment("需要识别的二维码类型,多个中间使用#分割")]
public static MyConfig<string> CodeType = "QR Code#Data Matrix ECC 200";
[MyConfigComment("是否开启吹气")]
public static MyConfig<bool> OpenBlow = false;
[MyConfigComment("开始吹气的判断值(配置值=服务器发送的湿度值-开始吹气值)")]
public static MyConfig<int> StartBlowValue = 4;
[MyConfigComment("停止吹气的判断值(配置值=服务器发送的湿度值-停止吹气值)")]
public static MyConfig<int> StopBlowValue = 4;
[MyConfigComment("二维码参数文件所在路径,文件名与二维码类型名一样")]
public static MyConfig<string> CodeParamPath = "\\CodeParam\\";
[MyConfigComment("进出轴最大待机点,需要小于3000")]
public static MyConfig<int> InOutDefaultPosition = 52000;
[MyConfigComment("配置的登录密码")]
public static MyConfig<string> Config_Pwd = "123456";
[MyConfigComment("出库等待料盘拿走的时间,秒")]
public static MyConfig<int> OutStoreWaitSeconds = 30;
[MyConfigComment("温控器类型,0=壁挂王字壳温湿度变送器,1=妙昕温湿度记录仪")]
public static MyConfig<int> HumitureControllerType = 0;
[MyConfigComment("是否使用零点IO模块")]
public static MyConfig<bool> UseAIOBOX = true;
[MyConfigComment("伺服通讯波特率")]
public static MyConfig<int> ACBaudRate = 115200;
[MyConfigComment("料仓配置文件路径")]
public static MyConfig<string> Store_ConfigPath = "\\StoreConfig\\StoreConfig.csv";
[MyConfigComment("是否使用蜂鸣器")]
public static MyConfig<bool> UseBuzzer = false;
[MyConfigComment("料架点位配置文件路径")]
public static MyConfig<string> Shelf_Position_Config = "\\StoreConfig\\shelfPosition.csv";
[MyConfigComment("")]
public static MyConfig<int> Tool_P3_Offset = 7000;
[MyConfigComment("")]
public static MyConfig<int> Tool_P4_Offset = -2000;
[MyConfigComment("")]
public static MyConfig<int> Tool_P5_Offset = -2000;
[MyConfigComment("")]
public static MyConfig<int> Tool_P6_Offset = 7000;
[MyConfigComment("")]
public static MyConfig<int> Tool_TargetSpeed = 20;
[MyConfigComment("")]
public static MyConfig<int> Tool_TargetPosition = 1835000;
[MyConfigComment("AGV调度服务器IP")]
public static MyConfig<string> AgvServerIp = "172.16.77.76";
[MyConfigComment("条码数量")]
public static MyConfig<int> CodeCount = 3;
[MyConfigComment("是否检测到料架自动入库")]
public static MyConfig<bool> AutoShelfInstore = true;
[MyConfigComment("是否启用入料口移门")]
public static MyConfig<bool> UseDoor = true;
}
}
......@@ -26,52 +26,18 @@ namespace OnlineStore.Common
Interlocked.Increment(ref seq);
return seq;
}
public static string GetValue(string key)
public static string GetValue(string key,string defaultVal="")
{
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
LogUtil.error("未找到配置:" + key + ",请检查配置是否完整!");
return "";
}
else
{
return config.AppSettings.Settings[key].Value;
}
return ConfigHelper.Config.Get(key, defaultVal);
}
public static decimal GetNumValue(string key)
{
decimal a = 0;
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
LogUtil.error("未找到配置:" + key + ",请检查配置是否完整!");
return a;
}
else
{
{
Decimal.TryParse(config.AppSettings.Settings[key].Value, out a);
}
}
return a;
}
public static int GetIntValue(string key)
{
int a = 0;
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
LogUtil.error("未找到配置:" + key + ",请检查配置是否完整!");
return a;
return ConfigHelper.Config.Get<decimal>(key);
}
else
public static int GetIntValue(string key,int val=0)
{
{
Int32.TryParse(config.AppSettings.Settings[key].Value, out a);
}
} return a;
return ConfigHelper.Config.Get<int>(key,val);
}
public static void SaveValue(string key, int value)
{
......@@ -79,81 +45,7 @@ namespace OnlineStore.Common
}
public static void SaveValue(string key, string value)
{
try
{
if (key.Equals("") || value.Equals(""))
{
return;
}
//增加的内容写在appSettings段下 <add key="RegCode" value="0"/>
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
SetValue(key, value);
}
else
{
UpdateConfig(key, value);
}
}
catch (Exception ex)
{
LogUtil.error( "SaveValue保存配置出错:AppKey=" + key + ",AppValue=" + value + "," + ex.StackTrace);
}
}
/// <summary>
/// 更新配置文件信息
/// </summary>
/// <param name="name">配置文件字段名称</param>
/// <param name="Xvalue">值</param>
private static void UpdateConfig(string name, string Xvalue)
{
try
{
XmlDocument doc = new XmlDocument();
doc.Load(Application.ExecutablePath + ".config");
XmlNode node = doc.SelectSingleNode(@"//add[@key='" + name + "']");
XmlElement ele = (XmlElement)node;
ele.SetAttribute("value", Xvalue);
doc.Save(Application.ExecutablePath + ".config");
}
catch (Exception ex)
{
LogUtil.error( "UpdateConfig保存配置出错:name=" + name + ",Xvalue=" + Xvalue + "," + ex.StackTrace);
}
}
///<summary>
///向.config文件的appKey结写入信息AppValue 保存设置
///</summary>
///<param name="AppKey">节点名</param>
///<param name="AppValue">值</param>
private static void SetValue(String AppKey, String AppValue)
{
try
{
XmlDocument xDoc = new XmlDocument();
xDoc.Load(System.Windows.Forms.Application.ExecutablePath + ".config");
XmlNode xNode;
XmlElement xElem1;
XmlElement xElem2;
xNode = xDoc.SelectSingleNode("//appSettings");
xElem1 = (XmlElement)xNode.SelectSingleNode("//add[@key='" + AppKey + "']");
if (xElem1 != null)
xElem1.SetAttribute("value", AppValue);
else
{
xElem2 = xDoc.CreateElement("add");
xElem2.SetAttribute("key", AppKey);
xElem2.SetAttribute("value", AppValue);
xNode.AppendChild(xElem2);
}
xDoc.Save(System.Windows.Forms.Application.ExecutablePath + ".config");
}
catch (Exception ex)
{
LogUtil.error( "SetValue保存配置出错:AppKey=" + AppKey + ",AppValue=" + AppValue + "," + ex.StackTrace);
}
ConfigHelper.Config.Set(key, value);
}
}
}
......@@ -120,12 +120,11 @@ namespace OnlineStore.Common
}
return null;
}
private static int isLog = ConfigAppSettings.GetIntValue(Setting_Init.Server_Log_Open);
public static string LastServerMsg = "";
private static string PostJson(string url, string paramData, Encoding encoding, out bool isTimeOut)
{
isTimeOut = false;
if (isLog == 1)
if (Setting_Init.Log_OpenServer)
{
LogUtil.info("给服务器发送数据【" + paramData + "】 ");
}
......@@ -156,7 +155,7 @@ namespace OnlineStore.Common
{
LogUtil.error("POST ERROR:" + ex.ToString(), 1);
}
if (isLog == 1)
if (Setting_Init.Log_OpenServer)
{
LogUtil.info("收到服务器数据【" + result + "】");
}
......@@ -186,7 +185,7 @@ namespace OnlineStore.Common
}
IsTimeOut = false;
if (isLog == 1)
if (Setting_Init.Log_OpenServer)
{
LogUtil.info("给服务器发送数据【" + url + "】【" + paramData + "】 ");
}
......@@ -216,7 +215,7 @@ namespace OnlineStore.Common
LogUtil.error("POST [" + url + "] ERROR:" + e.ToString(), 101);
}
if (isLog == 1)
if (Setting_Init.Log_OpenServer)
{
LogUtil.info("收到服务器数据【" + result + "】");
}
......
......@@ -24,7 +24,7 @@ namespace OnlineStore.Common
private static string LogName = "";
private static Dictionary<string, AcSerialBean> serialBeanMap = new Dictionary<string, AcSerialBean>();
public static int HumitureControllerType = ConfigAppSettings.GetIntValue(Setting_Init.HumitureControllerType);
public static int HumitureControllerType = Setting_Init.HumitureControllerType;
public static bool Init(string port)
{
if (serialBeanMap.ContainsKey(port))
......
using System;
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using log4net;
using System.Reflection;
using System.Drawing;
namespace OnlineStore.Common
{
public class LogUtil
{
public static readonly ILog AIOLog = LogManager.GetLogger("AIOBOXLog");
private static LogUtil instance = new LogUtil();
public delegate void ShowLog(string msg, Color color);
public static readonly ILog LOGGER = LogManager.GetLogger("RollingLogFileAppender");
......@@ -29,19 +23,7 @@ namespace OnlineStore.Common
log.Info(" - " + msg);
AddToBox(msg, Color.Black);
}
public static void info(ILog log, string msg, Color color)
{
log.Info(" - " + msg);
AddToBox(msg, color);
}
public static void debug(ILog log, string msg, Color color)
{
log.Debug(" - " + msg);
if (debug_opened)
{
AddToBox(msg, color);
}
}
public static void debug(ILog log, string msg)
{
log.Debug(" - " + msg);
......@@ -125,8 +107,10 @@ namespace OnlineStore.Common
LastText = text;
if (logBox.Visible)
{
logBox.Invoke(new Action(() =>
{
logBox.Text = text;
logBox.ForeColor = color;
// logBox.Focus(); //使文本框获取焦点
logBox.AppendText(now.ToLongTimeString() + " " + msg + Environment.NewLine); //增加文本
......@@ -138,6 +122,9 @@ namespace OnlineStore.Common
logBox.ScrollToCaret(); //滚动到控件光标处
}
}
));
}
}
catch (Exception ex)
{
......
using Asa;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
partial class AC_BOX_Bean
{
#region 出入库结果验证
public bool CompressSigTimeOut = false;
public bool IsScanCodeWithLockedShelf = true; //锁定的料架是否扫码
private void CheckWait()
{
List<WaitResultInfo> list = MoveInfo.WaitList;
//当等待超过一分钟时,需要打印提示
TimeSpan span = DateTime.Now - MoveInfo.LastSetpTime;
string NotOkMsg = "";
if (list.Count <= 0)
{
MoveInfo.EndStepWait();
return;
}
bool isOk = true;
if (MoveInfo.OneWaitCanEndStep)
{
isOk = false;
}
foreach (WaitResultInfo wait in list)
{
if (wait.IsEnd)
{
continue;
}
NotOkMsg = wait.ToStr();
if (wait.WaitType.Equals(WaitEnum.W001_AxisMove))
{
string msg = "";
if (wait.IsHomeMove)
{
wait.IsEnd = ACHomeMoveIsEnd(wait.AxisInfo, out msg);
}
else
{
wait.IsEnd = ACAxisMoveIsEnd(wait.AxisInfo, wait.TargetPosition, wait.TargetSpeed, out msg);
}
if (!msg.Equals(""))
{
isOk = false;
WarnMsg = msg;
Alarm(StoreAlarmType.AxisMoveError, GetAlarmCodeByAxis(wait.AxisInfo).ToString(), WarnMsg, MoveInfo.MoveType);
break;
}
}
else if (wait.WaitType.Equals(WaitEnum.W002_IOValue))
{
wait.IsEnd = IOValue(wait.IoType).Equals(wait.IoValue);
int timeOutMs = Config.IOSingle_TimerOut;
if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_08_WaitLineIn) ||
MoveInfo.MoveStep.Equals(StoreMoveStep.BI_04_WaitTakeSingle))
{
timeOutMs = 30000;
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_03_LineRun))
{
timeOutMs = 40000;
}
if ((!wait.IsEnd) && span.TotalMilliseconds > timeOutMs && NoAlarm())
{
ConfigIO io = Config.getWaitIO(wait.IoType);
WarnMsg = Name + "[" + MoveInfo.MoveType + "][" + MoveInfo.MoveStep + "] 等待(" + io.DisplayStr + "=" + wait.IoValue + ") 超时";
if (WarnMsg.Contains(IO_Type.Compress_Check) && MoveInfo.MoveStep.Equals(StoreMoveStep.SO_09_CheckComSig))
{
CompressSigTimeOut = true;
WarnMsg += "出库时料叉未检测到信号!";
}
Alarm(StoreAlarmType.IoSingleTimeOut, io.ElectricalDefinition, WarnMsg, MoveInfo.MoveType);
LogUtil.error(Name + "[" + MoveInfo.MoveType + "][" + MoveInfo.MoveStep + "] 等待(" + io.DisplayStr + "=" + wait.IoValue + ") 超时", logType + 14);
if (!MoveInfo.OneWaitCanEndStep)
{
isOk = false;
break;
}
}
}
else if (wait.WaitType.Equals(WaitEnum.W003_Time))
{
wait.IsEnd = (span.TotalMilliseconds >= wait.TimeMSeconds);
}
else if (wait.WaitType.Equals(WaitEnum.W007_ReelHeight))
{
}
else if (wait.WaitType.Equals(WaitEnum.W008_Compress))
{
//等待信号亮或者走到绝对位置才停止
if (IOValue(TargetIoType).Equals(TargetIoValue))
{
LogUtil.info("CheckWait 检测到" + TargetIoType + "=" + TargetIoValue + ",停止压紧轴运行");
wait.IsEnd = true;
ComAxisStopCheck();
}
else
{
bool moveOk = ACServerManager.GetBusyStatus(wait.AxisInfo.DeviceName, wait.AxisInfo.GetAxisValue()).Equals(0);
if (moveOk)
{
//TODO 判断是否达到高度,如果未达到,继续上升
wait.IsEnd = true;
ComAxisStopCheck();
}
}
}
else if (wait.WaitType.Equals(WaitEnum.W009_ScanCode))
{
wait.IsEnd = (LastScanCodes.Count > 0);
}
else if (wait.WaitType.Equals(WaitEnum.W010_AgvStatus))
{
if (wait.AgvAction.Equals((int)ClientAction.Ready))
{
//Ready时使用状态判断,arrive时需要判断料架号是否正确
ClientAction agvA = AgvClient.GetAction(Config.AgvNodeName);
wait.IsEnd = ((int)agvA).Equals(wait.AgvAction);
}
if (!wait.IsEnd && span.TotalSeconds > 10)
{
//如果是等待AGV到达,等待有料架信号也算结束
if (wait.AgvAction.Equals((int)ClientAction.Arrive) && MoveInfo.MoveStep.Equals(StoreMoveStep.BI_00_ReadyShelf))
{
if (IOValue(IO_Type.LineTake_Check).Equals(IO_VALUE.HIGH))
{
LogInfo("BI_01_ReadyShelf 等待agv到达Arrive,检测到 LineTake_Check 信号,结束等待");
wait.IsEnd = true;
}
else if (IOValue(IO_Type.LineIn_Check).Equals(IO_VALUE.HIGH))
{
LogInfo("BI_01_ReadyShelf 等待agv到达Arrive,检测到 LineIn_Check 信号,结束等待");
wait.IsEnd = true;
}
}
else if (wait.AgvAction.Equals((int)ClientAction.Arrive) && MoveInfo.MoveStep.Equals(StoreMoveStep.BS_03_WaitEmptyAgv))
{
if (IOValue(IO_Type.LineTake_Check).Equals(IO_VALUE.LOW) && IOValue(IO_Type.LineIn_Check).Equals(IO_VALUE.LOW))
{
LogInfo("BS_03_WaitArrive 等待agv到达Arrive,检测到 LineTake_Check和LineIn_Check都没有信号,结束等待");
wait.IsEnd = true;
}
}
}
}
else if (wait.WaitType.Equals(WaitEnum.W011_DoorCloseEvent))
{
if (AgvClient.closeDoorTimeMap.ContainsKey(Config.AgvNodeName))
{
DateTime time = AgvClient.closeDoorTimeMap[Config.AgvNodeName];
if (time >= MoveInfo.LastSetpTime)
{
wait.IsEnd = true;
}
}
}
if (wait.IsEnd)
{
if (MoveInfo.OneWaitCanEndStep)
{
isOk = true;
break;
}
}
else
{
if (!MoveInfo.OneWaitCanEndStep)
{
isOk = false;
break;
}
}
}
if (isOk)
{
MoveInfo.EndStepWait();
}
else if (span.TotalSeconds > MoveInfo.TimeOutSeconds)
{
if (NotOkMsg.Contains(IO_Type.Compress_Check) && MoveInfo.MoveStep.Equals(StoreMoveStep.SO_09_CheckComSig))
{
CompressSigTimeOut = true;
NotOkMsg += "出库时料叉未检测到信号!";
}
WarnMsg = Name + "[" + MoveInfo.MoveType + "][" + MoveInfo.MoveStep + "]等待 " + NotOkMsg
+ "超时[" + FormUtil.GetSpanStr(span) + "] ";
int second = 10;
second = (int)(MoveInfo.TimeOutSeconds / span.TotalSeconds) * 10;
if (second > 120)
{
second = 120;
}
else if (second < 10)
{
second = 10;
}
LogUtil.error(WarnMsg, logType + 100, second);
Alarm(StoreAlarmType.IoSingleTimeOut, "", WarnMsg, MoveInfo.MoveType);
}
}
private static DateTime lastComRHomeTime = DateTime.Now;
private void InOutBackToP1(int InOut_P1)
{
//判断是否在P1,如果是,不需要运行
if (ACServerManager.isInPosition(Config.InOut_Axis, InOut_P1))
{
LogUtil.debug(Name + "进出轴当前已经在P1,不需要再回P1");
}
else
{
ACAxisMove(Config.InOut_Axis, InOut_P1, Config.InOutAxis_P1_Speed);
}
//StoreMove.WaitList.Add(WaitResultInfo.WaitAxisOrg(Config.InOut_Axis,IO_VALUE.HIGH));
}
#endregion
public ConcurrentQueue<InOutParam> waitOutStoreList = new ConcurrentQueue<InOutParam>();
private List<string> LastScanCodes = new List<string>();
private int ComTargetPosition = 0;
private int LastWidth = 0;
private int LastHeight = 0;
private string CurrShelfID = "";
/// <summary>
/// 最后一次使用的料架号
/// </summary>
// private string LastRfidID = "";//服务器发送的出库rfid
private InOutParam LastOutParam = new InOutParam();
private string GetLastRfid()
{
//出库料架使用,返回上次使用的料架绑定的虚拟料架号
return LastOutParam.rfid;
}
#region 入库
private void ClearLastTrayInfo()
{
LastScanCodes = new List<string>();
ComTargetPosition = 0;
LastWidth = 0;
LastHeight = 0;
}
private DateTime startInStoreTime = DateTime.Now;
/// <summary>
/// 开始单盘入库
/// </summary>
public override void StartInStoreMove(InOutParam param)
{
startInStoreTime = DateTime.Now;
string posId = param != null ? param.PosID : "";
if (isInSuddenDown || isNoAirCheck ||
(!storeRunStatus.Equals(StoreRunStatus.Runing))
|| (!MoveInfo.MoveType.Equals(StoreMoveType.None)))
{
LogUtil.error(Name + " 启动出库出错,忙碌或报警中 ,storeStatus=" + storeRunStatus + ",MoveType=" + MoveInfo.MoveType + ",isInSuddenDown=" + isInSuddenDown + ",isNoAirCheck" + isNoAirCheck);
return;
}
if (!StoreManager.LoadInoutParam(param, true, this))
{
LogUtil.error(Name + " 启动入库【" + param.ToStr() + "】出错,找不到库位信息");
return;
}
LogInfo(" 启动入库【" + param.ToStr() + "】,压紧点P2【" + param.MoveP.ComPress_P2 + "】压紧前点P3【" + param.MoveP.ComPress_P3 + "】");
storeRunStatus = StoreRunStatus.Busy;
storeStatus = StoreStatus.InStoreExecute;
MoveInfo.NewMove(StoreMoveType.InStore, param);
//新的料架库位
MoveInfo.NextMoveStep(StoreMoveStep.BI_11_InoutToP1);
MoveInfo.SingleInstore = true;
InOutStoreLog("料架取料:" + MoveInfo.SLog + " 叉子后退到待机点P1, 重置盘信息");
ACAxisMove(Config.InOut_Axis, Config.InOutAxis_P1_Position, Config.InOutAxis_P1_Speed);
ClearLastTrayInfo();
//LastRfidID = "";
LastOutParam = new InOutParam();
}
/// <summary>
/// 开始料架入库
/// </summary>
public void StartShelfInStore()
{
bool canStart = (storeRunStatus.Equals(StoreRunStatus.Runing)
&& MoveInfo.MoveType.Equals(StoreMoveType.None));
if (!canStart || isInSuddenDown || isNoAirCheck || (alarmType.Equals(StoreAlarmType.None).Equals(false)))
{
return;
}
storeRunStatus = StoreRunStatus.Busy;
storeStatus = StoreStatus.InStoreExecute;
// EmprtShelfList = new ConcurrentQueue<string>();
if (IOValue(IO_Type.LineIn_Check).Equals(IO_VALUE.HIGH))
{
MoveInfo.NewMove(StoreMoveType.InStore, new InOutParam());
MoveInfo.MoveParam.MoveP = new LineMoveP(Config);
MoveInfo.ShelfPositionList = new List<string>(ShelfPosList);
MoveInfo.NextMoveStep(StoreMoveStep.BI_01_DoorOpen);
LogInfo(" 空闲中,检测到入料口有料架,启动料架入库 " + MoveInfo.SLog + "");
// CylinderMove(MoveInfo, IO_Type.EntranceDoor_Close, IO_Type.EntranceDoor_Open);
// DoorBean.StartOpen(MoveInfo);
}
else if (IOValue(IO_Type.LineTake_Check).Equals(IO_VALUE.HIGH))
{
MoveInfo.NewMove(StoreMoveType.InStore, new InOutParam());
MoveInfo.MoveParam.MoveP = new LineMoveP(Config);
MoveInfo.ShelfPositionList = new List<string>(ShelfPosList);
MoveInfo.NextMoveStep(StoreMoveStep.BI_06_DoorClose);
LogInfo(" 空闲中,检测到入料口有料架,启动料架入库 " + MoveInfo.SLog + "");
}
else
{
LogInfo(" 空闲中,需要料架入库,料架入库 " + MoveInfo.SLog + ":入料口移门打开,更新 WaitShelfEnter=false");
WaitShelfEnter = false;
MoveInfo.NewMove(StoreMoveType.InStore, new InOutParam());
MoveInfo.MoveParam.MoveP = new LineMoveP(Config);
MoveInfo.ShelfPositionList = new List<string>(ShelfPosList);
MoveInfo.NextMoveStep(StoreMoveStep.BI_01_DoorOpen);
DoorBean.StartOpen(MoveInfo);
}
}
private void UpdateShelfId()
{
//读取RFID
RFIDData data = RFIDManager.ReadRFID(Config.RFID_IP, true);
CurrShelfID = data.NumStr();
LogUtil.info(Name + "更新当前料架号CurrShelfID=【" + CurrShelfID + "】,LastRfidID=【" + GetLastRfid() + "】");
}
private void GetPosId()
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_30_SetInstoreParam);
InOutStoreLog("不扫码 " + MoveInfo.SLog + ": 获取库位号");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(10000));
if (MoveInfo.IsShelfLocked)
{
bool result = GetPosIdByCode();
if (!result)//获取库位失败
{
MoveInfo.MoveParam.PosID = "";
StartSendTray("锁定库位:获取入库库位失败");
}
else
{
MoveInfo.EndStepWait();
}
}
}
private void StartMoveToBag()
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_51_MoveToBag);
InOutStoreLog("入库 " + MoveInfo.SLog + ":到库位点,旋转轴至P2( 库位点)轴2(上下) 至P3(库位入库前点)");
ACAxisMove(Config.Middle_Axis, MoveInfo.MoveParam.MoveP.Middle_P2, Config.MiddleAxis_P2_Speed);
ACAxisMove(Config.UpDown_Axis, MoveInfo.MoveParam.MoveP.UpDown_P3, Config.UpDownAxis_P3_Speed);
}
private void StartSendTray(string str = "扫码失败")
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_71_ToNGDoor);
InOutStoreLog(" NG料 " + MoveInfo.SLog + ":" + str + ",升降轴到NG门口高点P12,旋转轴到NG门口P11");
//if(MoveInfo.IsShelfLocked)//锁定料架,扫码失败则清除当前位置
{
StoreManager.ClearLockLoc(Name, CurrShelfID, MoveInfo.currShelfIndex);
}
ACAxisMove(Config.UpDown_Axis, MoveInfo.MoveParam.MoveP.UpDown_P12, Config.UpDownAxis_P1_Speed);
ACAxisMove(Config.Middle_Axis, MoveInfo.MoveParam.MoveP.Middle_P11, Config.MiddleAxis_P1_Speed);
}
private void StartMoveTrayBack(string str = "料盘不属于该仓库")
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_10_ToShelfPosition);
InOutStoreLog("送出料盘 " + MoveInfo.SLog + ":" + str + ",走到料架位置,旋转轴至P101,升降轴至P102");
ACAxisMove(Config.UpDown_Axis, MoveInfo.MoveParam.MoveP.UpDown_HP102, Config.UpDownAxis_P102_Speed);
ACAxisMove(Config.Middle_Axis, MoveInfo.MoveParam.MoveP.Middle_P101, Config.MiddleAxis_P101_Speed);
}
protected override void InStoreProcess()
{
LineMoveP moveP = MoveInfo.MoveParam.MoveP;
if (MoveInfo.IsInWait)
{
CheckWait();
}
if (MoveInfo.IsInWait)
{
return;
}
#region 料架取料盘扫码获取POSID
if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_10_StartGetTray))
{
if (MoveInfo.IsShelfLocked)
{
if (MoveInfo.NextLockedShelfPos())
{
//新的料架库位
startInStoreTime = DateTime.Now;
MoveInfo.SingleInstore = false;
MoveInfo.NextMoveStep(StoreMoveStep.BI_11_InoutToP1);
InOutStoreLog("料架取料 " + MoveInfo.SLog + ":叉子后退到待机点P1, 重置盘信息");
ACAxisMove(Config.InOut_Axis, Config.InOutAxis_P1_Position, Config.InOutAxis_P1_Speed);
ClearLastTrayInfo();
}
else
{
//所有料盘已取料完成,送出料架
StartShelfOut();
}
}
else
{
if (MoveInfo.NextShelfPos())
{
//新的料架库位
startInStoreTime = DateTime.Now;
MoveInfo.SingleInstore = false;
MoveInfo.NextMoveStep(StoreMoveStep.BI_11_InoutToP1);
InOutStoreLog("料架取料 " + MoveInfo.SLog + ":叉子后退到待机点P1, 重置盘信息");
ACAxisMove(Config.InOut_Axis, Config.InOutAxis_P1_Position, Config.InOutAxis_P1_Speed);
ClearLastTrayInfo();
}
else
{
//所有料盘已取料完成,送出料架
StartShelfOut();
}
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_11_InoutToP1))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_12_MoveToShelf);
InOutStoreLog("料架取料 " + MoveInfo.SLog + ":升降轴到P101低点[" + moveP.UpDown_LP101 + "],旋转轴到P101点[" + moveP.Middle_P101 + "],压紧轴到压紧前点p3[" + Config.CompAxis_Max_P3 + "]");
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_LP101, Config.UpDownAxis_P102_Speed);
ACAxisMove(Config.Middle_Axis, moveP.Middle_P101, Config.MiddleAxis_P101_Speed);
ACAxisMove(Config.Comp_Axis, Config.CompAxis_Max_P3, Config.CompAxis_P3_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_12_MoveToShelf))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_13_InoutToP101);
InOutStoreLog("料架取料 " + MoveInfo.SLog + ":叉子前进到P101点[" + moveP.InOut_P101 + "]", true);
ACAxisMove(Config.InOut_Axis, moveP.InOut_P101, Config.InOutAxis_P101_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_13_InoutToP101))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_14_UpdownToP102);
InOutStoreLog("料架取料 " + MoveInfo.SLog + ":升降轴上升到P102点[" + moveP.UpDown_HP102 + "]", true);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_HP102, Config.UpDownAxis_P101_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_14_UpdownToP102))
{
if (MoveInfo.SingleInstore)
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_16_ComDownMove);
InOutStoreLog("单盘入库,料架取料 " + MoveInfo.SLog + ":压紧轴走到压紧点P2: " + MoveInfo.MoveParam.MoveP.ComPress_P2);
ACAxisMove(Config.Comp_Axis, MoveInfo.MoveParam.MoveP.ComPress_P2, Config.CompAxis_P2_Speed);
}
else
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_15_StartCompress);
InOutStoreLog("料架取料 " + MoveInfo.SLog + ":压紧轴开始缓慢压紧到P4 :" + Config.CompAxis_P4_Position);
MoveInfo.WaitList.Add(WaitResultInfo.WaitComAxis(Config.Comp_Axis, Config.CompAxis_P4_Position, Config.CompAxis_P4_Speed));
Config.Comp_Axis.TargetPosition = Config.CompAxis_P4_Position;
ACServerManager.AbsMove(Config.Comp_Axis.DeviceName, Config.Comp_Axis.GetAxisValue(), Config.CompAxis_P4_Position, Config.CompAxis_P4_Speed);
ComAxisStartCheck();
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_15_StartCompress))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_16_ComDownMove);
int currPosition = ACServerManager.GetActualtPosition(Config.Comp_Axis);
ComTargetPosition = currPosition;
int targetP = currPosition + Config.CompAxis_Down_Position;
LastHeight = Config.GetComP2PlateH(targetP);
MoveInfo.MoveParam.MoveP.ComPress_P2 = targetP;
MoveInfo.MoveParam.MoveP.ComPress_P3 = targetP + Config.CompAxis_P3_P2_Value;
InOutStoreLog("料架取料 " + MoveInfo.SLog + ":检测到Compress_Check,盘高【" + LastHeight + "】,向下压紧 [" + Config.CompAxis_Down_Position + "] 目标 [" + targetP +
"]记录ComP2[" + targetP + "]ComP3[" + MoveInfo.MoveParam.MoveP.ComPress_P3 + "]");
ACAxisMove(Config.Comp_Axis, targetP, Config.CompAxis_P1_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_16_ComDownMove))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_17_InoutBack);
InOutStoreLog("料架取料 " + MoveInfo.SLog + ":叉子后退到扫码点");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P1, Config.CompAxis_P1_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_17_InoutBack))
{
if (MoveInfo.SingleInstore)
{
//单盘入库,不需要扫码
StartMoveToBag();
}
else if (MoveInfo.IsShelfLocked && !IsScanCodeWithLockedShelf)
{
//该料架已锁定库位,不需要扫码,直接查询服务器
GetPosId();
}
else
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_21_ToScanPosition);
InOutStoreLog("扫码 " + MoveInfo.SLog + ":升降轴到P2,旋转轴到P1", true);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P2, Config.UpDownAxis_P1_Speed);
ACAxisMove(Config.Middle_Axis, moveP.Middle_P1, Config.MiddleAxis_P1_Speed);
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_21_ToScanPosition))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_22_InOutToP2);
InOutStoreLog("扫码 " + MoveInfo.SLog + ":进出轴到P2", true);
ACAxisMove(Config.InOut_Axis, moveP.InOut_P2, Config.InOutAxis_P2_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_22_InOutToP2))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_23_PutTrayDown);
InOutStoreLog("扫码 " + MoveInfo.SLog + ":升降轴到扫码低点P1,压紧轴到压紧前点P3", true);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P1, Config.UpDownAxis_P2_Speed);
ACAxisMove(Config.Comp_Axis, moveP.ComPress_P3, Config.CompAxis_P3_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_23_PutTrayDown))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_24_InOutToP1);
InOutStoreLog("扫码 " + MoveInfo.SLog + ":进出轴返回待机点P1", true);
ACAxisMove(Config.InOut_Axis, moveP.InOut_P1, Config.CompAxis_P1_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_24_InOutToP1))
{
IO_VALUE io1 = IOValue(IO_Type.TrayCheck_1);
IO_VALUE io2 = IOValue(IO_Type.TrayCheck_2);
IO_VALUE io3 = IOValue(IO_Type.TrayCheck_3);
IO_VALUE io4 = IOValue(IO_Type.TrayCheck_4);
if (io3.Equals(IO_VALUE.HIGH) || io4.Equals(IO_VALUE.HIGH))
{
LastWidth = 15;
}
else if (io1.Equals(IO_VALUE.HIGH) || io2.Equals(IO_VALUE.HIGH))
{
LastWidth = 7;
}
else
{
LastWidth = 0;
LogUtil.debug("未检测到识别区料盘检测信号, 设置默认宽度=0");
}
MoveInfo.NextMoveStep(StoreMoveStep.BI_25_ScanCode);
InOutStoreLog("扫码 " + MoveInfo.SLog + ":料盘识别 [" + io1 + "] [" + io2 + "] [" + io3 + "] [" + io4 + "] ,宽度【" + LastWidth + "】,开始扫码");
MoveInfo.OneWaitCanEndStep = true;
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(12000));
MoveInfo.WaitList.Add(WaitResultInfo.WaitCode());
Task.Factory.StartNew(delegate
{
IOMove(IO_Type.Camera_Led, IO_VALUE.HIGH);
LastScanCodes = CodeManager.CameraScan(Config.GetCameraList(), Name);
if (LastScanCodes.Count <= 0)
{
Thread.Sleep(1);
LastScanCodes = CodeManager.CameraScan(Config.GetCameraList(), Name);
}
IOMove(IO_Type.Camera_Led, IO_VALUE.LOW);
});
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_25_ScanCode))
{
if (LastScanCodes.Count <= 0 && LastWidth.Equals(0) && LastHeight.Equals(8))
{
storeStatus = StoreStatus.InStoreExecute;
MoveInfo.NextMoveStep(StoreMoveStep.BI_10_StartGetTray);
InOutStoreLog("扫码 " + MoveInfo.SLog + ": 扫码失败,尺寸" + LastWidth + "*" + LastHeight + ",认为没拿到料盘,继续循环料架取料盘");
}
else
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_27_InoutToP2);
InOutStoreLog("扫码 " + MoveInfo.SLog + ":进出轴到P2", true);
ACAxisMove(Config.InOut_Axis, moveP.InOut_P2, Config.InOutAxis_P2_Speed);
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_27_InoutToP2))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_28_GetScanPTray);
InOutStoreLog("扫码 " + MoveInfo.SLog + ":升降轴到扫码高P2,压紧轴到压紧点P2", true);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P2, Config.UpDownAxis_P2_Speed);
ACAxisMove(Config.Comp_Axis, moveP.ComPress_P2, Config.CompAxis_P2_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_28_GetScanPTray))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_29_InoutBackP1);
InOutStoreLog("扫码 " + MoveInfo.SLog + ":进出轴返回", true);
ACAxisMove(Config.InOut_Axis, moveP.InOut_P1, Config.InOutAxis_P1_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_29_InoutBackP1))
{
if (LastScanCodes.Count <= 0)
{
StartSendTray();
}
else
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_30_SetInstoreParam);
InOutStoreLog("扫码 " + MoveInfo.SLog + ": 获取库位号");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime((int)TimeSpan.FromMinutes(75).TotalMilliseconds));
bool result = GetPosIdByCode(MoveInfo.currShelfIndex, out CodeResultType codeResult);
if (!result)//获取库位失败
{
if (codeResult == CodeResultType.NotPosForPutIn)//库位不在该料仓,将该料盘放回料架
{
//MoveInfo.MoveParam.PosID = "";
StartMoveTrayBack("此料盘不属于该仓库,放回料架");
}
else//无法获取库位信息
{
MoveInfo.MoveParam.PosID = "";
StartSendTray("获取入库库位失败");
}
}
else
{
MoveInfo.EndStepWait();
}
}
}
#endregion
#region 入库逻辑
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_30_SetInstoreParam))
{
StartMoveToBag();
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_51_MoveToBag))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_52_DeviceToBag);
InOutStoreLog("入库 " + MoveInfo.SLog + ":叉子进入库位中,进出轴到库位P3");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P3, Config.InOutAxis_P3_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_52_DeviceToBag))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_53_PutWareToBag);
InOutStoreLog("入库 " + MoveInfo.SLog + ":放下物品,升降轴到库位缓冲点P4,压紧轴到P3");
// 5= 入仓位完成(料仓Box把料盘放入对应的库位中,装置还未恢复原始状态)
string posId = MoveInfo.MoveParam != null ? MoveInfo.MoveParam.PosID : "";
lastPosId = posId;
lastPosIdStatus = StoreStatus.InStoreEnd;
storeStatus = StoreStatus.InStoreEnd;
//手动发给服务器状态,防止没有手动
//SendLineStatus(StoreID, posId, StoreStatus.InStoreEnd);
ACAxisMove(Config.Comp_Axis, moveP.ComPress_P3, Config.CompAxis_P3_Speed);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P4, Config.UpDownAxis_P4_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_53_PutWareToBag))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_54_DeviceBackFromBag);
InOutStoreLog("入库 " + MoveInfo.SLog + ":叉子从库位中返回,进出轴到P1");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P1, Config.InOutAxis_P1_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_54_DeviceBackFromBag))
{
if (MoveInfo.SingleInstore)
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_55_GoBack);
InOutStoreLog("入库 " + MoveInfo.SLog + ":返回待机点,轴2/轴1/轴4动作至P1( 待机点))开始");
ACAxisMove(Config.Comp_Axis, moveP.ComPress_P1, Config.CompAxis_P1_Speed);
ACAxisMove(Config.Middle_Axis, moveP.Middle_P1, Config.MiddleAxis_P1_Speed);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P1, Config.UpDownAxis_P1_Speed);
}
else
{
TimeSpan span = DateTime.Now - startInStoreTime;
storeStatus = StoreStatus.InStoreExecute;
MoveInfo.NextMoveStep(StoreMoveStep.BI_10_StartGetTray);
InOutStoreLog("料架入库 " + MoveInfo.SLog + ":上一盘入库结束, 耗时【" + FormUtil.GetSpanStr(span) + "】,旋转轴返回待机点,继续循环料架取料盘");
ACAxisMove(Config.Middle_Axis, moveP.Middle_P1, Config.MiddleAxis_P1_Speed);
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_55_GoBack))
{
TimeSpan span = DateTime.Now - startInStoreTime;
StoreManager.ClearLockLoc(Name, CurrShelfID, MoveInfo.currShelfIndex);
if (MoveInfo.SingleInstore)
{
string posId = MoveInfo.MoveParam != null ? MoveInfo.MoveParam.PosID : "";
LogInfo(" 【" + posId + "】单盘入库结束,耗时【" + FormUtil.GetSpanStr(span) + "】!");
MoveEndToRuningStatus();
AutoInout.InOutEndProcess(this, StoreMoveType.InStore);
}
else
{
storeStatus = StoreStatus.InStoreExecute;
MoveInfo.NextMoveStep(StoreMoveStep.BI_10_StartGetTray);
InOutStoreLog("料架入库 " + MoveInfo.SLog + ":上一盘入库结束, 耗时【" + FormUtil.GetSpanStr(span) + "】继续循环料架取料盘");
}
}
#endregion
#region 把料盘送到NG逻辑
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_71_ToNGDoor))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_72_NGDoorUp);
InOutStoreLog("NG料 " + MoveInfo.SLog + ":NG升降门上升", true);
CylinderMove(MoveInfo, IO_Type.NGDoorCylinder_Down, IO_Type.NGDoowCylinder_Up);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_72_NGDoorUp))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_73_InoutToNGDoor);
InOutStoreLog("NG料 " + MoveInfo.SLog + ":进出轴到NG料门口位置P11", true);
ACAxisMove(Config.InOut_Axis, moveP.InOut_P11, Config.InOutAxis_P2_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_73_InoutToNGDoor))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_74_UpdownDown);
InOutStoreLog("NG料 " + MoveInfo.SLog + ":升降轴到P11,压紧轴到P3,放下料盘", true);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P11, Config.UpDownAxis_P2_Speed);
ACAxisMove(Config.Comp_Axis, moveP.ComPress_P3, Config.CompAxis_P3_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_74_UpdownDown))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_75_InoutToP1);
InOutStoreLog("NG料 " + MoveInfo.SLog + ":叉子后退到P1", true);
ACAxisMove(Config.InOut_Axis, moveP.InOut_P1, Config.InOutAxis_P1_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_75_InoutToP1))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_76_NGDoorDown);
InOutStoreLog("NG料 " + MoveInfo.SLog + ":关门NG料门,送出料盘结束", true);
CylinderMove(MoveInfo, IO_Type.NGDoowCylinder_Up, IO_Type.NGDoorCylinder_Down);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_76_NGDoorDown))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_77_NGLineRun);
InOutStoreLog("料架入库 " + MoveInfo.SLog + ":NG流水线转动30s", true);
IOMove(IO_Type.NGLine_BackRun, IO_VALUE.LOW);
IOMove(IO_Type.NGLine_Run, IO_VALUE.HIGH);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(30000));
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_77_NGLineRun))
{
IOMove(IO_Type.NGLine_Run, IO_VALUE.LOW);
MoveInfo.NextMoveStep(StoreMoveStep.BI_10_StartGetTray);
InOutStoreLog("料架入库 " + MoveInfo.SLog + ":停止NG线体转动,继续循环料架取料盘");
}
#endregion
#region 把料盘送回料架逻辑
else if (MoveInfo.MoveStep == StoreMoveStep.SO_10_ToShelfPosition)
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_11_ToShelf);
InOutStoreLog("送出料盘 " + MoveInfo.SLog + ":叉子进出料口,进出轴至P101", true);
ACAxisMove(Config.InOut_Axis, moveP.InOut_P101, Config.InOutAxis_P101_Speed);
}
else if (MoveInfo.MoveStep == StoreMoveStep.SO_11_ToShelf)
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_12_PutReel);
InOutStoreLog("送出料盘 " + MoveInfo.SLog + ":放下物品,压紧轴到P1,升降轴至P101,清空 taskData=null ");
ACAxisMove(Config.Comp_Axis, moveP.ComPress_P1, Config.CompAxis_P1_Speed);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_LP101, Config.UpDownAxis_P101_Speed);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
}
else if (MoveInfo.MoveStep == StoreMoveStep.SO_12_PutReel)
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_13_InoutBack);
InOutStoreLog("送出料盘 " + MoveInfo.SLog + ":叉子从出料口返回, 进出轴到P1 ", true);
InOutBackToP1(moveP.InOut_P1);
}
else if (MoveInfo.MoveStep == StoreMoveStep.SO_13_InoutBack)
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_10_StartGetTray);
InOutStoreLog("送出料盘结束 " + MoveInfo.SLog + ": 升降轴返回,升降轴到P1,顶升下降,继续循环料架取料盘");
// ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P1, Config.UpDownAxis_P1_Speed);
}
#endregion
//料架进入逻辑
else if (MoveInfo.MoveStep < StoreMoveStep.BI_10_StartGetTray)
{
ShelfEnterProcess();
}
//料架送出逻辑
else if (MoveInfo.MoveStep >= StoreMoveStep.BS_01_TopDown)
{
ShelfOutProcess();
}
else
{
LogInfo(" 入库,MoveStep=" + MoveInfo.MoveStep + ",没有对应的处理!");
}
}
#endregion
#region 压紧轴压紧处理
private System.Timers.Timer axisCheckTimer = null;
private string TargetIoType = IO_Type.Compress_Check;
private IO_VALUE TargetIoValue = IO_VALUE.HIGH;
public bool ComAxisStartCheck(string targetIo = "", IO_VALUE value = IO_VALUE.HIGH)
{
if (String.IsNullOrEmpty(targetIo))
{
targetIo = IO_Type.Compress_Check;
}
if (axisCheckTimer == null)
{
axisCheckTimer = new System.Timers.Timer();
axisCheckTimer.AutoReset = true;
axisCheckTimer.Interval += 50;
axisCheckTimer.Elapsed += CheckTimer_Elapsed;
axisCheckTimer.Enabled = false;
}
TargetIoValue = value;
TargetIoType = targetIo;
axisCheckTimer.Start();
return true;
}
private bool ComAxisStopCheck()
{
if (!(axisCheckTimer == null))
{
ACServerManager.SuddenStop(Config.Comp_Axis);
axisCheckTimer.Stop();
}
return true;
}
private bool IsInProcess = false;
private void CheckTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
if (IsInProcess) { return; }
IsInProcess = true;
if (IOValue(TargetIoType).Equals(TargetIoValue))
{
LogUtil.info(Name + "压紧轴运动:检测到 " + TargetIoType + "=" + TargetIoValue + ",停止运动");
ACServerManager.SuddenStop(Config.Comp_Axis.DeviceName, Config.Comp_Axis.GetAxisValue());
ComAxisStopCheck();
}
IsInProcess = false;
}
#endregion
#region 出库
private DateTime startOutStoreTime = DateTime.Now;
public bool IsIgnoreComSig = false; //忽略料叉压紧信号
private void StartExecuctOut(InOutParam param)
{
bool result;
if (param.urgentReel)
{
result = StartUrgentOutStoreMove(param);
}
else
{
result = StartOutStoreMove(param);
}
if (!result)
{
LogInfo(" 执行出库【" + param.ToStr() + "】失败,加入等待队列");
waitOutStoreList.Enqueue(param);
}
}
/// <summary>
/// 开始出库运动
/// </summary>
public override bool StartOutStoreMove(InOutParam param)
{
startOutStoreTime = DateTime.Now;
string posId = param != null ? param.PosID : "";
if (isInSuddenDown || isNoAirCheck ||
(!storeRunStatus.Equals(StoreRunStatus.Runing))
|| (!MoveInfo.MoveType.Equals(StoreMoveType.None)))
{
LogUtil.error(Name + " 启动出库【" + param.ToStr() + "】失败,忙碌或报警中 ,storeStatus:" + storeRunStatus + ",MoveType:" + MoveInfo.MoveType + ",isInSuddenDown:" + isInSuddenDown + ",isNoAirCheck:" + isNoAirCheck);
return false;
}
if (WaitShelfEnter)
{
LogUtil.error(Name + " 启动出库【" + param.ToStr() + "】失败,WaitShelfEnter=true ,需要等待入库结束才能出库");
return false;
}
if (!StoreManager.LoadInoutParam(param, false, this))
{
LogUtil.error(Name + " 启动出库【" + param.ToStr() + "】出错,找不到库位信息");
return false;
}
taskData = null;
storeStatus = StoreStatus.OutStoreExecute;
storeRunStatus = StoreRunStatus.Busy;
MoveInfo.NewMove(StoreMoveType.OutStore, param);
LogInfo("启动出库【" + param.ToStr() + "】 ");
//出库前shelfPosID需要固定,出库时根据rfid判断是否需要出入料架
MoveInfo.NextMoveStep(StoreMoveStep.SO_01_InoutBack);
InOutStoreLog("出库 " + MoveInfo.SLog + ":进出轴到P1 开始");
InOutBackToP1(MoveInfo.MoveParam.MoveP.InOut_P1);
return true;
}
/// <summary>
/// 开始紧急料出库运动
/// </summary>
public bool StartUrgentOutStoreMove(InOutParam param)
{
startOutStoreTime = DateTime.Now;
string posId = param != null ? param.PosID : "";
if (isInSuddenDown || isNoAirCheck ||
(!storeRunStatus.Equals(StoreRunStatus.Runing))
|| (!MoveInfo.MoveType.Equals(StoreMoveType.None)))
{
LogUtil.error(Name + " 启动紧急料出库【" + param.ToStr() + "】失败,忙碌或报警中 ,storeStatus:" + storeRunStatus + ",MoveType:" + MoveInfo.MoveType + ",isInSuddenDown:" + isInSuddenDown + ",isNoAirCheck:" + isNoAirCheck);
return false;
}
if (WaitShelfEnter)
{
LogUtil.error(Name + " 启动紧急料出库【" + param.ToStr() + "】失败,WaitShelfEnter=true ,需要等待入库结束才能出库");
return false;
}
if (!StoreManager.LoadInoutParam(param, false, this))
{
LogUtil.error(Name + " 启动紧急料出库【" + param.ToStr() + "】出错,找不到库位信息");
return false;
}
CylinderMove(MoveInfo, IO_Type.TopCylinder_Down, IO_Type.TopCylinder_Up);
taskData = null;
storeStatus = StoreStatus.OutStoreExecute;
storeRunStatus = StoreRunStatus.Busy;
MoveInfo.NewMove(StoreMoveType.OutStore, param);
LogInfo("启动紧急料出库【" + param.ToStr() + "】 ");
MoveInfo.NextMoveStep(StoreMoveStep.SO_01_InoutBack);
InOutStoreLog("紧急料出库 " + MoveInfo.SLog + ":进出轴到P1 开始");
InOutBackToP1(MoveInfo.MoveParam.MoveP.InOut_P1);
return true;
}
private void SO_03_ToBagPosition()
{
LineMoveP movep = MoveInfo.MoveParam.MoveP;
MoveInfo.NextMoveStep(StoreMoveStep.SO_03_ToPosition);
InOutStoreLog("出库 " + MoveInfo.SLog + ":走到库位,压紧轴至P3[" + movep.ComPress_P3 + "] ,旋转轴至P2[" + movep.Middle_P2 + "],升降轴至P5[" + movep.UpDown_P5 + "] ,顶升上升");
ACAxisMove(Config.Comp_Axis, movep.ComPress_P3, Config.CompAxis_P3_Speed);
ACAxisMove(Config.Middle_Axis, movep.Middle_P2, Config.MiddleAxis_P2_Speed);
ACAxisMove(Config.UpDown_Axis, movep.UpDown_P5, Config.UpDownAxis_P5_Speed);
CylinderMove(MoveInfo, IO_Type.TopCylinder_Down, IO_Type.TopCylinder_Up);
}
protected override void OutStoreProcess()
{
LineMoveP moveP = MoveInfo.MoveParam.MoveP;
if (MoveInfo.IsInWait)
{
CheckWait();
}
if (MoveInfo.IsInWait)
{
return;
}
#region 把紧急料盘送到紧急料箱逻辑
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_15_ToUrgentDoor))
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_16_UrgentDoorUp);
InOutStoreLog("紧急料 " + MoveInfo.SLog + ":升降门上升", true);
CylinderMove(MoveInfo, IO_Type.NGDoorCylinder_Down, IO_Type.NGDoowCylinder_Up);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_16_UrgentDoorUp))
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_17_InoutToUrgentDoor);
InOutStoreLog("紧急料 " + MoveInfo.SLog + ":进出轴到升降门口位置P11", true);
ACAxisMove(Config.InOut_Axis, moveP.InOut_P11, Config.InOutAxis_P2_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_17_InoutToUrgentDoor))
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_18_UpdownDown);
InOutStoreLog("紧急料 " + MoveInfo.SLog + ":升降轴到P11,压紧轴到P3,放下料盘", true);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P11, Config.UpDownAxis_P2_Speed);
ACAxisMove(Config.Comp_Axis, moveP.ComPress_P3, Config.CompAxis_P3_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_18_UpdownDown))
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_19_InoutToP1);
InOutStoreLog("紧急料 " + MoveInfo.SLog + ":叉子后退到P1", true);
ACAxisMove(Config.InOut_Axis, moveP.InOut_P1, Config.InOutAxis_P1_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_19_InoutToP1))
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_20_UrgentDoorDown);
InOutStoreLog("紧急料 " + MoveInfo.SLog + ":关闭升降门,送出料盘结束", true);
CylinderMove(MoveInfo, IO_Type.NGDoowCylinder_Up, IO_Type.NGDoorCylinder_Down);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
taskData = null;
Task.Factory.StartNew(delegate
{
int posLoc = StoreManager.GetShelfPosIndex(MoveInfo.MoveParam.ShelfPosID, ShelfPosList);
//紧急料发PutFinished
if (MoveInfo.MoveParam.urgentReel)
{
string msg = StoreManager.afterPutCut(Name, "1000A", MoveInfo.MoveParam.WareCode, CID, 1, out taskData);
if (String.IsNullOrEmpty(msg).Equals(false))
{
LogUtil.error(Name + "[" + MoveInfo.MoveParam.WareCode + "] [" + "1000A" + "_" + GetLastRfid() + "] [" + 1 + "] afterPutCut 结果:" + msg);
}
}
});
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_20_UrgentDoorDown))
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_21_UrgentLineRun);
InOutStoreLog("紧急料出库 " + MoveInfo.SLog + ":流水线转动30s", true);
IOMove(IO_Type.NGLine_Run, IO_VALUE.LOW);
IOMove(IO_Type.NGLine_BackRun, IO_VALUE.HIGH);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(30000));
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_21_UrgentLineRun))
{
IOMove(IO_Type.NGLine_BackRun, IO_VALUE.LOW);
InOutStoreLog("紧急料出库 " + MoveInfo.SLog + ":停止紧急料线体转动");
bool isFinish = false;
if (MoveInfo.MoveParam.urgentReel)
{
if (taskData != null && taskData.urgentPackageTask <= 0)
{
InOutStoreLog("紧急料出库完成,urgentPackageTask=" + taskData.urgentPackageTask + "");
isFinish = true;
}
else if (taskData == null)
{
InOutStoreLog("紧急料出库完成,taskData=null");
isFinish = true;
}
}
if (!isFinish)
{
TimeSpan span = DateTime.Now - startOutStoreTime;
string posId = MoveInfo.MoveParam != null ? MoveInfo.MoveParam.PosID : "";
storeStatus = StoreStatus.StoreOnline;
LogInfo(" 【" + posId + "】 " + " 紧急料出库结束,耗时【" + FormUtil.GetSpanStr(span) + "】!");
if (StoreManager.Store.AutoShelfInstore)
{
LogInfo("紧急料还有出库任务,设置 AutoShelfInstore = false");
ConfigAppSettings.SaveValue(Setting_Init.AutoShelfInstore, 0);
StoreManager.Store.AutoShelfInstore = false;
}
}
else
{
CylinderMove(MoveInfo, IO_Type.TopCylinder_Up, IO_Type.TopCylinder_Down);
}
MoveEndToRuningStatus();
AutoInout.InOutEndProcess(this, StoreMoveType.OutStore);
}
#endregion
#region 出入库步骤
if (MoveInfo.MoveStep == StoreMoveStep.SO_01_InoutBack)
{
//判断是否需要送出料架,是否需要进入料架,是否可以直接开始,是否是紧急料
if (MoveInfo.MoveParam.urgentReel || MoveInfo.MoveParam.rfid.Equals(""))
{
SO_03_ToBagPosition();
}
else
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_02_TopDown);
InOutStoreLog("出库 " + MoveInfo.SLog + ":顶升下降");
CylinderMove(MoveInfo, IO_Type.TopCylinder_Up, IO_Type.TopCylinder_Down);
}
}
else if (MoveInfo.MoveStep == StoreMoveStep.SO_02_TopDown)
{
if (IOValue(IO_Type.LineTake_Check).Equals(IO_VALUE.HIGH))
{
string LastRfidID = GetLastRfid();
// if (IsRightShelfId(CurrShelfID, MoveInfo.MoveParam.realRfid))
if (MoveInfo.MoveParam.rfid.Equals(LastRfidID))
{
LogUtil.error("出库 【" + LastRfidID + "】 【" + MoveInfo.MoveParam.rfid + "," + MoveInfo.MoveParam.realRfid + "】 同料架,开始取料");
SO_03_ToBagPosition();
return;
}
else
{
//重新记录
LogInfo(" 执行出库【" + MoveInfo.MoveParam.ToStr() + "】失败,料架号不一致,加入等待队列");
waitOutStoreList.Enqueue(MoveInfo.MoveParam);
LogUtil.error(Name + "出库 【" + LastRfidID + "】 【" + MoveInfo.MoveParam.rfid + "," + MoveInfo.MoveParam.realRfid + "】不同料架,送出当前料架,稍后重新出库");
// MoveInfo.MoveParam.rfid = LastRfidID;
MoveInfo.NewMove(StoreMoveType.OutStore, LastOutParam);
//送出料架,并且记录出库信息,等会重新出库
StartShelfOut();
return;
}
}
else if (IOValue(IO_Type.LineTake_Check).Equals(IO_VALUE.LOW) && (!MoveInfo.MoveParam.rfid.Equals("")))
{
if (CurrShelfID.EndsWith("00"))
{
CurrShelfID = "";
}
string mark = GetMarkInfo();
// string rfid = MoveInfo.MoveParam.rfid;
MoveInfo.NextMoveStep(StoreMoveStep.BI_00_ReadyShelf);
InOutStoreLog("出库 " + MoveInfo.SLog + ": NeedEnter[" + mark + "][" + MoveInfo.MoveParam.rfid + "],等待agv_Arrive 或有料架,进出轴到P1");
InOutBackToP1(MoveInfo.MoveParam.MoveP.InOut_P1);
//需要先叫agv到达
AgvClient.SetStatus(Config.AgvNodeName, mark, MoveInfo.MoveParam.rfid, ClientAction.NeedEnter, ClientLevel.High, true);
MoveInfo.WaitList.Add(WaitResultInfo.WaitAgvAction((int)ClientAction.Arrive));
}
else
{
SO_03_ToBagPosition();
}
}
else if (MoveInfo.MoveStep == StoreMoveStep.SO_03_ToPosition)
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_04_ToPos);
InOutStoreLog("出库 " + MoveInfo.SLog + ":叉子进入库位中, 进出轴至P3[" + moveP.InOut_P3 + "] ");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P3, Config.InOutAxis_P3_Speed);
}
else if (MoveInfo.MoveStep == StoreMoveStep.SO_04_ToPos)
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_05_GetReel);
InOutStoreLog("出库 " + MoveInfo.SLog + ": 拿起物品,升降轴至P6[" + moveP.UpDown_P6 + "],压紧轴到压紧点P2 :" + moveP.ComPress_P2);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P6, Config.UpDownAxis_P6_Speed);
ACAxisMove(Config.Comp_Axis, moveP.ComPress_P2, Config.CompAxis_P2_Speed);
//MoveInfo.WaitList.Add(WaitResultInfo.WaitComAxis(Config.Comp_Axis, Config.CompAxis_P4_Position, Config.CompAxis_P4_Speed));
//Config.Comp_Axis.TargetPosition = Config.CompAxis_P4_Position;
//ACServerManager.AbsMove(Config.Comp_Axis.DeviceName, Config.Comp_Axis.GetAxisValue(), Config.CompAxis_P4_Position, Config.CompAxis_P4_Speed);
//ComAxisStartCheck();
}
else if (MoveInfo.MoveStep == StoreMoveStep.SO_05_GetReel)
{
// SO_06_StartCompress();
//}
//else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_06_StartCompress))
//{
// MoveInfo.NextMoveStep(StoreMoveStep.SO_07_ComDownMove);
// int currPosition = ACServerManager.GetActualtPosition(Config.Comp_Axis);
// int targetP = currPosition + Config.CompAxis_Down_Position;
// InOutStoreLog("出库 " + MoveInfo.SLog + ": 再向下压紧 [" + Config.CompAxis_Down_Position + "] 目标 [" + targetP + "] ");
// ACAxisMove(Config.Comp_Axis, targetP, Config.CompAxis_P1_Speed);
//}
//else if (MoveInfo.MoveStep == StoreMoveStep.SO_07_ComDownMove)
//{
MoveInfo.NextMoveStep(StoreMoveStep.SO_08_InoutBack);
InOutStoreLog("出库 " + MoveInfo.SLog + ":进出轴至待机点P1[" + moveP.InOut_P1 + "] ");
InOutBackToP1(moveP.InOut_P1);
//把库位的物品放到取到叉子上之后是出仓完成
string posId = MoveInfo.MoveParam != null ? MoveInfo.MoveParam.PosID : "";
lastPosId = posId;
lastPosIdStatus = StoreStatus.OutStoreBoxEnd;
storeStatus = StoreStatus.OutStoreBoxEnd;
}
else if (MoveInfo.MoveStep == StoreMoveStep.SO_08_InoutBack)
{
IsIgnoreComSig = false;
CompressSigTimeOut = false;
//LogUtil.info("出库步骤 SO_07_CheckComSig :IsIgnoreComSig = false, CompressSigTimeOut = false");
IO_VALUE iov = IOValue(IO_Type.Compress_Check);
if (MoveInfo.MoveParam.urgentReel)
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_15_ToUrgentDoor);
InOutStoreLog("紧急料 " + MoveInfo.SLog + ",升降轴到升降门口高点P12,旋转轴到升降门口P11");
ACAxisMove(Config.UpDown_Axis, MoveInfo.MoveParam.MoveP.UpDown_P12, Config.UpDownAxis_P1_Speed);
ACAxisMove(Config.Middle_Axis, MoveInfo.MoveParam.MoveP.Middle_P11, Config.MiddleAxis_P1_Speed);
}
else
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_10_ToShelfPosition);
InOutStoreLog("出库 " + MoveInfo.SLog + ":叉子已到P1,Compress_Check=" + iov + ",走到料架位置,旋转轴至P101[" + moveP.Middle_P101 + "],升降轴至P102[" + moveP.UpDown_HP102 + "] ");
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_HP102, Config.UpDownAxis_P102_Speed);
ACAxisMove(Config.Middle_Axis, moveP.Middle_P101, Config.MiddleAxis_P101_Speed);
}
//MoveInfo.NextMoveStep(StoreMoveStep.SO_09_CheckComSig);
//InOutStoreLog("出库 " + MoveInfo.SLog + ":等待料叉压紧信号 ");
//MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Compress_Check, IO_VALUE.HIGH));
}
else if (MoveInfo.MoveStep == StoreMoveStep.SO_09_CheckComSig)
{
if (IOValue(IO_Type.Compress_Check).Equals(IO_VALUE.HIGH) || IsIgnoreComSig)
{
IsIgnoreComSig = false;
CompressSigTimeOut = false;
LogUtil.info("出库步骤 SO_07_CheckComSig :IsIgnoreComSig = false, CompressSigTimeOut = false");
MoveInfo.NextMoveStep(StoreMoveStep.SO_10_ToShelfPosition);
InOutStoreLog("出库 " + MoveInfo.SLog + ":走到料架位置,旋转轴至P101,升降轴至P102 ");
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_HP102, Config.UpDownAxis_P102_Speed);
ACAxisMove(Config.Middle_Axis, moveP.Middle_P101, Config.MiddleAxis_P101_Speed);
}
}
else if (MoveInfo.MoveStep == StoreMoveStep.SO_10_ToShelfPosition)
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_11_ToShelf);
InOutStoreLog("出库 " + MoveInfo.SLog + ":叉子进出料口,进出轴至P101");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P101, Config.InOutAxis_P101_Speed);
}
else if (MoveInfo.MoveStep == StoreMoveStep.SO_11_ToShelf)
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_12_PutReel);
InOutStoreLog("出库 " + MoveInfo.SLog + ":放下物品,压紧轴到P1,升降轴至P101,清空 taskData=null ");
ACAxisMove(Config.Comp_Axis, moveP.ComPress_P1, Config.CompAxis_P1_Speed);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_LP101, Config.UpDownAxis_P101_Speed);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
taskData = null;
Task.Factory.StartNew(delegate
{
int posLoc = StoreManager.GetShelfPosIndex(MoveInfo.MoveParam.ShelfPosID, ShelfPosList);
//分盘料和紧急料发PutFinished
if (MoveInfo.MoveParam.cutReel || MoveInfo.MoveParam.urgentReel)
{
string msg = StoreManager.afterPutCut(Name, CurrShelfID, MoveInfo.MoveParam.WareCode, CID, posLoc, out taskData);
if (String.IsNullOrEmpty(msg).Equals(false))
{
LogUtil.error(Name + "[" + MoveInfo.MoveParam.WareCode + "] [" + CurrShelfID + "_" + GetLastRfid() + "] [" + posLoc + "] afterPutCut 结果:" + msg);
}
}
else
{
int newTaskCount = 0;
string msg = StoreManager.UpdateTrayLoc(Name, MoveInfo.MoveParam.WareCode, CurrShelfID + "@" + posLoc.ToString(), out newTaskCount);
if (String.IsNullOrEmpty(msg).Equals(false))
{
LogUtil.error(Name + "[" + MoveInfo.MoveParam.WareCode + "] [" + CurrShelfID + "_" + GetLastRfid() + "] [" + posLoc + "] UpdateTrayLoc 结果:" + msg);
}
if (newTaskCount > MoveInfo.MoveParam.taskCount)
{
InOutStoreLog("UpdateTrayLoc 返回 newTaskCount=" + newTaskCount + ",原有 taskCount=" + MoveInfo.MoveParam.taskCount + ",使用新数据");
MoveInfo.MoveParam.taskCount = newTaskCount;
}
}
});
}
else if (MoveInfo.MoveStep == StoreMoveStep.SO_12_PutReel)
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_13_InoutBack);
InOutStoreLog("出库 " + MoveInfo.SLog + ":叉子从出料口返回, 进出轴到P1 ");
InOutBackToP1(moveP.InOut_P1);
}
else if (MoveInfo.MoveStep == StoreMoveStep.SO_13_InoutBack)
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_14_GoBack);
InOutStoreLog("出库 " + MoveInfo.SLog + ": 升降轴返回,升降轴到P1,顶升下降");
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P1, Config.UpDownAxis_P1_Speed);
//发送消息给流水线
// SendOutStoreEnd(MoveInfo);
CylinderMove(MoveInfo, IO_Type.TopCylinder_Up, IO_Type.TopCylinder_Down);
}
else if (MoveInfo.MoveStep == StoreMoveStep.SO_14_GoBack)
{
//判断是否需要送出料架
bool isNeedSend = false;
string logName = "【" + CurrShelfID + "_" + GetLastRfid() + "】";
//只有rfid不为空才需要送出料架
if (String.IsNullOrEmpty(MoveInfo.MoveParam.rfid))
{
InOutStoreLog("出库完成,未设置rfid,不需要送出料架");
isNeedSend = false;
}
else if (MoveInfo.MoveParam.cutReel)
{
if (taskData != null && taskData.cutPackageTask <= 0)
{
InOutStoreLog(logName + "分盘料出库完成,cutPackageTask=" + taskData.cutPackageTask + ",送出料架");
isNeedSend = true;
}
else if (taskData == null)
{
InOutStoreLog(logName + "分盘料出库完成,taskData=null,送出料架");
isNeedSend = true;
}
}
else if (MoveInfo.MoveParam.urgentReel)
{
if (taskData != null && taskData.urgentPackageTask <= 0)
{
InOutStoreLog(logName + "紧急料出库完成,urgentPackageTask=" + taskData.urgentPackageTask + ",送出料架");
isNeedSend = true;
}
else if (taskData == null)
{
InOutStoreLog(logName + "紧急料出库完成,taskData=null,送出料架");
isNeedSend = true;
}
}
else if (MoveInfo.MoveParam.taskCount <= 0)
{
InOutStoreLog(logName + "出库完成,taskCount=" + MoveInfo.MoveParam.taskCount + " 送出料架");
isNeedSend = true;
}
if (isNeedSend)
{
StartShelfOut();
}
else
{
TimeSpan span = DateTime.Now - startOutStoreTime;
string posId = MoveInfo.MoveParam != null ? MoveInfo.MoveParam.PosID : "";
storeStatus = StoreStatus.StoreOnline;
LogInfo(" 【" + posId + "】 " + logName + " 出库结束,耗时【" + FormUtil.GetSpanStr(span) + "】!");
if (!String.IsNullOrEmpty(MoveInfo.MoveParam.rfid))
{
if (StoreManager.Store.AutoShelfInstore)
{
LogInfo(" 料架" + logName + "还有出库任务,设置 AutoShelfInstore = false");
ConfigAppSettings.SaveValue(Setting_Init.AutoShelfInstore, 0);
StoreManager.Store.AutoShelfInstore = false;
}
}
MoveEndToRuningStatus();
AutoInout.InOutEndProcess(this, StoreMoveType.OutStore);
}
}
#endregion
else if (MoveInfo.MoveStep <= StoreMoveStep.SO_01_InoutBack)
{
ShelfEnterProcess();
}
else if (MoveInfo.MoveStep >= StoreMoveStep.BS_01_TopDown)
{
ShelfOutProcess();
}
else
{
LogUtil.error(Name + " 出库处理,moveStatus=" + MoveInfo.MoveStep + ",没有对应的处理!");
}
}
//private void SO_06_StartCompress()
//{
// //如果检测信号亮或者当前位置大于P4,直接走相对位置
// if (IOValue(IO_Type.Compress_Check).Equals(IO_VALUE.HIGH) || (MoveInfo.MoveParam.MoveP.ComPress_P2 >= Config.CompAxis_P4_Position))
// {
// MoveInfo.NextMoveStep(StoreMoveStep.SO_07_ComDownMove);
// int currPosition = ACServerManager.GetActualtPosition(Config.Comp_Axis);
// int targetP = currPosition + Config.CompAxis_Down_Position;
// InOutStoreLog("出库 " + MoveInfo.SLog + ": 再向下压紧 [" + Config.CompAxis_Down_Position + "] 目标 [" + targetP + "] ");
// ACAxisMove(Config.Comp_Axis, targetP, Config.CompAxis_P1_Speed);
// }
// else
// {
// MoveInfo.NextMoveStep(StoreMoveStep.SO_06_StartCompress);
// InOutStoreLog("出库 " + MoveInfo.SLog + ":压紧轴开始缓慢压紧到P4 :" + Config.CompAxis_P4_Position);
// MoveInfo.WaitList.Add(WaitResultInfo.WaitComAxis(Config.Comp_Axis, Config.CompAxis_P4_Position, Config.CompAxis_P4_Speed));
// Config.Comp_Axis.TargetPosition = Config.CompAxis_P4_Position;
// ACServerManager.AbsMove(Config.Comp_Axis.DeviceName, Config.Comp_Axis.GetAxisValue(), Config.CompAxis_P4_Position, Config.CompAxis_P4_Speed);
// ComAxisStartCheck();
// }
//}
#endregion
}
}
using Asa;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
public partial class AC_BOX_Bean
{
#region 料架进出料仓处理:出入库模块共用
private void BI_04_WaitTakeSingle(string moveName)
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_04_WaitTakeSingle);
InOutStoreLog(moveName + MoveInfo.SLog + " 线体正转,等待LineIn_Check=Low, 信号LineTake_Check=High");
LineRun();
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LineIn_Check, IO_VALUE.LOW));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LineTake_Check, IO_VALUE.HIGH));
}
private void ShelfEnterProcess()
{
string mark = GetMarkInfo();
string moveName = "入库料架[" + CurrShelfID + "]";
bool instoreShelf = true;
if (MoveInfo.MoveType.Equals(StoreMoveType.OutStore))
{
instoreShelf = false;
moveName = "出库料架[" + CurrShelfID + "][" + mark + "]";
}
if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_00_ReadyShelf))
{
if (IOValue(IO_Type.LineIn_Check).Equals(IO_VALUE.HIGH))
{
BI_04_WaitTakeSingle(moveName);
}
else if (IOValue(IO_Type.LineTake_Check).Equals(IO_VALUE.HIGH))
{
BI_04_WaitTakeSingle(moveName);
}
else
{
// MoveInfo.ShelfPositionList = new List<string>(ShelfPosList);
InOutStoreLog(moveName + MoveInfo.SLog + " agv已到达,打开入料口移门");
MoveInfo.NextMoveStep(StoreMoveStep.BI_01_DoorOpen);
DoorBean.StartOpen(MoveInfo);
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_01_DoorOpen))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_03_LineRun);
InOutStoreLog(moveName + MoveInfo.SLog + "调用AgvClient.MayEnter,线体正转,等待LineIn_Check 或LineTake_Check 信号");
AgvClient.SetStatus(Config.AgvNodeName, mark, "", ClientAction.MayEnter, ClientLevel.High, true);
LineRun();
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LineIn_Check, IO_VALUE.HIGH));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LineTake_Check, IO_VALUE.HIGH));
MoveInfo.OneWaitCanEndStep = true;
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_03_LineRun))
{
BI_04_WaitTakeSingle(moveName);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_04_WaitTakeSingle))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_05_LineStop);
InOutStoreLog(moveName + MoveInfo.SLog + "调用Agv " + Config.AgvNodeName + " FinishEnter,取料位检测到信号,继续转动");
LineRun();
AgvClient.SetStatus(Config.AgvNodeName, mark, "", ClientAction.FinishEnter, ClientLevel.High, true);
if (!instoreShelf)
{
if (MoveInfo.MoveParam.ShelfPosID.Equals(""))
{
MoveInfo.MoveParam.UpdateShelfPosId(ShelfPosList[0]);
InOutStoreLog("出库 " + MoveInfo.SLog + ": ShelfPosID未设置,默认ShelfPosID=" + MoveInfo.MoveParam.ShelfPosID);
}
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_05_LineStop))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_06_DoorClose);
InOutStoreLog(moveName + MoveInfo.SLog + "入料口移门关闭 ");
DoorBean.StartClose(MoveInfo);
if (!instoreShelf)
{
InOutStoreLog("出库 " + MoveInfo.SLog + ": 走到库位,压紧轴至P3(压紧前点) ,旋转轴至P2(库位点),升降轴至P5(库位出库前点)");
ACAxisMove(Config.Comp_Axis, MoveInfo.MoveParam.MoveP.ComPress_P3, Config.CompAxis_P3_Speed);
ACAxisMove(Config.Middle_Axis, MoveInfo.MoveParam.MoveP.Middle_P2, Config.MiddleAxis_P2_Speed);
ACAxisMove(Config.UpDown_Axis, MoveInfo.MoveParam.MoveP.UpDown_P5, Config.UpDownAxis_P5_Speed);
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_06_DoorClose))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_07_LineRun);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(7000));
InOutStoreLog(moveName + MoveInfo.SLog + "继续转动 7000");
LineRun();
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_07_LineRun))
{
LineStop();
UpdateShelfId();
//如果未读到料架号,将料架送出
if (CurrShelfID.EndsWith("00") && MoveInfo.MoveType.Equals(StoreMoveType.OutStore))
{
LogInfo(" 执行出库【" + MoveInfo.MoveParam.ToStr() + "】失败,料架号[" + CurrShelfID + "]无效,加入等待队列");
waitOutStoreList.Enqueue(MoveInfo.MoveParam.NewParam());
LogUtil.error(Name + "出库 料架号[" + CurrShelfID + "]无效,送出料架,稍后重新出库");
MoveInfo.MoveParam.rfid = CurrShelfID;
//送出料架,并且记录出库信息,等会重新出库
StartShelfOut();
return;
}
//如果该料架为入库料架,此时有出库任务,执行入库任务
if (StoreManager.CheckShelfInfo(CurrShelfID) && MoveInfo.MoveType.Equals(StoreMoveType.OutStore))
{
LogInfo(Name + "出库"+ mark + "->入库 料架号[" + CurrShelfID + "]为入库料架,进行入库");
MoveInfo.NewMove(StoreMoveType.InStore, new InOutParam());
MoveInfo.MoveParam.MoveP = new LineMoveP(Config);
MoveInfo.ShelfPositionList = new List<string>(ShelfPosList);
mark = "0";
instoreShelf = true;
}
MoveInfo.NextMoveStep(StoreMoveStep.BI_08_LocationUp);
InOutStoreLog(moveName + MoveInfo.SLog + "停止线体,读取料架" + CurrShelfID + ",设置" + Config.AgvNodeName + "=None");
AgvClient.SetStatus(Config.AgvNodeName, mark);
// CylinderMove(MoveInfo, IO_Type.LocationCylinder_Down, IO_Type.LocationCylinder_Up);
if (!instoreShelf)
{
if (MoveInfo.MoveParam.ShelfPosID.Equals(""))
{
MoveInfo.MoveParam.UpdateShelfPosId(ShelfPosList[0]);
InOutStoreLog("出库 " + MoveInfo.SLog + ": ShelfPosID未设置,默认ShelfPosID=" + MoveInfo.MoveParam.ShelfPosID);
}
// LastRfidID = MoveInfo.MoveParam.rfid;
LastOutParam = MoveInfo.MoveParam;
InOutStoreLog("出库 " + MoveInfo.SLog + ":叉子进入库位中, 进出轴至P3(库位取放料点) ");
ACAxisMove(Config.InOut_Axis, MoveInfo.MoveParam.MoveP.InOut_P3, Config.InOutAxis_P3_Speed);
}
else
{
LastOutParam = new InOutParam();
// LastRfidID = "";
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_08_LocationUp))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_09_TopCylinderUp);
InOutStoreLog(moveName + MoveInfo.SLog + "" + CurrShelfID + "顶升上升");
CylinderMove(MoveInfo, IO_Type.TopCylinder_Down, IO_Type.TopCylinder_Up);
if (!instoreShelf)
{
InOutStoreLog("出库 " + MoveInfo.SLog + ": 拿起物品,升降轴至P6["+ MoveInfo.MoveParam.MoveP.UpDown_P6 + "],压紧轴到压紧点P2 :" + MoveInfo.MoveParam.MoveP.ComPress_P2);
ACAxisMove(Config.Comp_Axis, MoveInfo.MoveParam.MoveP.ComPress_P2, Config.CompAxis_P2_Speed);
ACAxisMove(Config.UpDown_Axis, MoveInfo.MoveParam.MoveP.UpDown_P6, Config.UpDownAxis_P6_Speed);
//MoveInfo.WaitList.Add(WaitResultInfo.WaitComAxis(Config.Comp_Axis, Config.CompAxis_P4_Position, Config.CompAxis_P4_Speed));
//Config.Comp_Axis.TargetPosition = Config.CompAxis_P4_Position;
//ACServerManager.AbsMove(Config.Comp_Axis.DeviceName, Config.Comp_Axis.GetAxisValue(), Config.CompAxis_P4_Position, Config.CompAxis_P4_Speed);
//ComAxisStartCheck();
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_09_TopCylinderUp))
{
if (instoreShelf)
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_10_StartGetTray);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime((int)TimeSpan.FromMinutes(75).TotalMilliseconds));
//获取料架的锁定状态
bool lockState = StoreManager.GetShelfLockInfo(Name, CID, CurrShelfID, out MoveInfo.shelfLockDatas);
if (lockState && MoveInfo.shelfLockDatas != null)
{
MoveInfo.IsShelfLocked = true;
if (MoveInfo.shelfLockDatas.Count.Equals(0))
InOutStoreLog(moveName + MoveInfo.SLog + "该锁定料架上的料盘不属于该料仓,即将送出锁定料架");
else
InOutStoreLog(moveName + MoveInfo.SLog + "开始到料架指定位置取料盘 ");
}
else
{
MoveInfo.IsShelfLocked = false;
InOutStoreLog(moveName + MoveInfo.SLog + "开始循环料架取料盘 ");
}
MoveInfo.EndStepWait();
}
else
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_08_InoutBack);
InOutStoreLog("出库 " + MoveInfo.SLog + ":进出轴返回P1["+ MoveInfo.MoveParam.MoveP.InOut_P1 + "] ");
InOutBackToP1(MoveInfo.MoveParam.MoveP.InOut_P1);
//把库位的物品放到取到叉子上之后是出仓完成
string posId = MoveInfo.MoveParam != null ? MoveInfo.MoveParam.PosID : "";
lastPosId = posId;
lastPosIdStatus = StoreStatus.OutStoreBoxEnd;
storeStatus = StoreStatus.OutStoreBoxEnd;
//SO_06_StartCompress();
}
}
}
private void StartShelfOut()
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_01_TopDown);
if (MoveInfo.MoveType.Equals(StoreMoveType.OutStore))
{
string mark = GetMarkInfo();
InOutStoreLog("送出[" + CurrShelfID + "][" + mark + "]:顶升下降,调用 NeedLeave[" + mark + "][" + CurrShelfID + "] ");
AgvClient.NeedLeave(Config.AgvNodeName, mark, CurrShelfID);
}
else
{
InOutStoreLog("送出空料架[" + CurrShelfID + "]:顶升下降,调用 NeedLeave[0][" + CurrShelfID + "],clearPutInRfid[" + CurrShelfID + "]");
AgvClient.NeedLeave(Config.AgvNodeName, "0", CurrShelfID);
StoreManager.clearPutInRfid(Name, CurrShelfID);
ACAxisMove(Config.UpDown_Axis, Config.UpDownAxis_P1, Config.UpDownAxis_P1_Speed);
}
CylinderMove(MoveInfo, IO_Type.TopCylinder_Up, IO_Type.TopCylinder_Down);
}
private string GetMarkInfo(string defualtMark = "0")
{
string mark = defualtMark;
//如果料架号是空,需要送到VMI线
if (MoveInfo.MoveType.Equals(StoreMoveType.OutStore))
{
if (CurrShelfID.EndsWith("00"))
{
mark = defualtMark;
}
//包装料会发往分盘区, 紧急料区, 包装线区
// urgentReel 这个为true是紧急料 出到紧急料区
// cutReel 为true是分盘料,AGV会拉到到分盘区
//料串会发到分盘区和紧急料区
//两个都为false 包装料默认拉到包装线体, 料串默认拉到紧急料区
else if (MoveInfo.MoveParam.urgentReel)
{
//紧急料,需要到紧急料区
mark = MoveInfo.MoveParam.rfid + ",urgent";
}
else if (MoveInfo.MoveParam.cutReel)
{
//cutReel 为true是分盘料,AGV会拉到到分盘区
mark = MoveInfo.MoveParam.rfid + ",cut";
}
else
{
mark = MoveInfo.MoveParam.rfid + ",pack";
}
}
return mark;
}
private void ShelfOutProcess()
{
string mark = GetMarkInfo();
string moveName = "送出空料架[" + CurrShelfID + "]";
if (MoveInfo.MoveType.Equals(StoreMoveType.OutStore))
{
moveName = "送出[" + CurrShelfID + "][" + mark + "]";
}
// LogCPU();
if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_01_TopDown))
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_02_LocatinDown);
InOutStoreLog(moveName + MoveInfo.SLog + " :定位气缸下降");
// CylinderMove(MoveInfo, IO_Type.LocationCylinder_Up, IO_Type.LocationCylinder_Down);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_02_LocatinDown))
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_03_WaitEmptyAgv);
MoveInfo.TimeOutSeconds = 600;
//MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(30000));
//等待agv到达
MoveInfo.WaitList.Add(WaitResultInfo.WaitAgvAction((int)ClientAction.Arrive));
InOutStoreLog(moveName + MoveInfo.SLog + ":再次调用 NeedLeave[" + mark + "][" + CurrShelfID + "],等待Agv " + Config.AgvNodeName + " Arrive ,最多等待1200秒");
AgvClient.SetStatus(Config.AgvNodeName, mark, CurrShelfID, ClientAction.NeedLeave, ClientLevel.High, true);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_03_WaitEmptyAgv))
{
//agv到达
if (AgvClient.GetAction(Config.AgvNodeName).Equals(ClientAction.Arrive))
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_04_DoorOpen);
InOutStoreLog(moveName + MoveInfo.SLog + ":agv到达,打开入料口移门");
DoorBean.StartOpen(MoveInfo);
}
else
{
//如果料架已被拉出,也算结束
if (IOValue(IO_Type.LineIn_Check).Equals(IO_VALUE.LOW) && IOValue(IO_Type.LineTake_Check).Equals(IO_VALUE.LOW))
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_06_LineBackRun);
AgvClient.SetToNone(Config.AgvNodeName);
//如果agv未到达,直接结束
MoveEndToRuningStatus();
//EmprtShelfList = new ConcurrentQueue<string>();
InOutStoreLog(moveName + MoveInfo.SLog + ":等待Agv " + Config.AgvNodeName + " Arrive超时,检测不到料架信号,认为料架已离开,出库结束,设置" + Config.AgvNodeName + "=None");
}
else
{
TimeSpan span = DateTime.Now - MoveInfo.LastSetpTime;
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime((int)span.TotalMilliseconds + 30000));
InOutStoreLog(moveName + MoveInfo.SLog + ":等待Agv " + Config.AgvNodeName + " Arrive超时,再等待30秒");
}
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_04_DoorOpen))
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_05_WaitReady);
MoveInfo.TimeOutSeconds = 120;
InOutStoreLog(moveName + MoveInfo.SLog + ":移门已打开,调用 MayLeave [" + mark + "][" + CurrShelfID + "],等待agv " + Config.AgvNodeName + " Ready");
AgvClient.SetStatus(Config.AgvNodeName, mark, CurrShelfID, ClientAction.MayLeave, ClientLevel.High, true);
//等待agv到达
MoveInfo.WaitList.Add(WaitResultInfo.WaitAgvAction((int)ClientAction.Ready));
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_05_WaitReady))
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_06_LineBackRun);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
InOutStoreLog(moveName + MoveInfo.SLog + ":收到agv " + Config.AgvNodeName + " Ready ,线体开始反转");
LineBackRun();
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_06_LineBackRun))
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_07_WaitShelfOut);
InOutStoreLog(moveName + MoveInfo.SLog + ":等待取料工位无信号 ");
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LineTake_Check, IO_VALUE.LOW));
// MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LineIn_Check, IO_VALUE.HIGH));
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_07_WaitShelfOut))
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_08_WaitLineIn);
InOutStoreLog(moveName + MoveInfo.SLog + ":等待 入料口有信号,最多等待30秒");
// MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LineTake_Check, IO_VALUE.LOW));
MoveInfo.OneWaitCanEndStep = true;
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(30000));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LineIn_Check, IO_VALUE.HIGH));
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_08_WaitLineIn))
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_09_WaitTime);
InOutStoreLog(moveName + MoveInfo.SLog + ":再转动1000 , 等待入料口无信号,清理RFID");
RFIDManager.ReadRFID(Config.RFID_IP, true);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LineIn_Check, IO_VALUE.LOW));
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_09_WaitTime))
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_10_WaitAGVLeave);
MoveInfo.TimeOutSeconds = 180;
InOutStoreLog(moveName + MoveInfo.SLog + ":等待DoorClose事件,最多等待180000 ");
MoveInfo.OneWaitCanEndStep = true;
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(180000));
MoveInfo.WaitList.Add(WaitResultInfo.WaitDoorClose());
//MoveInfo.WaitList.Add(WaitResultInfo.WaitAgvAction(action.FinishOut));
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_10_WaitAGVLeave))
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_11_CloseDoor);
InOutStoreLog(moveName + MoveInfo.SLog + ":停止线体转动,关闭仓门 ,发送FinishLeave ,等待最少5000");
AgvClient.SetStatus(Config.AgvNodeName, mark, CurrShelfID, ClientAction.FinishLeave, ClientLevel.High, true);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(5000));
LineStop();
DoorBean.StartClose(MoveInfo);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_11_CloseDoor))
{
//结束
MoveEndToRuningStatus();
AgvClient.SetStatus(Config.AgvNodeName);
//EmprtShelfList = new ConcurrentQueue<string>();
InOutStoreLog(moveName + MoveInfo.SLog + ":料架" + CurrShelfID + "已离开 ,设置" + Config.AgvNodeName + "=None,清理rfid");
RFIDManager.ReadRFID(Config.RFID_IP, true);
CurrShelfID = "";
LastOutParam = new InOutParam();
//LastRfidID = "";
}
}
#endregion
#region AGV
internal bool ProcessAGVAction(string name, string rfid, ClientAction action)
{
string logN = name + "收到调度" + name + "=" + action + ",RFID[" + rfid + "]";
//Arrive收到后打开门
if (!action.Equals(ClientAction.Arrive))
{
LogUtil.info(Name + logN + " ,未找到相关处理");
return false;
}
//出库处理中不处理
if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_03_WaitEmptyAgv))
{
if (!rfid.Equals(""))
{
string mark = GetMarkInfo();
LogUtil.error(Name + logN + " 当前 BS_03_WaitEmptyAgv,RFID[" + rfid + "]不是空车,不处理agv,重发 NeedLeave [" + mark + "][" + CurrShelfID + "]");
Task.Factory.StartNew(new Action(()=> {
AgvClient.SetStatus(Config.AgvNodeName, mark, CurrShelfID, ClientAction.MayNot, ClientLevel.High, true);
Thread.Sleep(10000);
AgvClient.SetStatus(Config.AgvNodeName, mark, CurrShelfID, ClientAction.NeedLeave, ClientLevel.High, true);
}));
return false;
}
//等待空车到达
LogUtil.info(Name + logN + ",当前 BS_03_WaitEmptyAgv,正在等待料架到达");
MoveInfo.NextMoveStep(StoreMoveStep.BS_04_DoorOpen);
InOutStoreLog("送出料架等待空车" + MoveInfo.SLog + ":agv到达,打开入料口移门");
DoorBean.StartOpen(MoveInfo);
return true;
}
else if (MoveInfo.MoveType.Equals(StoreMoveType.OutStore) && MoveInfo.MoveStep.Equals(StoreMoveStep.BI_00_ReadyShelf))
{
if (rfid.Equals(""))
{
string mark = GetMarkInfo();
LogUtil.error(Name + logN + " 当前出库中 BI_00_ReadyShelf,RFID无效,不处理agv,重发 NeedEnter [" + mark + "][" + MoveInfo.MoveParam.rfid + "]");
Task.Factory.StartNew(new Action(() => {
AgvClient.SetStatus(Config.AgvNodeName, mark, CurrShelfID, ClientAction.MayNot, ClientLevel.High, true);
Thread.Sleep(10000);
AgvClient.SetStatus(Config.AgvNodeName, mark, MoveInfo.MoveParam.rfid, ClientAction.NeedEnter, ClientLevel.High, true);
}));
return false;
}
//出库等待料架到达
LogUtil.info(Name + logN + ",当前出库中 BI_00_ReadyShelf,正在等待料架到达");
MoveInfo.NextMoveStep(StoreMoveStep.BI_01_DoorOpen);
InOutStoreLog("出库等待料架" + MoveInfo.SLog + " agv已到达,打开入料口移门");
DoorBean.StartOpen(MoveInfo);
return true;
}
else if (storeRunStatus.Equals(StoreRunStatus.Runing) &&
MoveInfo.MoveType.Equals(StoreMoveType.None) &&
IOValue(IO_Type.LineTake_Check).Equals(IO_VALUE.LOW))
{
//agv到达,开始处理
if (rfid.Equals(""))
{
LogUtil.error(Name + logN + " ,RFID无效,不需要入库处理");
return false;
}
LogUtil.info(Name + logN + " ,检测到料架,开始料架入库");
StartShelfInStore();
return true;
}
else
{
LogUtil.error(Name + logN + " ,[" + MoveInfo.MoveType + "][" + MoveInfo.MoveStep + "]未找到相关处理");
}
return false;
}
#endregion
#region 与服务器通信定时器,每1秒向服务器通知一次状态,同时执行出库操作
private string CodeMsg = "";
private bool isInProcess = false;
private DateTime lastConTime = DateTime.Now;
public void server_connect_timer_Tick(object sender, EventArgs e)
{
if (isInProcess)
{
TimeSpan span = DateTime.Now - lastConTime;
if (span.TotalSeconds < 60)
{
return;
}
}
isInProcess = true;
lastConTime = DateTime.Now;
try
{
////HumitureController.QueryData();
//humBean.HumidityProcess(this);
//if (StoreManager.IsConnectServer)
//{
// SendLineStatus();
//}
}
catch (Exception ex)
{
LogUtil.error(Name + "定时SendLineStatus出错:" + ex.ToString());
}
finally
{
isInProcess = false;
}
}
/// <summary>
/// 获取整个料仓的状态
/// </summary>
public Operation getLineBoxStatus()
{
//构建发送给服务器的对象
Operation lineOperation = new Operation();
lineOperation.msg = "";
lineOperation.alarmList = new List<AlarmInfo>();
lineOperation.cid = CID;
lineOperation.seq = ConfigAppSettings.nextSeq();
lineOperation.status = 1;
if (WarnMsg != "")
{
lineOperation.status = (int)StoreStatus.Warning;
lineOperation.msg = WarnMsg;
}
lineOperation.status = (int)StoreStatus.StoreOnline;
BoxStatus boxStatus = new BoxStatus();
boxStatus.boxId = 1;
boxStatus.msg = WarnMsg;
lineOperation.msg = WarnMsg;
if (WarnMsg.Equals(""))
{
boxStatus.msg = CodeMsg;
lineOperation.msg = CodeMsg;
}
CodeMsg = "";
//WarnMsg = "";
//状态
boxStatus.status = (int)storeStatus;
if (IsDebug)
{
boxStatus.status = (int)StoreStatus.Debugging;
}
else if (storeStatus.Equals(StoreStatus.OutStoreBoxEnd) || storeStatus.Equals(StoreStatus.InStoreEnd))
{
boxStatus.data.Add(ParamDefine.posId, lastPosId);
}
else if (!lastPosId.Equals(""))
{
boxStatus.data.Add(ParamDefine.posId, lastPosId);
boxStatus.status = (int)lastPosIdStatus;
if (lastPosId != "")
{
LogUtil.info("给服务器发送出入库完成消息:" + Name + ",status【" + lastPosIdStatus + "】posId【" + lastPosId + "】");
}
lastPosId = "";
}
//温湿度
//ASTemperateParam param = HumitureServer.GetTemperateParam(Config.Temperate_Serveraddress);
HumitureParam param = humBean.LastData;
if (param != null)
{
boxStatus.humidity = param.Humidity.ToString();
boxStatus.temperature = param.Temperate.ToString();
}
lineOperation.boxStatus.Add(1, boxStatus);
if (!alarmType.Equals(StoreAlarmType.None))
{
lineOperation.alarmList.Add(alarmInfo);
}
return lineOperation;
}
public void SendLineStatus()
{
DateTime time = DateTime.Now;
//构建发送给服务器的对象
Operation lineOperation = getLineBoxStatus();
//如果还没湿度范围,先获取
if (humBean.NeedGetTem())
{
lineOperation.op = 5;
LogUtil.error(Name + "没有湿度预警范围,需要从服务器获取,发送OP=" + lineOperation.op, DeviceID + 105);
}
string server = ConfigAppSettings.GetValue(Setting_Init.http_server);
Operation resultOperation = HttpHelper.PostJson(StoreManager.GetPostApi(server), lineOperation, false);
//发送状态信息到服务器
if (resultOperation == null || (resultOperation.op <= 0))
{
//判断服务端是否返回出库操作
return;
}
if (resultOperation.op.Equals(1))
{
// ReviceInStoreProcess("", resultOperation);
}
else if (resultOperation.op.Equals(2))
{
ReviceOutStoreProcess(resultOperation);
}
else if (resultOperation.op.Equals(5))
{
humBean.ProcessHumidityCMD(resultOperation);
}
else
{
LogUtil.error("收到服务器命令:op=" + resultOperation.op + ",未找到对应处理");
}
TimeSpan span = DateTime.Now - time;
if (span.TotalMilliseconds > 10)
{
LogUtil.info(Name + "执行TimerProcess 共处理了【" + span.TotalMilliseconds + "】毫秒");
}
}
private void ReviceOutStoreProcess(Operation resultOperation)
{
DateTime time = DateTime.Now;
Dictionary<string, string> data = resultOperation.data;
if (data != null && data.ContainsKey(ParamDefine.posId)
&& data.ContainsKey(ParamDefine.plateH) && data.ContainsKey(ParamDefine.plateW))
{
char splitChar = '|';
string[] posIdArray = data[ParamDefine.posId].Split(splitChar);
string[] plateWArray = data[ParamDefine.plateW].Split(splitChar);
string[] plateHArray = data[ParamDefine.plateH].Split(splitChar);
bool urgentReel = FormUtil.GetBoolData(data, ParamDefine.urgentReel);
bool cutReel = FormUtil.GetBoolData(data, ParamDefine.cutReel);
bool smallReel = FormUtil.GetBoolData(data, ParamDefine.smallReel);
string rfid = data.ContainsKey(ParamDefine.rfid) ? data[ParamDefine.rfid] : "";
int rfidLoc = FormUtil.GetIntData(data, ParamDefine.rfidLoc);
string barcode = data.ContainsKey(ParamDefine.barcode) ? data[ParamDefine.barcode] : "";
string realRfid = data.ContainsKey(ParamDefine.realRfid) ? data[ParamDefine.realRfid] : "";
int taskCount = FormUtil.GetIntData(data, ParamDefine.taskCount, 0);
//urgentReel: true 表示紧急料,需要出到料串上
//cutReel: true 表示分盘料,需要出到料串上
//smallReel: true 小料(7x8),放置到小料架上
//rfid: 分配的料架RFID
//rfidLoc: 料架的架位,值为 - 1时,可以自由分配皮带线, 小料时,架位为1 - 46优先走1 / 2号皮带线,47 - 92优先走3 / 4号皮带线, 70,71,72时只能分配到3 / 4号皮带线; 大料时,架位1 - 6优先走1 / 2号皮带线, 7 - 12优先走3 / 4号皮带线
string dataStr = JsonHelper.SerializeObject(data);
LogUtil.info("收到服务器出库消息:【" + dataStr + "】");
int index = -1;
foreach (string posId in posIdArray)
{
index++;
int plateW = Convert.ToInt32( plateWArray[index]);
int plateH =Convert.ToInt32( plateHArray[index]);
string shelfPosID = StoreManager.GetShelfIDByLoc(rfidLoc, ShelfPosList);
InOutParam inoutParam = new InOutParam(barcode, posId, shelfPosID, plateW, plateH, urgentReel, cutReel, smallReel, rfid, rfidLoc, taskCount, realRfid);
//根据发送的posId获取位置列表
ACBoxPosition position = CSVPositionReader<ACBoxPosition>.GetPositon(posId);
if (position == null)
{
//出入库没有找到服务器发送的库位,需要打印日志方便查询原因
WarnMsg = Name + "未找到库位:【" + inoutParam.ToStr() + "】";
LogUtil.error(WarnMsg);
continue;
}
try
{
//判断是否接收过此库位的出库信息
if (MoveInfo.MoveType.Equals(StoreMoveType.OutStore) && MoveInfo.MoveParam.PosID.Equals(posId))
{
LogUtil.error(Name + " 出库命令【" + inoutParam.ToStr() + "】重复,正在【" + posId + "】出库中");
continue;
}
//判断排队列表中是否已存在
List<InOutParam> reviceList = new List<InOutParam>(waitOutStoreList);
reviceList = (from m in reviceList where m.PosID.Equals(posId) select m).ToList<InOutParam>();
if (reviceList.Count > 0)
{
LogUtil.error(Name + " 出库命令【" + inoutParam.ToStr() + "】重复,排队列表中已存在【" + reviceList[0].ToStr() + "】");
continue;
}
}
catch (Exception ex)
{
LogUtil.error(Name + "验证出库【" + inoutParam.ToStr() + "】是否重复出错:" + ex.ToString());
}
StartExecuctOut(inoutParam);
}
TimeSpan span = DateTime.Now - time;
if (span.TotalMilliseconds > 10)
{
LogInfo(Name + "执行 ReviceOutStoreProcess 共处理了【" + span.TotalMilliseconds + "】毫秒");
}
}
}
#endregion
#region 扫码获取库位
/// <summary>
/// 数据接收
/// </summary>
/// <param name="message"></param>
private bool GetPosIdByCode()
{
try
{
if (LastWidth <= 0)
{
LastWidth = 7;
}
//string message = StoreManager.ProcessCode(LastWidth, LastHeight, LastScanCodes);
string message = MoveInfo.shelfLockDatas[MoveInfo.currShelfIndex].barcode;
if (message.Equals("") || string.IsNullOrEmpty(message))
{
CodeMsg = "未扫到二维码";
LogInfo("未扫到二维码");
return false;
}
if (storeRunStatus.Equals(StoreRunStatus.Wait))
{
LogInfo("二维码【 " + message + "】,设备未启动,不需要发送服务器");
return false;
}
// CodeMsg = "收到二维码【 " + message + "】,发送给服务器获取入库PosID";
LogUtil.info(Name + "二维码【 " + message + "】,发送给服务器获取入库PosID");
//发送扫码内容到服务器进行入库操作
Operation operation = getLineBoxStatus();
operation.op = 1;
operation.data = new Dictionary<string, string>() { { "code", message }, { "boxId", 1.ToString() }, { ParamDefine.rfid, CurrShelfID } };
string server = ConfigAppSettings.GetValue(Setting_Init.http_server);
Operation resultOperation = HttpHelper.PostJson(StoreManager.GetPostApi(server), operation, false);
if (resultOperation == null)
{
CodeMsg = "二维码【" + message + "】没有收到服务器反馈";
LogInfo("二维码【 " + message + "】没有收到服务器反馈!");
return false;
}
else if (!string.IsNullOrEmpty(resultOperation.msg))
{
//如果有提示消息,直接显示提示
LogInfo("二维码【 " + message + "】 :" + resultOperation.msg);
return false;
}
if (resultOperation.op.Equals(1))
{
Dictionary<string, string> data = resultOperation.data;
if (data != null && data.ContainsKey(ParamDefine.posId) && data.ContainsKey(ParamDefine.plateH) && data.ContainsKey(ParamDefine.plateW))
{
//服务器返回时有:posId库位编号,plateW:料盘宽度,plateH:料盘高度,
//postId格式BoxId#位置
string posId = data[ParamDefine.posId];
int plateW = FormUtil.GetIntData(data, ParamDefine.plateW);
int plateH = FormUtil.GetIntData(data, ParamDefine.plateH);
int storeId = InOutParam.GetPosStoreId(posId);
//根据发送的posId获取位置列表
ACBoxPosition position = CSVPositionReader<ACBoxPosition>.GetPositon(posId);
if (position == null)
{ //出入库没有找到服务器发送的库位,需要打印日志方便查询原因
WarnMsg = "入库未找到库位:二维码【" + message + "】库位【" + posId + "】 ";
LogUtil.error(Name + "收到服务器入库命令:入库未找到库位:二维码【" + message + "】库位【" + posId + "】");
return false;
}
int p2 = Config.GetComP2(plateH).TargetComP2(); ;
int p3 = p2 + Config.GetCom_P3_P2(plateW);
LogInfo(" 收到服务器入库命令:库位号【" + posId + "】二维码【" + message + "】设置入库参数,压紧位置["+p2+"]["+p3+"] , 开始入库!");
MoveInfo.MoveParam.UpdatePosId(message, posId, plateW, plateH, p2, p3);
return true;
}
}
else if (resultOperation.op.Equals(2))
{
ReviceOutStoreProcess(resultOperation);
}
else if (resultOperation.op.Equals(5))
{
humBean.ProcessHumidityCMD(resultOperation);
}
else
{
LogUtil.error("收到服务器命令:op=" + resultOperation.op + ",未找到对应处理");
}
}
catch (Exception ex)
{
LogUtil.error(Name + "GetPosIdByCode" + ex.StackTrace);
}
return false;
}
/// <summary>
/// 扫码枪数据接收
/// </summary>
/// <param name="codeResultType">扫码结果</param>
/// <returns></returns>
public enum CodeResultType
{
/// <summary>
/// 未扫到二维码
/// </summary>
NoCode,
/// <summary>
/// 设备未启动
/// </summary>
DeviceNotOpen,
/// <summary>
///未收到服务器反馈
/// </summary>
NotResponseFromServer,
WarnMsg,
/// <summary>
/// 未找到库位
/// </summary>
NotFoundPos,
/// <summary>
/// 不属于该仓位
/// </summary>
NotPosForPutIn,
Error,
Success
}
private bool GetPosIdByCode(int rfidLoc, out CodeResultType codeResultType)
{
try
{
if (LastWidth <= 0)
{
LastWidth = 7;
}
string message = StoreManager.ProcessCode(LastWidth, LastHeight, LastScanCodes);
if (message.Equals("") || string.IsNullOrEmpty(message))
{
CodeMsg = "未扫到二维码";
LogInfo("未扫到二维码");
codeResultType = CodeResultType.NoCode;
return false;
}
if (storeRunStatus.Equals(StoreRunStatus.Wait))
{
LogInfo("二维码【 " + message + "】,设备未启动,不需要发送服务器");
codeResultType = CodeResultType.DeviceNotOpen;
return false;
}
// CodeMsg = "收到二维码【 " + message + "】,发送给服务器获取入库PosID";
LogUtil.debug (Name + "二维码【 " + message + "】,发送给服务器获取入库PosID");
//查询该料盘所在料仓以及仓位
StoreManager.ResultType resultType = StoreManager.GetPosForPutIn(Name, Config, message, CurrShelfID, rfidLoc, out bool isLockInfoMatch);
if (resultType == StoreManager.ResultType.Error)
{
codeResultType = CodeResultType.Error;
return false;
}
else if(resultType == StoreManager.ResultType.NotInThisBox)
{
codeResultType = CodeResultType.NotPosForPutIn;
return false;
}
if (!isLockInfoMatch && MoveInfo.IsShelfLocked)//锁定信息不匹配则从第一层开始重新取料,一个料架只重新开始一次
{
MoveInfo.IsShelfLocked = false;
MoveInfo.currShelfIndex = -1;
LogUtil.info(Name + "该锁定料架" + CurrShelfID + "上的料盘信息不匹配,即将从开始位置循环取料");
}
//发送扫码内容到服务器进行入库操作
Operation operation = getLineBoxStatus();
operation.op = 1;
operation.data = new Dictionary<string, string>() { { "code", message }, { "boxId", 1.ToString() }, { ParamDefine.rfid, CurrShelfID } };
string server = ConfigAppSettings.GetValue(Setting_Init.http_server);
Operation resultOperation = HttpHelper.PostJson(StoreManager.GetPostApi(server), operation, false);
if (resultOperation == null)
{
CodeMsg = "二维码【" + message + "】没有收到服务器反馈";
LogInfo("二维码【 " + message + "】没有收到服务器反馈!");
codeResultType = CodeResultType.NotResponseFromServer;
return false;
}
else if (!string.IsNullOrEmpty(resultOperation.msg))
{
//如果有提示消息,直接显示提示
LogInfo("二维码【 " + message + "】 :" + resultOperation.msg);
codeResultType = CodeResultType.WarnMsg;
return false;
}
if (resultOperation.op.Equals(1))
{
Dictionary<string, string> data = resultOperation.data;
if (data != null && data.ContainsKey(ParamDefine.posId) && data.ContainsKey(ParamDefine.plateH) && data.ContainsKey(ParamDefine.plateW))
{
//服务器返回时有:posId库位编号,plateW:料盘宽度,plateH:料盘高度,
//postId格式BoxId#位置
string posId = data[ParamDefine.posId];
int plateW = FormUtil.GetIntData(data, ParamDefine.plateW);
int plateH = FormUtil.GetIntData(data, ParamDefine.plateH);
int storeId = InOutParam.GetPosStoreId(posId);
//根据发送的posId获取位置列表
ACBoxPosition position = CSVPositionReader<ACBoxPosition>.GetPositon(posId);
if (position == null)
{ //出入库没有找到服务器发送的库位,需要打印日志方便查询原因
WarnMsg = "入库未找到库位:二维码【" + message + "】库位【" + posId + "】 ";
LogUtil.error(Name + "收到服务器入库命令:入库未找到库位:二维码【" + message + "】库位【" + posId + "】");
codeResultType = CodeResultType.NotFoundPos;
return false;
}
int p2 = Config.GetComP2(plateH).TargetComP2(); ;
int p3 = p2 + Config.GetCom_P3_P2(plateW);
LogInfo(" 收到服务器入库命令:库位号【" + posId + "】二维码【" + message + "】设置入库参数,压紧位置[" + p2 + "][" + p3 + "] , 开始入库!");
MoveInfo.MoveParam.UpdatePosId(message, posId, plateW, plateH, p2, p3);
codeResultType = CodeResultType.Success;
return true;
}
}
else if (resultOperation.op.Equals(2))
{
ReviceOutStoreProcess(resultOperation);
}
else if (resultOperation.op.Equals(5))
{
humBean.ProcessHumidityCMD(resultOperation);
}
else
{
LogUtil.error("收到服务器命令:op=" + resultOperation.op + ",未找到对应处理");
}
}
catch (Exception ex)
{
LogUtil.error(Name + "GetPosIdByCode" + ex.StackTrace);
}
codeResultType = CodeResultType.Error;
return false;
}
#endregion
}
}
......@@ -69,13 +69,18 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ACPackingStore\AC_BOX_Bean.cs" />
<Compile Include="ACPackingStore\AC_BOX_Bean_Partial.cs" />
<Compile Include="ACPackingStore\AC_BOX_Bean_Shelf.cs" />
<Compile Include="ACPackingStore\EnteryDoorBean.cs" />
<Compile Include="ACPackingStore\HumitureBean.cs" />
<Compile Include="ACPackingStore\PackingStoreBean.cs" />
<Compile Include="ACPackingStore\StoreManager.cs" />
<Compile Include="PackingStore\AC_BOX_Bean_server_connect.cs" />
<Compile Include="PackingStore\AC_BOX_Bean.cs" />
<Compile Include="PackingStore\AC_BOX_Bean_OutStore.cs" />
<Compile Include="PackingStore\AC_BOX_Bean_InStore.cs" />
<Compile Include="PackingStore\AC_BOX_Bean_Partial.cs" />
<Compile Include="PackingStore\AC_BOX_Bean_AGV.cs" />
<Compile Include="PackingStore\AC_BOX_Bean_ScanCode.cs" />
<Compile Include="PackingStore\AC_BOX_Bean_Shelf.cs" />
<Compile Include="PackingStore\EnteryDoorBean.cs" />
<Compile Include="PackingStore\HumitureBean.cs" />
<Compile Include="PackingStore\PackingStoreBean.cs" />
<Compile Include="PackingStore\StoreManager.cs" />
<Compile Include="agvClient\AgvClient.cs" />
<Compile Include="device\halcon\CodeManager.cs" />
<Compile Include="device\IO\AIOBOX\AIOBOXManager.cs" />
......@@ -96,7 +101,7 @@
<Compile Include="store\InOutParam.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="store\model\StoreMoveInfo.cs">
<Compile Include="store\model\DeviceMoveInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="store\KTK_Store.cs" />
......@@ -110,6 +115,10 @@
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\..\CSharp-Workspace\MyProject\DLL\ConfigHelper\ConfigHelper\ConfigHelper.csproj">
<Project>{290182DB-D949-434E-9FF7-C59BDE3F433A}</Project>
<Name>ConfigHelper</Name>
</ProjectReference>
<ProjectReference Include="..\Common\Common.csproj">
<Project>{43cdd09e-fcf3-4960-a01d-3bbfe9933122}</Project>
<Name>Common</Name>
......
......@@ -45,6 +45,11 @@ namespace OnlineStore.DeviceLibrary
/// </summary>
public bool WaitShelfEnter=false;
private int logType = 1000;
/// <summary>
/// 当前料架编号
/// </summary>
private string CurrShelfID = "";
public AC_BOX_Bean(AC_BOX_Config config)
{
Init();
......@@ -92,8 +97,7 @@ namespace OnlineStore.DeviceLibrary
}
}
mainTimer.Enabled = false;
int isAuto = ConfigAppSettings.GetIntValue(Setting_Init.App_AutoRun);
if (isAuto == 1)
if (Setting_Init.App_AutoRun)
{
mainTimer.Enabled = true;
}
......@@ -266,7 +270,7 @@ namespace OnlineStore.DeviceLibrary
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
LineStop();
ACAxisHomeMove(Config.InOut_Axis);
AgvClient.SetStatus(Config.AgvNodeName,"","",ClientAction.None,ClientLevel.High,true);
setAgvStatus("","",ClientAction.None,ClientLevel.High,true);
}
/// <summary>
......@@ -460,7 +464,7 @@ namespace OnlineStore.DeviceLibrary
/// </summary>
public override void StopRun()
{
AgvClient.SetStatus(Config.AgvNodeName);
setAgvStatus();
lastPosId = "";
lastPosIdStatus = StoreStatus.StoreOnline;
WarnMsg = "";
......@@ -698,7 +702,7 @@ namespace OnlineStore.DeviceLibrary
}
if (IsDebug)
{
AgvClient.SetStatus(Config.AgvNodeName);
setAgvStatus();
}
else
{
......@@ -836,7 +840,7 @@ namespace OnlineStore.DeviceLibrary
/// </summary>
public override void StopMove()
{
AgvClient.SetStatus(Config.AgvNodeName);
setAgvStatus();
DoorBean.Stop();
IOMove(IO_Type.Axis_Brake, IO_VALUE.LOW);
MoveInfo.EndMove();
......
using Asa;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
public partial class AC_BOX_Bean
{
/// <summary>
/// 设置出入口AGV状态
/// </summary>
/// <param name="mark"></param>
/// <param name="shelfId"></param>
/// <param name="action"></param>
/// <param name="level"></param>
/// <param name="isMust"></param>
void setAgvStatus(string mark = "0", string shelfId = "", ClientAction action = ClientAction.None, ClientLevel level = ClientLevel.Low, bool isMust = false)
{
AgvClient.SetStatus(Config.AgvNodeName, mark, shelfId, action, level, isMust);
}
internal bool ProcessAGVAction(string name, string rfid, ClientAction action)
{
string logN = name + "收到调度" + name + "=" + action + ",RFID[" + rfid + "]";
//Arrive收到后打开门
if (!action.Equals(ClientAction.Arrive))
{
LogUtil.info(Name + logN + " ,未找到相关处理");
return false;
}
//出库处理中不处理
if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_03_WaitEmptyAgv))
{
if (!rfid.Equals(""))
{
string mark = GetMarkInfo();
LogUtil.error(Name + logN + " 当前 BS_03_WaitEmptyAgv,RFID[" + rfid + "]不是空车,不处理agv,重发 NeedLeave [" + mark + "][" + CurrShelfID + "]");
Task.Factory.StartNew(new Action(()=> {
setAgvStatus(mark, CurrShelfID, ClientAction.MayNot, ClientLevel.High, true);
Thread.Sleep(10000);
setAgvStatus(mark, CurrShelfID, ClientAction.NeedLeave, ClientLevel.High, true);
}));
return false;
}
//等待空车到达
LogUtil.info(Name + logN + ",当前 BS_03_WaitEmptyAgv,正在等待料架到达");
MoveInfo.NextMoveStep(StoreMoveStep.BS_04_DoorOpen);
InOutStoreLog("送出料架等待空车,agv到达,打开入料口移门");
DoorBean.StartOpen(MoveInfo);
return true;
}
else if (MoveInfo.MoveType.Equals(StoreMoveType.OutStore) && MoveInfo.MoveStep.Equals(StoreMoveStep.BI_00_ReadyShelf))
{
if (rfid.Equals(""))
{
string mark = GetMarkInfo();
LogUtil.error(Name + logN + " 当前出库中 BI_00_ReadyShelf,RFID无效,不处理agv,重发 NeedEnter [" + mark + "][" + MoveInfo.MoveParam.rfid + "]");
Task.Factory.StartNew(new Action(() => {
setAgvStatus(mark, CurrShelfID, ClientAction.MayNot, ClientLevel.High, true);
Thread.Sleep(10000);
setAgvStatus(mark, MoveInfo.MoveParam.rfid, ClientAction.NeedEnter, ClientLevel.High, true);
}));
return false;
}
//出库等待料架到达
LogUtil.info(Name + logN + ",当前出库中 BI_00_ReadyShelf,正在等待料架到达");
MoveInfo.NextMoveStep(StoreMoveStep.BI_01_DoorOpen);
InOutStoreLog("出库等待料架,agv已到达,打开入料口移门");
DoorBean.StartOpen(MoveInfo);
return true;
}
else if (storeRunStatus.Equals(StoreRunStatus.Runing) &&
MoveInfo.MoveType.Equals(StoreMoveType.None) &&
IOValue(IO_Type.LineTake_Check).Equals(IO_VALUE.LOW))
{
//agv到达,开始处理
if (rfid.Equals(""))
{
LogUtil.error(Name + logN + " ,RFID无效,不需要入库处理");
return false;
}
LogUtil.info(Name + logN + " ,检测到料架,开始料架入库");
StartShelfInStore();
return true;
}
else
{
LogUtil.error(Name + logN + " ,[" + MoveInfo.MoveType + "][" + MoveInfo.MoveStep + "]未找到相关处理");
}
return false;
}
}
}
using Asa;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
partial class AC_BOX_Bean
{
private DateTime startInStoreTime = DateTime.Now;
/// <summary>
/// 入库NG的料架位置
/// </summary>
List<string> inNGShelfPos = new List<string>();
void addNGShelfPos(string shelfPos)
{
inNGShelfPos.Add(shelfPos);
}
/// <summary>
/// 清空料架NG位置信息
/// </summary>
void clearNGShelfPos()
{
inNGShelfPos.Clear();
LogInfo("清空料架NG位置信息");
}
string getNGShelfPos()
{
return string.Join(",", inNGShelfPos);
}
/// <summary>
/// 是否是入库NG料架
/// </summary>
/// <returns></returns>
bool isNGShelf()
{
return inNGShelfPos.Count > 0;
}
/// <summary>
/// 清空最后一盘的信息
/// </summary>
private void ClearLastTrayInfo()
{
LastScanCodes = new List<string>();
ComTargetPosition = 0;
LastWidth = 0;
LastHeight = 0;
}
/// <summary>
/// 开始单盘入库
/// </summary>
public override void StartInStoreMove(InOutParam param)
{
startInStoreTime = DateTime.Now;
string posId = param != null ? param.PosID : "";
if (isInSuddenDown || isNoAirCheck ||
(!storeRunStatus.Equals(StoreRunStatus.Runing))
|| (!MoveInfo.MoveType.Equals(StoreMoveType.None)))
{
LogUtil.error(Name + " 启动出库出错,忙碌或报警中 ,storeStatus=" + storeRunStatus + ",MoveType=" + MoveInfo.MoveType + ",isInSuddenDown=" + isInSuddenDown + ",isNoAirCheck" + isNoAirCheck);
return;
}
if (!StoreManager.LoadInoutParam(param, true, this))
{
LogUtil.error(Name + " 启动入库【" + param.ToStr() + "】出错,找不到库位信息");
return;
}
InOutStoreLog(" 启动入库【" + param.ToStr() + "】,压紧点P2【" + param.MoveP.ComPress_P2 + "】压紧前点P3【" + param.MoveP.ComPress_P3 + "】");
setStatus(StoreRunStatus.Busy, StoreStatus.InStoreExecute);
MoveInfo.NewMove(StoreMoveType.InStore, param);
//新的料架库位
MoveInfo.NextMoveStep(StoreMoveStep.BI_11_InoutToP1);
MoveInfo.SingleInstore = true;
InOutStoreLog("料架取料: 叉子后退到待机点P1, 重置盘信息");
ACAxisMove(Config.InOut_Axis, Config.InOutAxis_P1_Position, Config.InOutAxis_P1_Speed);
ClearLastTrayInfo();
//LastRfidID = "";
LastOutParam = new InOutParam();
}
private void GetPosId()
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_30_SetInstoreParam);
InOutStoreLog("不扫码 : 获取库位号");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(10000));
if (MoveInfo.IsShelfLocked)
{
bool result = GetPosIdByCode();
if (!result)//获取库位失败
{
MoveInfo.MoveParam.PosID = "";
StartSendTray("锁定库位:获取入库库位失败");
}
else
{
MoveInfo.EndStepWait();
}
}
}
private void StartMoveToBag()
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_51_MoveToBag);
InOutStoreLog("到库位点,旋转轴至P2( 库位点)轴2(上下) 至P3(库位入库前点)");
ACAxisMove(Config.Middle_Axis, MoveInfo.MoveParam.MoveP.Middle_P2, Config.MiddleAxis_P2_Speed);
ACAxisMove(Config.UpDown_Axis, MoveInfo.MoveParam.MoveP.UpDown_P3, Config.UpDownAxis_P3_Speed);
}
/// <summary>
/// 入库失败料盘处理
/// </summary>
/// <param name="str"></param>
private void StartSendTray(string str = "扫码失败")
{
StartMoveTrayBack(str);
//MoveInfo.NextMoveStep(StoreMoveStep.BI_71_ToNGDoor);
//InOutStoreLog("NG料,升降轴到NG门口高点P12,旋转轴到NG门口P11");
////if(MoveInfo.IsShelfLocked)//锁定料架,扫码失败则清除当前位置
//{
// StoreManager.ClearLockLoc(Name, CurrShelfID, MoveInfo.currShelfIndex);
//}
//ACAxisMove(Config.UpDown_Axis, MoveInfo.MoveParam.MoveP.UpDown_P12, Config.UpDownAxis_P1_Speed);
//ACAxisMove(Config.Middle_Axis, MoveInfo.MoveParam.MoveP.Middle_P11, Config.MiddleAxis_P1_Speed);
}
/// <summary>
/// 将料盘送回原位
/// </summary>
/// <param name="str"></param>
private void StartMoveTrayBack(string str = "料盘不属于该仓库")
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_10_ToShelfPosition);
addNGShelfPos(MoveInfo.MoveParam.CurShelfPosID);
InOutStoreLog($"送出料盘 :{str} ,走到料架位置,旋转轴至P101,升降轴至P102");
ACAxisMove(Config.UpDown_Axis, MoveInfo.MoveParam.MoveP.UpDown_HP102, Config.UpDownAxis_P102_Speed);
ACAxisMove(Config.Middle_Axis, MoveInfo.MoveParam.MoveP.Middle_P101, Config.MiddleAxis_P101_Speed);
}
protected override void InStoreProcess()
{
LineMoveP moveP = MoveInfo.MoveParam.MoveP;
if (MoveInfo.IsInWait)
{
CheckWait();
}
if (MoveInfo.IsInWait)
{
return;
}
#region 料架取料盘扫码获取POSID
if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_10_StartGetTray))
{
if (MoveInfo.IsShelfLocked)
{
if (MoveInfo.NextLockedShelfPos())
{
//新的料架库位
startInStoreTime = DateTime.Now;
MoveInfo.SingleInstore = false;
MoveInfo.NextMoveStep(StoreMoveStep.BI_11_InoutToP1);
InOutStoreLog("料架取料,叉子后退到待机点P1, 重置盘信息");
ACAxisMove(Config.InOut_Axis, Config.InOutAxis_P1_Position, Config.InOutAxis_P1_Speed);
ClearLastTrayInfo();
}
else
{
//所有料盘已取料完成,送出料架
StartShelfOut();
}
}
else
{
if (MoveInfo.NextShelfPos())
{
//新的料架库位
startInStoreTime = DateTime.Now;
MoveInfo.SingleInstore = false;
MoveInfo.NextMoveStep(StoreMoveStep.BI_11_InoutToP1);
InOutStoreLog("料架取料,叉子后退到待机点P1, 重置盘信息");
ACAxisMove(Config.InOut_Axis, Config.InOutAxis_P1_Position, Config.InOutAxis_P1_Speed);
ClearLastTrayInfo();
}
else
{
//所有料盘已取料完成,送出料架
StartShelfOut();
}
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_11_InoutToP1))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_12_MoveToShelf);
InOutStoreLog("料架取料,升降轴到P101低点[" + moveP.UpDown_LP101 + "],旋转轴到P101点[" + moveP.Middle_P101 + "],压紧轴到压紧前点p3[" + Config.CompAxis_Max_P3 + "]");
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_LP101, Config.UpDownAxis_P102_Speed);
ACAxisMove(Config.Middle_Axis, moveP.Middle_P101, Config.MiddleAxis_P101_Speed);
ACAxisMove(Config.Comp_Axis, Config.CompAxis_Max_P3, Config.CompAxis_P3_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_12_MoveToShelf))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_13_InoutToP101);
InOutStoreLog("料架取料,叉子前进到P101点[" + moveP.InOut_P101 + "]");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P101, Config.InOutAxis_P101_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_13_InoutToP101))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_14_UpdownToP102);
InOutStoreLog("料架取料,升降轴上升到P102点[" + moveP.UpDown_HP102 + "]");
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_HP102, Config.UpDownAxis_P101_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_14_UpdownToP102))
{
if (MoveInfo.SingleInstore)
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_16_ComDownMove);
InOutStoreLog("单盘入库,料架取料,压紧轴走到压紧点P2: " + MoveInfo.MoveParam.MoveP.ComPress_P2);
ACAxisMove(Config.Comp_Axis, MoveInfo.MoveParam.MoveP.ComPress_P2, Config.CompAxis_P2_Speed);
}
else
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_15_StartCompress);
InOutStoreLog("料架取料,压紧轴开始缓慢压紧到P4 :" + Config.CompAxis_P4_Position);
MoveInfo.WaitList.Add(WaitResultInfo.WaitComAxis(Config.Comp_Axis, Config.CompAxis_P4_Position, Config.CompAxis_P4_Speed));
Config.Comp_Axis.TargetPosition = Config.CompAxis_P4_Position;
ACServerManager.AbsMove(Config.Comp_Axis.DeviceName, Config.Comp_Axis.GetAxisValue(), Config.CompAxis_P4_Position, Config.CompAxis_P4_Speed);
ComAxisStartCheck();
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_15_StartCompress))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_16_ComDownMove);
int currPosition = ACServerManager.GetActualtPosition(Config.Comp_Axis);
ComTargetPosition = currPosition;
int targetP = currPosition + Config.CompAxis_Down_Position;
LastHeight = Config.GetComP2PlateH(targetP);
MoveInfo.MoveParam.MoveP.ComPress_P2 = targetP;
MoveInfo.MoveParam.MoveP.ComPress_P3 = targetP + Config.CompAxis_P3_P2_Value;
InOutStoreLog("料架取料,检测到Compress_Check,盘高【" + LastHeight + "】,向下压紧 [" + Config.CompAxis_Down_Position + "] 目标 [" + targetP +
"]记录ComP2[" + targetP + "]ComP3[" + MoveInfo.MoveParam.MoveP.ComPress_P3 + "]");
ACAxisMove(Config.Comp_Axis, targetP, Config.CompAxis_P1_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_16_ComDownMove))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_17_InoutBack);
InOutStoreLog("料架取料,叉子后退到扫码点");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P1, Config.CompAxis_P1_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_17_InoutBack))
{
if (MoveInfo.SingleInstore)
{
//单盘入库,不需要扫码
StartMoveToBag();
}
else if (MoveInfo.IsShelfLocked && !IsScanCodeWithLockedShelf)
{
//该料架已锁定库位,不需要扫码,直接查询服务器
GetPosId();
}
else
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_21_ToScanPosition);
InOutStoreLog("扫码,升降轴到P2,旋转轴到P1");
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P2, Config.UpDownAxis_P1_Speed);
ACAxisMove(Config.Middle_Axis, moveP.Middle_P1, Config.MiddleAxis_P1_Speed);
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_21_ToScanPosition))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_22_InOutToP2);
InOutStoreLog("扫码,进出轴到P2");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P2, Config.InOutAxis_P2_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_22_InOutToP2))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_23_PutTrayDown);
InOutStoreLog("扫码,升降轴到扫码低点P1,压紧轴到压紧前点P3");
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P1, Config.UpDownAxis_P2_Speed);
ACAxisMove(Config.Comp_Axis, moveP.ComPress_P3, Config.CompAxis_P3_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_23_PutTrayDown))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_24_InOutToP1);
InOutStoreLog("扫码,进出轴返回待机点P1");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P1, Config.CompAxis_P1_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_24_InOutToP1))
{
IO_VALUE io1 = IOValue(IO_Type.TrayCheck_1);
IO_VALUE io2 = IOValue(IO_Type.TrayCheck_2);
IO_VALUE io3 = IOValue(IO_Type.TrayCheck_3);
IO_VALUE io4 = IOValue(IO_Type.TrayCheck_4);
if (io3.Equals(IO_VALUE.HIGH) || io4.Equals(IO_VALUE.HIGH))
{
LastWidth = 15;
}
else if (io1.Equals(IO_VALUE.HIGH) || io2.Equals(IO_VALUE.HIGH))
{
LastWidth = 7;
}
else
{
LastWidth = 0;
LogUtil.error("未检测到识别区料盘检测信号, 设置默认宽度=0");
}
MoveInfo.NextMoveStep(StoreMoveStep.BI_25_ScanCode);
InOutStoreLog("扫码,料盘识别 [" + io1 + "] [" + io2 + "] [" + io3 + "] [" + io4 + "] ,宽度【" + LastWidth + "】,开始扫码");
MoveInfo.OneWaitCanEndStep = true;
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(12000));
MoveInfo.WaitList.Add(WaitResultInfo.WaitCode());
Task.Factory.StartNew(delegate
{
IOMove(IO_Type.Camera_Led, IO_VALUE.HIGH);
LastScanCodes = CodeManager.CameraScan(Config.GetCameraList(), Name);
if (LastScanCodes.Count <= 0)
{
Thread.Sleep(1);
LastScanCodes = CodeManager.CameraScan(Config.GetCameraList(), Name);
}
IOMove(IO_Type.Camera_Led, IO_VALUE.LOW);
});
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_25_ScanCode))
{
if (LastScanCodes.Count <= 0 && LastWidth.Equals(0) && LastHeight.Equals(8))
{
storeStatus = StoreStatus.InStoreExecute;
MoveInfo.NextMoveStep(StoreMoveStep.BI_10_StartGetTray);
InOutStoreLog("扫码,扫码失败,尺寸" + LastWidth + "*" + LastHeight + ",认为没拿到料盘,继续循环料架取料盘");
}
else
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_27_InoutToP2);
InOutStoreLog("扫码,进出轴到P2");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P2, Config.InOutAxis_P2_Speed);
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_27_InoutToP2))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_28_GetScanPTray);
InOutStoreLog("扫码,升降轴到扫码高P2,压紧轴到压紧点P2");
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P2, Config.UpDownAxis_P2_Speed);
ACAxisMove(Config.Comp_Axis, moveP.ComPress_P2, Config.CompAxis_P2_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_28_GetScanPTray))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_29_InoutBackP1);
InOutStoreLog("扫码,进出轴返回");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P1, Config.InOutAxis_P1_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_29_InoutBackP1))
{
if (LastScanCodes.Count <= 0)
{
StartSendTray();
}
else
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_30_SetInstoreParam);
InOutStoreLog("扫码 ,获取库位号");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime((int)TimeSpan.FromMinutes(75).TotalMilliseconds));
bool result = GetPosIdByCode(MoveInfo.currShelfIndex, out CodeResultType codeResult);
if (!result)//获取库位失败
{
if (codeResult == CodeResultType.NotPosForPutIn)//库位不在该料仓,将该料盘放回料架
{
//MoveInfo.MoveParam.PosID = "";
StartMoveTrayBack("此料盘不属于该仓库,放回料架");
}
else//无法获取库位信息
{
MoveInfo.MoveParam.PosID = "";
StartSendTray("获取入库库位失败");
}
}
else
{
MoveInfo.EndStepWait();
}
}
}
#endregion
#region 入库逻辑
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_30_SetInstoreParam))
{
StartMoveToBag();
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_51_MoveToBag))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_52_DeviceToBag);
InOutStoreLog("叉子进入库位中,进出轴到库位P3");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P3, Config.InOutAxis_P3_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_52_DeviceToBag))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_53_PutWareToBag);
InOutStoreLog("放下物品,升降轴到库位缓冲点P4,压紧轴到P3");
// 5= 入仓位完成(料仓Box把料盘放入对应的库位中,装置还未恢复原始状态)
string posId = MoveInfo.MoveParam != null ? MoveInfo.MoveParam.PosID : "";
lastPosId = posId;
lastPosIdStatus = StoreStatus.InStoreEnd;
storeStatus = StoreStatus.InStoreEnd;
//手动发给服务器状态,防止没有手动
//SendLineStatus(StoreID, posId, StoreStatus.InStoreEnd);
ACAxisMove(Config.Comp_Axis, moveP.ComPress_P3, Config.CompAxis_P3_Speed);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P4, Config.UpDownAxis_P4_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_53_PutWareToBag))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_54_DeviceBackFromBag);
InOutStoreLog("叉子从库位中返回,进出轴到P1");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P1, Config.InOutAxis_P1_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_54_DeviceBackFromBag))
{
if (MoveInfo.SingleInstore)
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_55_GoBack);
InOutStoreLog("返回待机点,轴2/轴1/轴4动作至P1( 待机点))开始");
ACAxisMove(Config.Comp_Axis, moveP.ComPress_P1, Config.CompAxis_P1_Speed);
ACAxisMove(Config.Middle_Axis, moveP.Middle_P1, Config.MiddleAxis_P1_Speed);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P1, Config.UpDownAxis_P1_Speed);
}
else
{
TimeSpan span = DateTime.Now - startInStoreTime;
storeStatus = StoreStatus.InStoreExecute;
MoveInfo.NextMoveStep(StoreMoveStep.BI_10_StartGetTray);
InOutStoreLog("料架入库,上一盘入库结束, 耗时【" + FormUtil.GetSpanStr(span) + "】,旋转轴返回待机点,继续循环料架取料盘");
ACAxisMove(Config.Middle_Axis, moveP.Middle_P1, Config.MiddleAxis_P1_Speed);
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_55_GoBack))
{
TimeSpan span = DateTime.Now - startInStoreTime;
StoreManager.ClearLockLoc(Name, CurrShelfID, MoveInfo.currShelfIndex);
if (MoveInfo.SingleInstore)
{
string posId = MoveInfo.MoveParam != null ? MoveInfo.MoveParam.PosID : "";
InOutStoreLog(" 【" + posId + "】单盘入库结束,耗时【" + FormUtil.GetSpanStr(span) + "】!");
MoveEndToRuningStatus();
AutoInout.InOutEndProcess(this, StoreMoveType.InStore);
}
else
{
storeStatus = StoreStatus.InStoreExecute;
MoveInfo.NextMoveStep(StoreMoveStep.BI_10_StartGetTray);
InOutStoreLog("料架入库,上一盘入库结束, 耗时【" + FormUtil.GetSpanStr(span) + "】继续循环料架取料盘");
}
}
#endregion
#region 把料盘送到NG口逻辑
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_71_ToNGDoor))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_72_NGDoorUp);
InOutStoreLog("NG料,NG升降门上升");
CylinderMove(MoveInfo, IO_Type.NGDoorCylinder_Down, IO_Type.NGDoowCylinder_Up);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_72_NGDoorUp))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_73_InoutToNGDoor);
InOutStoreLog("NG料,进出轴到NG料门口位置P11");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P11, Config.InOutAxis_P2_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_73_InoutToNGDoor))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_74_UpdownDown);
InOutStoreLog("NG料,升降轴到P11,压紧轴到P3,放下料盘");
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P11, Config.UpDownAxis_P2_Speed);
ACAxisMove(Config.Comp_Axis, moveP.ComPress_P3, Config.CompAxis_P3_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_74_UpdownDown))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_75_InoutToP1);
InOutStoreLog("NG料,叉子后退到P1");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P1, Config.InOutAxis_P1_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_75_InoutToP1))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_76_NGDoorDown);
InOutStoreLog("NG料,关门NG料门,送出料盘结束");
CylinderMove(MoveInfo, IO_Type.NGDoowCylinder_Up, IO_Type.NGDoorCylinder_Down);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_76_NGDoorDown))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_77_NGLineRun);
InOutStoreLog("料架入库,NG流水线转动30s");
IOMove(IO_Type.NGLine_BackRun, IO_VALUE.LOW);
IOMove(IO_Type.NGLine_Run, IO_VALUE.HIGH);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(30000));
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_77_NGLineRun))
{
IOMove(IO_Type.NGLine_Run, IO_VALUE.LOW);
MoveInfo.NextMoveStep(StoreMoveStep.BI_10_StartGetTray);
InOutStoreLog("料架入库,停止NG线体转动,继续循环料架取料盘");
}
#endregion
#region 把料盘送回料架逻辑
else if (MoveInfo.MoveStep == StoreMoveStep.SO_10_ToShelfPosition)
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_11_ToShelf);
InOutStoreLog("送出料盘,叉子进出料口,进出轴至P101");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P101, Config.InOutAxis_P101_Speed);
}
else if (MoveInfo.MoveStep == StoreMoveStep.SO_11_ToShelf)
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_12_PutReel);
InOutStoreLog("送出料盘,放下物品,压紧轴到P1,升降轴至P101,清空 taskData=null ");
ACAxisMove(Config.Comp_Axis, moveP.ComPress_P1, Config.CompAxis_P1_Speed);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_LP101, Config.UpDownAxis_P101_Speed);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
}
else if (MoveInfo.MoveStep == StoreMoveStep.SO_12_PutReel)
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_13_InoutBack);
InOutStoreLog("送出料盘,叉子从出料口返回, 进出轴到P1 ");
InOutBackToP1(moveP.InOut_P1);
}
else if (MoveInfo.MoveStep == StoreMoveStep.SO_13_InoutBack)
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_10_StartGetTray);
InOutStoreLog("送出料盘结束,升降轴返回,升降轴到P1,顶升下降,继续循环料架取料盘");
// ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P1, Config.UpDownAxis_P1_Speed);
}
#endregion
//料架进入逻辑
else if (MoveInfo.MoveStep < StoreMoveStep.BI_10_StartGetTray)
{
ShelfEnterProcess();
}
//料架送出逻辑
else if (MoveInfo.MoveStep >= StoreMoveStep.BS_01_TopDown)
{
ShelfOutProcess();
}
else
{
InOutStoreLog("没有对应的处理!");
}
}
}
}
using Asa;
using log4net.Core;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics.Eventing.Reader;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
partial class AC_BOX_Bean
{
private DateTime startOutStoreTime = DateTime.Now;
public bool IsIgnoreComSig = false; //忽略料叉压紧信号
private void StartExecuctOut(InOutParam param)
{
bool result;
result = StartOutStoreMove(param);
if (!result)
{
LogInfo(" 执行出库【" + param.ToStr() + "】失败,加入等待队列");
waitOutStoreList.Enqueue(param);
}
}
/// <summary>
/// 开始出库运动
/// </summary>
public override bool StartOutStoreMove(InOutParam param)
{
startOutStoreTime = DateTime.Now;
if (!canOutStore(out string msg))
{
LogError(" 启动出库【" + param.ToStr() + "】失败:" + msg);
return false;
}
if (!StoreManager.LoadInoutParam(param, false, this))
{
LogError(" 启动出库【" + param.ToStr() + "】出错,找不到库位信息");
return false;
}
taskData = null;
setStatus(StoreRunStatus.Busy, StoreStatus.OutStoreExecute);
MoveInfo.NewMove(StoreMoveType.OutStore, param);
LogInfo("启动出库【" + param.ToStr() + "】 ");
//出库前shelfPosID需要固定,出库时根据rfid判断是否需要出入料架
MoveInfo.NextMoveStep(StoreMoveStep.SO_01_InoutBack);
InOutStoreLog("进出轴到P1 开始");
InOutBackToP1(MoveInfo.MoveParam.MoveP.InOut_P1);
return true;
}
private void SO_03_ToBagPosition()
{
LineMoveP movep = MoveInfo.MoveParam.MoveP;
MoveInfo.NextMoveStep(StoreMoveStep.SO_03_ToPosition);
InOutStoreLog("走到库位,压紧轴至P3[" + movep.ComPress_P3 + "] ,旋转轴至P2[" + movep.Middle_P2 + "],升降轴至P5[" + movep.UpDown_P5 + "] ,顶升上升");
ACAxisMove(Config.Comp_Axis, movep.ComPress_P3, Config.CompAxis_P3_Speed);
ACAxisMove(Config.Middle_Axis, movep.Middle_P2, Config.MiddleAxis_P2_Speed);
ACAxisMove(Config.UpDown_Axis, movep.UpDown_P5, Config.UpDownAxis_P5_Speed);
CylinderMove(MoveInfo, IO_Type.TopCylinder_Down, IO_Type.TopCylinder_Up);
}
protected override void OutStoreProcess()
{
LineMoveP moveP = MoveInfo.MoveParam.MoveP;
if (MoveInfo.IsInWait)
{
CheckWait();
}
if (MoveInfo.IsInWait)
{
return;
}
#region 关闭 把紧急料盘送到NG料箱逻辑
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_15_ToUrgentDoor))
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_16_UrgentDoorUp);
InOutStoreLog("紧急料 升降门上升");
CylinderMove(MoveInfo, IO_Type.NGDoorCylinder_Down, IO_Type.NGDoowCylinder_Up);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_16_UrgentDoorUp))
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_17_InoutToUrgentDoor);
InOutStoreLog("紧急料 进出轴到升降门口位置P11");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P11, Config.InOutAxis_P2_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_17_InoutToUrgentDoor))
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_18_UpdownDown);
InOutStoreLog("紧急料 升降轴到P11,压紧轴到P3,放下料盘");
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P11, Config.UpDownAxis_P2_Speed);
ACAxisMove(Config.Comp_Axis, moveP.ComPress_P3, Config.CompAxis_P3_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_18_UpdownDown))
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_19_InoutToP1);
InOutStoreLog("紧急料 叉子后退到P1");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P1, Config.InOutAxis_P1_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_19_InoutToP1))
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_20_UrgentDoorDown);
InOutStoreLog("紧急料 关闭升降门,送出料盘结束");
CylinderMove(MoveInfo, IO_Type.NGDoowCylinder_Up, IO_Type.NGDoorCylinder_Down);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
taskData = null;
Task.Factory.StartNew(delegate
{
int posLoc = StoreManager.GetShelfPosIndex(MoveInfo.MoveParam.CurShelfPosID, ShelfPosList);
//紧急料发PutFinished
if (MoveInfo.MoveParam.urgentReel)
{
string msg = StoreManager.afterPutCut(Name, "1000A", MoveInfo.MoveParam.WareCode, CID, 1, out taskData);
if (String.IsNullOrEmpty(msg).Equals(false))
{
LogUtil.error(Name + "[" + MoveInfo.MoveParam.WareCode + "] [" + "1000A" + "_" + GetLastRfid() + "] [" + 1 + "] afterPutCut 结果:" + msg);
}
}
});
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_20_UrgentDoorDown))
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_21_UrgentLineRun);
InOutStoreLog("紧急料出库 流水线转动30s");
IOMove(IO_Type.NGLine_Run, IO_VALUE.LOW);
IOMove(IO_Type.NGLine_BackRun, IO_VALUE.HIGH);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(30000));
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_21_UrgentLineRun))
{
IOMove(IO_Type.NGLine_BackRun, IO_VALUE.LOW);
InOutStoreLog("紧急料出库 停止紧急料线体转动");
bool isFinish = false;
if (MoveInfo.MoveParam.urgentReel)
{
if (taskData != null && taskData.urgentPackageTask <= 0)
{
InOutStoreLog("紧急料出库完成,urgentPackageTask=" + taskData.urgentPackageTask + "");
isFinish = true;
}
else if (taskData == null)
{
InOutStoreLog("紧急料出库完成,taskData=null");
isFinish = true;
}
}
if (!isFinish)
{
TimeSpan span = DateTime.Now - startOutStoreTime;
string posId = MoveInfo.MoveParam != null ? MoveInfo.MoveParam.PosID : "";
storeStatus = StoreStatus.StoreOnline;
InOutStoreLog(" 【" + posId + "】 " + " 紧急料出库结束,耗时【" + FormUtil.GetSpanStr(span) + "】!");
if (StoreManager.Store.AutoShelfInstore)
{
InOutStoreLog("紧急料还有出库任务,设置 AutoShelfInstore = false");
Setting_Init.AutoShelfInstore = false;
StoreManager.Store.AutoShelfInstore = false;
}
}
else
{
CylinderMove(MoveInfo, IO_Type.TopCylinder_Up, IO_Type.TopCylinder_Down);
}
MoveEndToRuningStatus();
AutoInout.InOutEndProcess(this, StoreMoveType.OutStore);
}
#endregion
#region 出库料架检查
if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_PreCheck_01_StartGetTray))
{
if (MoveInfo.NextShelfPos())
{
//新的料架库位
MoveInfo.NextMoveStep(StoreMoveStep.SO_PreCheck_02_InoutToP1);
InOutStoreLog("料架取料,叉子后退到待机点P1, 重置盘信息");
ACAxisMove(Config.InOut_Axis, Config.InOutAxis_P1_Position, Config.InOutAxis_P1_Speed);
ClearLastTrayInfo();
}
else
{
//所有位置已检查完,准备出库
MoveInfo.currShelfIndex = -1;
//恢复当前需要出库的位置
MoveInfo.MoveParam.RestoreShelfPosId();
SO_03_ToBagPosition();
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_PreCheck_02_InoutToP1))
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_PreCheck_03_MoveToShelf);
InOutStoreLog("料架取料,升降轴到P101低点[" + moveP.UpDown_LP101 + "],旋转轴到P101点[" + moveP.Middle_P101 + "],压紧轴到压紧前点p3[" + Config.CompAxis_Max_P3 + "]");
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_LP101, Config.UpDownAxis_P102_Speed);
ACAxisMove(Config.Middle_Axis, moveP.Middle_P101, Config.MiddleAxis_P101_Speed);
ACAxisMove(Config.Comp_Axis, Config.CompAxis_Max_P3, Config.CompAxis_P3_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_PreCheck_03_MoveToShelf))
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_PreCheck_04_InoutToP101);
InOutStoreLog("料架取料,叉子前进到P101点[" + moveP.InOut_P101 + "]");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P101, Config.InOutAxis_P101_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_PreCheck_04_InoutToP101))
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_PreCheck_05_UpdownToP102);
InOutStoreLog("料架取料,升降轴上升到P102点[" + moveP.UpDown_HP102 + "]");
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_HP102, Config.UpDownAxis_P101_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_PreCheck_05_UpdownToP102))
{
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_PreCheck_06_StartCompress);
InOutStoreLog("料架取料,压紧轴开始缓慢压紧到P4 :" + Config.CompAxis_P4_Position);
MoveInfo.WaitList.Add(WaitResultInfo.WaitComAxis(Config.Comp_Axis, Config.CompAxis_P4_Position, Config.CompAxis_P4_Speed));
Config.Comp_Axis.TargetPosition = Config.CompAxis_P4_Position;
ACServerManager.AbsMove(Config.Comp_Axis.DeviceName, Config.Comp_Axis.GetAxisValue(), Config.CompAxis_P4_Position, Config.CompAxis_P4_Speed);
//ComAxisStartCheck();
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_PreCheck_06_StartCompress))
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_PreCheck_07_ComDownMove);
int currPosition = ACServerManager.GetActualtPosition(Config.Comp_Axis);
ComTargetPosition = currPosition;
int targetP = currPosition + Config.CompAxis_Down_Position;
LastHeight = Config.GetComP2PlateH(targetP);
MoveInfo.MoveParam.MoveP.ComPress_P2 = targetP;
MoveInfo.MoveParam.MoveP.ComPress_P3 = targetP + Config.CompAxis_P3_P2_Value;
InOutStoreLog("料架取料,检测到Compress_Check,盘高【" + LastHeight + "】,向下压紧 [" + Config.CompAxis_Down_Position + "] 目标 [" + targetP +
"]记录ComP2[" + targetP + "]ComP3[" + MoveInfo.MoveParam.MoveP.ComPress_P3 + "]");
ACAxisMove(Config.Comp_Axis, targetP, Config.CompAxis_P1_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_PreCheck_07_ComDownMove))
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_PreCheck_08_InoutBack);
InOutStoreLog("料架取料,叉子后退到扫码点");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P1, Config.CompAxis_P1_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_PreCheck_08_InoutBack))
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_PreCheck_14_GetCheckResult);
//{
// MoveInfo.NextMoveStep(StoreMoveStep.SO_PreCheck_09_ToScanPosition);
// InOutStoreLog("检测治具,升降轴到P2,旋转轴到P1");
// ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P2, Config.UpDownAxis_P1_Speed);
// ACAxisMove(Config.Middle_Axis, moveP.Middle_P1, Config.MiddleAxis_P1_Speed);
//}
}
#region 无需到相机拍照位
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_PreCheck_09_ToScanPosition))
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_PreCheck_10_InOutToP2);
InOutStoreLog("检测治具,进出轴到P2");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P2, Config.InOutAxis_P2_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_PreCheck_10_InOutToP2))
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_PreCheck_11_PutTrayDown);
InOutStoreLog("检测治具,升降轴到扫码低点P1,压紧轴到压紧前点P3");
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P1, Config.UpDownAxis_P2_Speed);
ACAxisMove(Config.Comp_Axis, moveP.ComPress_P3, Config.CompAxis_P3_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_PreCheck_11_PutTrayDown))
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_PreCheck_12_InOutToP1);
InOutStoreLog("检测治具,进出轴返回待机点P1");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P1, Config.CompAxis_P1_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_PreCheck_12_InOutToP1))
{
IO_VALUE io1 = IOValue(IO_Type.TrayCheck_1);
IO_VALUE io2 = IOValue(IO_Type.TrayCheck_2);
IO_VALUE io3 = IOValue(IO_Type.TrayCheck_3);
IO_VALUE io4 = IOValue(IO_Type.TrayCheck_4);
if (io3.Equals(IO_VALUE.HIGH) || io4.Equals(IO_VALUE.HIGH))
{
LastWidth = 15;
}
else if (io1.Equals(IO_VALUE.HIGH) || io2.Equals(IO_VALUE.HIGH))
{
LastWidth = 7;
}
else
{
LastWidth = 0;
LogUtil.error("未检测到识别区料盘检测信号, 设置默认宽度=0");
}
MoveInfo.NextMoveStep(StoreMoveStep.SO_PreCheck_13_CheckFix);
InOutStoreLog("检测治具,料盘识别 [" + io1 + "] [" + io2 + "] [" + io3 + "] [" + io4 + "] ,宽度【" + LastWidth + "】,开始扫码");
MoveInfo.OneWaitCanEndStep = true;
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(12000));
MoveInfo.WaitList.Add(WaitResultInfo.WaitCode());
Task.Factory.StartNew(delegate//治具识别
{
IOMove(IO_Type.Camera_Led, IO_VALUE.HIGH);
LastScanCodes = CodeManager.CameraScan(Config.GetCameraList(), Name);
if (LastScanCodes.Count <= 0)
{
Thread.Sleep(1);
LastScanCodes = CodeManager.CameraScan(Config.GetCameraList(), Name);
}
IOMove(IO_Type.Camera_Led, IO_VALUE.LOW);
});
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_PreCheck_13_CheckFix))
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_PreCheck_14_GetCheckResult);
}
#endregion
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_PreCheck_14_GetCheckResult))
{
if (IOValue(IO_Type.Compress_Check).Equals(IO_VALUE.LOW))// && LastHeight.Equals(8)
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_PreCheck_01_StartGetTray);
InOutStoreLog("检测治具,未检测到治具,认为OK,继续循环料架取料盘");
}
else
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_PreCheck_15_InoutToP2);
addNGShelfPos(MoveInfo.MoveParam.CurShelfPosID);
InOutStoreLog("检测治具,检测到治具,认为料架为NG,进出轴到P2");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P2, Config.InOutAxis_P2_Speed);
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_PreCheck_15_InoutToP2))
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_PreCheck_16_GetScanPTray);
InOutStoreLog("检测治具,检测到治具,升降轴到扫码高P2,压紧轴到压紧点P2");
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P2, Config.UpDownAxis_P2_Speed);
ACAxisMove(Config.Comp_Axis, moveP.ComPress_P2, Config.CompAxis_P2_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_PreCheck_16_GetScanPTray))
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_PreCheck_17_InoutBackP1);
InOutStoreLog("检测治具,检测到治具,进出轴返回");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P1, Config.InOutAxis_P1_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_PreCheck_17_InoutBackP1))
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_PreCheck_18_ToShelfPosition);
InOutStoreLog("检测治具,检测到治具,叉子已到P1,走到料架位置,旋转轴至P101[" + moveP.Middle_P101 + "],升降轴至P102[" + moveP.UpDown_HP102 + "] ");
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_HP102, Config.UpDownAxis_P102_Speed);
ACAxisMove(Config.Middle_Axis, moveP.Middle_P101, Config.MiddleAxis_P101_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_PreCheck_18_ToShelfPosition))
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_PreCheck_19_ToShelf);
InOutStoreLog("检测治具,检测到治具,叉子进出料口,进出轴至P101");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P101, Config.InOutAxis_P101_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_PreCheck_19_ToShelf))
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_PreCheck_20_PutReel);
InOutStoreLog("检测治具,检测到治具,放下物品,压紧轴到P1,升降轴至P101");
ACAxisMove(Config.Comp_Axis, moveP.ComPress_P1, Config.CompAxis_P1_Speed);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_LP101, Config.UpDownAxis_P101_Speed);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_PreCheck_20_PutReel))
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_PreCheck_21_InoutBack);
InOutStoreLog("检测治具,检测到治具,叉子从出料口返回, 进出轴到P1 ");
InOutBackToP1(moveP.InOut_P1);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_PreCheck_21_InoutBack))
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_PreCheck_22_GoBack);
InOutStoreLog("检测治具,检测到治具,升降轴返回,升降轴到P1,顶升下降");
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P1, Config.UpDownAxis_P1_Speed);
//发送消息给流水线
// SendOutStoreEnd(MoveInfo);
CylinderMove(MoveInfo, IO_Type.TopCylinder_Up, IO_Type.TopCylinder_Down);
}
else if (MoveInfo.MoveStep == StoreMoveStep.SO_PreCheck_22_GoBack)
{
StartShelfOut();
}
#endregion
#region 出库步骤
if (MoveInfo.MoveStep == StoreMoveStep.SO_01_InoutBack)
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_02_TopDown);
InOutStoreLog("顶升下降");
CylinderMove(MoveInfo, IO_Type.TopCylinder_Up, IO_Type.TopCylinder_Down);
}
else if (MoveInfo.MoveStep == StoreMoveStep.SO_02_TopDown)
{
bool hasShelf = IOValue(IO_Type.LineTake_Check).Equals(IO_VALUE.HIGH);
if (hasShelf)
{
string LastRfidID = GetLastRfid();
// if (IsRightShelfId(CurrShelfID, MoveInfo.MoveParam.realRfid))
if (MoveInfo.MoveParam.rfid.Equals(LastRfidID))
{
LogRunStepInfo($"【LastRfidID={LastRfidID}】【{MoveInfo.MoveParam.rfid}】 同料架,开始取料");
SO_03_ToBagPosition();
return;
}
else
{
//重新记录
LogRunStepInfo($"【LastRfidID={LastRfidID}】【{MoveInfo.MoveParam.rfid}】 不同料架,送出当前料架,稍后重新出库");
waitOutStoreList.Enqueue(MoveInfo.MoveParam);
// MoveInfo.MoveParam.rfid = LastRfidID;
MoveInfo.NewMove(StoreMoveType.OutStore, LastOutParam);
//送出料架,并且记录出库信息,等会重新出库
StartShelfOut();
return;
}
}
else if (!hasShelf && (!MoveInfo.MoveParam.rfid.Equals("")))
{
if (CurrShelfID.EndsWith("00"))
{
CurrShelfID = "";
}
string mark = GetMarkInfo();
// string rfid = MoveInfo.MoveParam.rfid;
MoveInfo.NextMoveStep(StoreMoveStep.BI_00_ReadyShelf);
clearNGShelfPos();
InOutStoreLog("呼叫agv送空料架,NeedEnter[" + mark + "][" + MoveInfo.MoveParam.rfid + "],等待agv_Arrive 或有料架,进出轴到P1");
InOutBackToP1(MoveInfo.MoveParam.MoveP.InOut_P1);
//需要先叫agv到达
setAgvStatus(mark, MoveInfo.MoveParam.rfid, ClientAction.NeedEnter, ClientLevel.High, true);
MoveInfo.WaitList.Add(WaitResultInfo.WaitAgvAction((int)ClientAction.Arrive));
}
else
{
LogRunStepError($"未找到处理的步骤,当前:LineTake_Check={hasShelf},{MoveInfo.MoveParam.ToStr()}");
}
}
else if (MoveInfo.MoveStep == StoreMoveStep.SO_03_ToPosition)
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_04_ToPos);
InOutStoreLog("叉子进入库位中, 进出轴至P3[" + moveP.InOut_P3 + "] ");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P3, Config.InOutAxis_P3_Speed);
}
else if (MoveInfo.MoveStep == StoreMoveStep.SO_04_ToPos)
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_05_GetReel);
InOutStoreLog("拿起物品,升降轴至P6[" + moveP.UpDown_P6 + "],压紧轴到压紧点P2 :" + moveP.ComPress_P2);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P6, Config.UpDownAxis_P6_Speed);
ACAxisMove(Config.Comp_Axis, moveP.ComPress_P2, Config.CompAxis_P2_Speed);
//MoveInfo.WaitList.Add(WaitResultInfo.WaitComAxis(Config.Comp_Axis, Config.CompAxis_P4_Position, Config.CompAxis_P4_Speed));
//Config.Comp_Axis.TargetPosition = Config.CompAxis_P4_Position;
//ACServerManager.AbsMove(Config.Comp_Axis.DeviceName, Config.Comp_Axis.GetAxisValue(), Config.CompAxis_P4_Position, Config.CompAxis_P4_Speed);
//ComAxisStartCheck();
}
else if (MoveInfo.MoveStep == StoreMoveStep.SO_05_GetReel)
{
// SO_06_StartCompress();
//}
//else if (MoveInfo.MoveStep.Equals(StoreMoveStep.SO_06_StartCompress))
//{
// MoveInfo.NextMoveStep(StoreMoveStep.SO_07_ComDownMove);
// int currPosition = ACServerManager.GetActualtPosition(Config.Comp_Axis);
// int targetP = currPosition + Config.CompAxis_Down_Position;
// InOutStoreLog("出库 " + MoveInfo.SLog + ": 再向下压紧 [" + Config.CompAxis_Down_Position + "] 目标 [" + targetP + "] ");
// ACAxisMove(Config.Comp_Axis, targetP, Config.CompAxis_P1_Speed);
//}
//else if (MoveInfo.MoveStep == StoreMoveStep.SO_07_ComDownMove)
//{
MoveInfo.NextMoveStep(StoreMoveStep.SO_08_InoutBack);
InOutStoreLog("进出轴至待机点P1[" + moveP.InOut_P1 + "] ");
InOutBackToP1(moveP.InOut_P1);
//把库位的物品放到取到叉子上之后是出仓完成
string posId = MoveInfo.MoveParam != null ? MoveInfo.MoveParam.PosID : "";
lastPosId = posId;
lastPosIdStatus = StoreStatus.OutStoreBoxEnd;
storeStatus = StoreStatus.OutStoreBoxEnd;
}
else if (MoveInfo.MoveStep == StoreMoveStep.SO_08_InoutBack)
{
IsIgnoreComSig = false;
CompressSigTimeOut = false;
//LogUtil.info("出库步骤 SO_07_CheckComSig :IsIgnoreComSig = false, CompressSigTimeOut = false");
IO_VALUE iov = IOValue(IO_Type.Compress_Check);
//if (MoveInfo.MoveParam.urgentReel)
//{
// MoveInfo.NextMoveStep(StoreMoveStep.SO_15_ToUrgentDoor);
// InOutStoreLog("紧急料 " + MoveInfo.SLog + ",升降轴到升降门口高点P12,旋转轴到升降门口P11");
// ACAxisMove(Config.UpDown_Axis, MoveInfo.MoveParam.MoveP.UpDown_P12, Config.UpDownAxis_P1_Speed);
// ACAxisMove(Config.Middle_Axis, MoveInfo.MoveParam.MoveP.Middle_P11, Config.MiddleAxis_P1_Speed);
//}
//else
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_10_ToShelfPosition);
InOutStoreLog("叉子已到P1,Compress_Check=" + iov + ",走到料架位置,旋转轴至P101[" + moveP.Middle_P101 + "],升降轴至P102[" + moveP.UpDown_HP102 + "] ");
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_HP102, Config.UpDownAxis_P102_Speed);
ACAxisMove(Config.Middle_Axis, moveP.Middle_P101, Config.MiddleAxis_P101_Speed);
}
//MoveInfo.NextMoveStep(StoreMoveStep.SO_09_CheckComSig);
//InOutStoreLog("出库 " + MoveInfo.SLog + ":等待料叉压紧信号 ");
//MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Compress_Check, IO_VALUE.HIGH));
}
else if (MoveInfo.MoveStep == StoreMoveStep.SO_09_CheckComSig)
{
if (IOValue(IO_Type.Compress_Check).Equals(IO_VALUE.HIGH) || IsIgnoreComSig)
{
IsIgnoreComSig = false;
CompressSigTimeOut = false;
LogUtil.info("出库步骤 SO_07_CheckComSig :IsIgnoreComSig = false, CompressSigTimeOut = false");
MoveInfo.NextMoveStep(StoreMoveStep.SO_10_ToShelfPosition);
InOutStoreLog("走到料架位置,旋转轴至P101,升降轴至P102 ");
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_HP102, Config.UpDownAxis_P102_Speed);
ACAxisMove(Config.Middle_Axis, moveP.Middle_P101, Config.MiddleAxis_P101_Speed);
}
}
else if (MoveInfo.MoveStep == StoreMoveStep.SO_10_ToShelfPosition)
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_11_ToShelf);
InOutStoreLog("叉子进出料口,进出轴至P101");
ACAxisMove(Config.InOut_Axis, moveP.InOut_P101, Config.InOutAxis_P101_Speed);
}
else if (MoveInfo.MoveStep == StoreMoveStep.SO_11_ToShelf)
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_12_PutReel);
InOutStoreLog("放下物品,压紧轴到P1,升降轴至P101,清空 taskData=null ");
ACAxisMove(Config.Comp_Axis, moveP.ComPress_P1, Config.CompAxis_P1_Speed);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_LP101, Config.UpDownAxis_P101_Speed);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
taskData = null;
Task.Factory.StartNew(delegate
{
int posLoc = StoreManager.GetShelfPosIndex(MoveInfo.MoveParam.CurShelfPosID, ShelfPosList);
//分盘料和紧急料发PutFinished
if (MoveInfo.MoveParam.cutReel || MoveInfo.MoveParam.urgentReel)
{
string msg = StoreManager.afterPutCut(Name, CurrShelfID, MoveInfo.MoveParam.WareCode, CID, posLoc, out taskData);
if (String.IsNullOrEmpty(msg).Equals(false))
{
LogUtil.error(Name + "[" + MoveInfo.MoveParam.WareCode + "] [" + CurrShelfID + "_" + GetLastRfid() + "] [" + posLoc + "] afterPutCut 结果:" + msg);
}
}
else
{
int newTaskCount = 0;
string msg = StoreManager.UpdateTrayLoc(Name, MoveInfo.MoveParam.WareCode, CurrShelfID + "@" + posLoc.ToString(), out newTaskCount);
if (String.IsNullOrEmpty(msg).Equals(false))
{
LogUtil.error(Name + "[" + MoveInfo.MoveParam.WareCode + "] [" + CurrShelfID + "_" + GetLastRfid() + "] [" + posLoc + "] UpdateTrayLoc 结果:" + msg);
}
if (newTaskCount > MoveInfo.MoveParam.taskCount)
{
InOutStoreLog("UpdateTrayLoc 返回 newTaskCount=" + newTaskCount + ",原有 taskCount=" + MoveInfo.MoveParam.taskCount + ",使用新数据");
MoveInfo.MoveParam.taskCount = newTaskCount;
}
}
});
}
else if (MoveInfo.MoveStep == StoreMoveStep.SO_12_PutReel)
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_13_InoutBack);
InOutStoreLog("叉子从出料口返回, 进出轴到P1 ");
InOutBackToP1(moveP.InOut_P1);
}
else if (MoveInfo.MoveStep == StoreMoveStep.SO_13_InoutBack)
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_14_GoBack);
InOutStoreLog("升降轴返回,升降轴到P1,顶升下降");
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P1, Config.UpDownAxis_P1_Speed);
//发送消息给流水线
// SendOutStoreEnd(MoveInfo);
CylinderMove(MoveInfo, IO_Type.TopCylinder_Up, IO_Type.TopCylinder_Down);
}
else if (MoveInfo.MoveStep == StoreMoveStep.SO_14_GoBack)
{
//判断是否需要送出料架
bool isNeedSend = false;
string logName = "【" + CurrShelfID + "_" + GetLastRfid() + "】";
//只有rfid不为空才需要送出料架
if (String.IsNullOrEmpty(MoveInfo.MoveParam.rfid))
{
InOutStoreLog("出库完成,未设置rfid,不需要送出料架");
isNeedSend = false;
}
else if (MoveInfo.MoveParam.cutReel)
{
if (taskData != null && taskData.cutPackageTask <= 0)
{
InOutStoreLog(logName + "分盘料出库完成,cutPackageTask=" + taskData.cutPackageTask + ",送出料架");
isNeedSend = true;
}
else if (taskData == null)
{
InOutStoreLog(logName + "分盘料出库完成,taskData=null,送出料架");
isNeedSend = true;
}
}
else if (MoveInfo.MoveParam.urgentReel)
{
if (taskData != null && taskData.urgentPackageTask <= 0)
{
InOutStoreLog(logName + "紧急料出库完成,urgentPackageTask=" + taskData.urgentPackageTask + ",送出料架");
isNeedSend = true;
}
else if (taskData == null)
{
InOutStoreLog(logName + "紧急料出库完成,taskData=null,送出料架");
isNeedSend = true;
}
}
else if (MoveInfo.MoveParam.taskCount <= 0)
{
InOutStoreLog(logName + "出库完成,taskCount=" + MoveInfo.MoveParam.taskCount + " 送出料架");
isNeedSend = true;
}
if (isNeedSend)
{
StartShelfOut();
}
else
{
TimeSpan span = DateTime.Now - startOutStoreTime;
string posId = MoveInfo.MoveParam != null ? MoveInfo.MoveParam.PosID : "";
storeStatus = StoreStatus.StoreOnline;
LogInfo(" 【" + posId + "】 " + logName + " 出库结束,耗时【" + FormUtil.GetSpanStr(span) + "】!");
if (!String.IsNullOrEmpty(MoveInfo.MoveParam.rfid))
{
if (StoreManager.Store.AutoShelfInstore)
{
LogInfo(" 料架" + logName + "还有出库任务,设置 AutoShelfInstore = false");
Setting_Init.AutoShelfInstore = false;
StoreManager.Store.AutoShelfInstore = false;
}
}
MoveEndToRuningStatus();
AutoInout.InOutEndProcess(this, StoreMoveType.OutStore);
}
}
#endregion
else if (MoveInfo.MoveStep <= StoreMoveStep.SO_01_InoutBack)
{
ShelfEnterProcess();
}
else if (MoveInfo.MoveStep >= StoreMoveStep.BS_01_TopDown)
{
ShelfOutProcess();
}
else
{
LogUtil.error(Name + " 出库处理,moveStatus=" + MoveInfo.MoveStep + ",没有对应的处理!");
}
}
//private void SO_06_StartCompress()
//{
// //如果检测信号亮或者当前位置大于P4,直接走相对位置
// if (IOValue(IO_Type.Compress_Check).Equals(IO_VALUE.HIGH) || (MoveInfo.MoveParam.MoveP.ComPress_P2 >= Config.CompAxis_P4_Position))
// {
// MoveInfo.NextMoveStep(StoreMoveStep.SO_07_ComDownMove);
// int currPosition = ACServerManager.GetActualtPosition(Config.Comp_Axis);
// int targetP = currPosition + Config.CompAxis_Down_Position;
// InOutStoreLog("出库 " + MoveInfo.SLog + ": 再向下压紧 [" + Config.CompAxis_Down_Position + "] 目标 [" + targetP + "] ");
// ACAxisMove(Config.Comp_Axis, targetP, Config.CompAxis_P1_Speed);
// }
// else
// {
// MoveInfo.NextMoveStep(StoreMoveStep.SO_06_StartCompress);
// InOutStoreLog("出库 " + MoveInfo.SLog + ":压紧轴开始缓慢压紧到P4 :" + Config.CompAxis_P4_Position);
// MoveInfo.WaitList.Add(WaitResultInfo.WaitComAxis(Config.Comp_Axis, Config.CompAxis_P4_Position, Config.CompAxis_P4_Speed));
// Config.Comp_Axis.TargetPosition = Config.CompAxis_P4_Position;
// ACServerManager.AbsMove(Config.Comp_Axis.DeviceName, Config.Comp_Axis.GetAxisValue(), Config.CompAxis_P4_Position, Config.CompAxis_P4_Speed);
// ComAxisStartCheck();
// }
//}
}
}
using Asa;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
partial class AC_BOX_Bean
{
/// <summary>
/// 设置设备运行状态
/// </summary>
/// <param name="runStatus"></param>
void setStoreRunStatus(StoreRunStatus runStatus)
{
storeRunStatus = runStatus;
LogInfo($"设置设备运行状态:{storeRunStatus.ToString()}");
}
/// <summary>
/// 设置设备状态
/// </summary>
/// <param name="status"></param>
void setStoreStatus(StoreStatus status)
{
storeStatus = status;
LogInfo($"设置设备状态:{storeStatus.ToString()}");
}
void setStatus(StoreRunStatus runStatus, StoreStatus status)
{
setStoreRunStatus(runStatus);
setStoreStatus(status);
}
/// <summary>
/// 设备是否空闲
/// </summary>
/// <returns></returns>
bool isIdle()
{
return storeRunStatus.Equals(StoreRunStatus.Runing) && (MoveInfo?.MoveType.Equals(StoreMoveType.None) ?? false);
}
/// <summary>
/// 获取料架备注
/// 包含料信息
/// </summary>
/// <param name="defualtMark"></param>
/// <returns></returns>
private string GetMarkInfo(string defualtMark = "0")
{
string mark = defualtMark;
//如果料架号是空,需要送到VMI线
if (MoveInfo.MoveType.Equals(StoreMoveType.OutStore))
{
if (CurrShelfID.EndsWith("00"))
{
mark = defualtMark;
}
else if(isNGShelf())
{
mark = MoveInfo.MoveParam.rfid + ",ng";
}
//包装料会发往分盘区, 紧急料区, 包装线区
// urgentReel 这个为true是紧急料 出到紧急料区
// cutReel 为true是分盘料,AGV会拉到到分盘区
//料串会发到分盘区和紧急料区
//两个都为false 包装料默认拉到包装线体, 料串默认拉到紧急料区
else if (MoveInfo.MoveParam.urgentReel)
{
//紧急料,需要到紧急料区
mark = MoveInfo.MoveParam.rfid + ",urgent";
}
else if (MoveInfo.MoveParam.cutReel)
{
//cutReel 为true是分盘料,AGV会拉到到分盘区
mark = MoveInfo.MoveParam.rfid + ",cut";
}
else
{
mark = MoveInfo.MoveParam.rfid + ",pack";
}
}
else if (MoveInfo.MoveType.Equals(StoreMoveType.InStore) && isNGShelf())
{
mark = MoveInfo.MoveParam.rfid + ",ng";
}
return mark;
}
/// <summary>
/// 设备是否可以动作
/// </summary>
/// <param name="msg"></param>
/// <returns></returns>
bool canStartMove(out string msg)
{
StringBuilder sb = new StringBuilder();
if (isInSuddenDown)
sb.Append("急停中;");
if (isNoAirCheck)
sb.Append("未检测到气压信号;");
if (!isIdle())
{
sb.Append("忙碌中;");
}
msg = sb.ToString();
if (!string.IsNullOrEmpty(msg))
return false;
return true;
}
bool canInStore(out string msg)
{
msg = "";
return true;
}
bool canOutStore(out string msg)
{
if(canStartMove(out msg))
{
if (WaitShelfEnter)
{
msg+="有入库料架在路上";
return false;
}
}
return true;
}
#region 出入库结果验证
public bool CompressSigTimeOut = false;
public bool IsScanCodeWithLockedShelf = true; //锁定的料架是否扫码
private void CheckWait()
{
List<WaitResultInfo> list = MoveInfo.WaitList;
//当等待超过一分钟时,需要打印提示
TimeSpan span = DateTime.Now - MoveInfo.LastSetpTime;
string NotOkMsg = "";
if (list.Count <= 0)
{
MoveInfo.EndStepWait();
return;
}
bool isOk = true;
if (MoveInfo.OneWaitCanEndStep)
{
isOk = false;
}
foreach (WaitResultInfo wait in list)
{
if (wait.IsEnd)
{
continue;
}
NotOkMsg = wait.ToStr();
if (wait.WaitType.Equals(WaitEnum.W001_AxisMove))
{
string msg = "";
if (wait.IsHomeMove)
{
wait.IsEnd = ACHomeMoveIsEnd(wait.AxisInfo, out msg);
}
else
{
wait.IsEnd = ACAxisMoveIsEnd(wait.AxisInfo, wait.TargetPosition, wait.TargetSpeed, out msg);
}
if (!msg.Equals(""))
{
isOk = false;
WarnMsg = msg;
Alarm(StoreAlarmType.AxisMoveError, GetAlarmCodeByAxis(wait.AxisInfo).ToString(), WarnMsg, MoveInfo.MoveType);
break;
}
}
else if (wait.WaitType.Equals(WaitEnum.W002_IOValue))
{
wait.IsEnd = IOValue(wait.IoType).Equals(wait.IoValue);
int timeOutMs = Config.IOSingle_TimerOut;
if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_08_WaitLineIn) ||
MoveInfo.MoveStep.Equals(StoreMoveStep.BI_04_WaitTakeSingle))
{
timeOutMs = 30000;
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_03_LineRun))
{
timeOutMs = 40000;
}
if ((!wait.IsEnd) && span.TotalMilliseconds > timeOutMs && NoAlarm())
{
ConfigIO io = Config.getWaitIO(wait.IoType);
WarnMsg = Name + "[" + MoveInfo.MoveType + "][" + MoveInfo.MoveStep + "] 等待(" + io.DisplayStr + "=" + wait.IoValue + ") 超时";
if (WarnMsg.Contains(IO_Type.Compress_Check) && MoveInfo.MoveStep.Equals(StoreMoveStep.SO_09_CheckComSig))
{
CompressSigTimeOut = true;
WarnMsg += "出库时料叉未检测到信号!";
}
Alarm(StoreAlarmType.IoSingleTimeOut, io.ElectricalDefinition, WarnMsg, MoveInfo.MoveType);
LogUtil.error(Name + "[" + MoveInfo.MoveType + "][" + MoveInfo.MoveStep + "] 等待(" + io.DisplayStr + "=" + wait.IoValue + ") 超时", logType + 14);
if (!MoveInfo.OneWaitCanEndStep)
{
isOk = false;
break;
}
}
}
else if (wait.WaitType.Equals(WaitEnum.W003_Time))
{
wait.IsEnd = (span.TotalMilliseconds >= wait.TimeMSeconds);
}
else if (wait.WaitType.Equals(WaitEnum.W007_ReelHeight))
{
}
else if (wait.WaitType.Equals(WaitEnum.W008_Compress))
{
//等待信号亮或者走到绝对位置才停止
if (IOValue(TargetIoType).Equals(TargetIoValue))
{
LogUtil.info("CheckWait 检测到" + TargetIoType + "=" + TargetIoValue + ",停止压紧轴运行");
wait.IsEnd = true;
ComAxisStopCheck();
}
else
{
bool moveOk = ACServerManager.GetBusyStatus(wait.AxisInfo.DeviceName, wait.AxisInfo.GetAxisValue()).Equals(0);
if (moveOk)
{
//TODO 判断是否达到高度,如果未达到,继续上升
wait.IsEnd = true;
ComAxisStopCheck();
}
}
}
else if (wait.WaitType.Equals(WaitEnum.W009_ScanCode))
{
wait.IsEnd = (LastScanCodes.Count > 0);
}
else if (wait.WaitType.Equals(WaitEnum.W010_AgvStatus))
{
if (wait.AgvAction.Equals((int)ClientAction.Ready))
{
//Ready时使用状态判断,arrive时需要判断料架号是否正确
ClientAction agvA = AgvClient.GetAction(Config.AgvNodeName);
wait.IsEnd = ((int)agvA).Equals(wait.AgvAction);
}
if (!wait.IsEnd && span.TotalSeconds > 10)
{
//如果是等待AGV到达,等待有料架信号也算结束
if (wait.AgvAction.Equals((int)ClientAction.Arrive) && MoveInfo.MoveStep.Equals(StoreMoveStep.BI_00_ReadyShelf))
{
if (IOValue(IO_Type.LineTake_Check).Equals(IO_VALUE.HIGH))
{
LogInfo("BI_01_ReadyShelf 等待agv到达Arrive,检测到 LineTake_Check 信号,结束等待");
wait.IsEnd = true;
}
else if (IOValue(IO_Type.LineIn_Check).Equals(IO_VALUE.HIGH))
{
LogInfo("BI_01_ReadyShelf 等待agv到达Arrive,检测到 LineIn_Check 信号,结束等待");
wait.IsEnd = true;
}
}
else if (wait.AgvAction.Equals((int)ClientAction.Arrive) && MoveInfo.MoveStep.Equals(StoreMoveStep.BS_03_WaitEmptyAgv))
{
if (IOValue(IO_Type.LineTake_Check).Equals(IO_VALUE.LOW) && IOValue(IO_Type.LineIn_Check).Equals(IO_VALUE.LOW))
{
LogInfo("BS_03_WaitArrive 等待agv到达Arrive,检测到 LineTake_Check和LineIn_Check都没有信号,结束等待");
wait.IsEnd = true;
}
}
}
}
else if (wait.WaitType.Equals(WaitEnum.W011_DoorCloseEvent))
{
if (AgvClient.closeDoorTimeMap.ContainsKey(Config.AgvNodeName))
{
DateTime time = AgvClient.closeDoorTimeMap[Config.AgvNodeName];
if (time >= MoveInfo.LastSetpTime)
{
wait.IsEnd = true;
}
}
}
if (wait.IsEnd)
{
if (MoveInfo.OneWaitCanEndStep)
{
isOk = true;
break;
}
}
else
{
if (!MoveInfo.OneWaitCanEndStep)
{
isOk = false;
break;
}
}
}
if (isOk)
{
MoveInfo.EndStepWait();
}
else if (span.TotalSeconds > MoveInfo.TimeOutSeconds)
{
if (NotOkMsg.Contains(IO_Type.Compress_Check) && MoveInfo.MoveStep.Equals(StoreMoveStep.SO_09_CheckComSig))
{
CompressSigTimeOut = true;
NotOkMsg += "出库时料叉未检测到信号!";
}
WarnMsg = Name + "[" + MoveInfo.MoveType + "][" + MoveInfo.MoveStep + "]等待 " + NotOkMsg
+ "超时[" + FormUtil.GetSpanStr(span) + "] ";
int second = 10;
second = (int)(MoveInfo.TimeOutSeconds / span.TotalSeconds) * 10;
if (second > 120)
{
second = 120;
}
else if (second < 10)
{
second = 10;
}
LogUtil.error(WarnMsg, logType + 100, second);
Alarm(StoreAlarmType.IoSingleTimeOut, "", WarnMsg, MoveInfo.MoveType);
}
}
private static DateTime lastComRHomeTime = DateTime.Now;
private void InOutBackToP1(int InOut_P1)
{
//判断是否在P1,如果是,不需要运行
if (ACServerManager.isInPosition(Config.InOut_Axis, InOut_P1))
{
LogUtil.debug(Name + "进出轴当前已经在P1,不需要再回P1");
}
else
{
ACAxisMove(Config.InOut_Axis, InOut_P1, Config.InOutAxis_P1_Speed);
}
//StoreMove.WaitList.Add(WaitResultInfo.WaitAxisOrg(Config.InOut_Axis,IO_VALUE.HIGH));
}
#endregion
public ConcurrentQueue<InOutParam> waitOutStoreList = new ConcurrentQueue<InOutParam>();
private List<string> LastScanCodes = new List<string>();
private int ComTargetPosition = 0;
private int LastWidth = 0;
private int LastHeight = 0;
/// <summary>
/// 最后一次使用的料架号
/// </summary>
// private string LastRfidID = "";//服务器发送的出库rfid
private InOutParam LastOutParam = new InOutParam();
private string GetLastRfid()
{
//出库料架使用,返回上次使用的料架绑定的虚拟料架号
return LastOutParam.rfid;
}
#region 压紧轴压紧处理
private System.Timers.Timer axisCheckTimer = null;
private string TargetIoType = IO_Type.Compress_Check;
private IO_VALUE TargetIoValue = IO_VALUE.HIGH;
public bool ComAxisStartCheck(string targetIo = "", IO_VALUE value = IO_VALUE.HIGH)
{
if (String.IsNullOrEmpty(targetIo))
{
targetIo = IO_Type.Compress_Check;
}
if (axisCheckTimer == null)
{
axisCheckTimer = new System.Timers.Timer();
axisCheckTimer.AutoReset = true;
axisCheckTimer.Interval += 50;
axisCheckTimer.Elapsed += CheckTimer_Elapsed;
axisCheckTimer.Enabled = false;
}
TargetIoValue = value;
TargetIoType = targetIo;
axisCheckTimer.Start();
return true;
}
private bool ComAxisStopCheck()
{
if (!(axisCheckTimer == null))
{
ACServerManager.SuddenStop(Config.Comp_Axis);
axisCheckTimer.Stop();
}
return true;
}
private bool IsInProcess = false;
private void CheckTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
if (IsInProcess) { return; }
IsInProcess = true;
if (IOValue(TargetIoType).Equals(TargetIoValue))
{
LogUtil.info(Name + "压紧轴运动:检测到 " + TargetIoType + "=" + TargetIoValue + ",停止运动");
ACServerManager.SuddenStop(Config.Comp_Axis.DeviceName, Config.Comp_Axis.GetAxisValue());
ComAxisStopCheck();
}
IsInProcess = false;
}
#endregion
}
}
using Asa;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
public partial class AC_BOX_Bean
{
#region 扫码获取库位
/// <summary>
/// 数据接收
/// </summary>
/// <param name="message"></param>
private bool GetPosIdByCode()
{
try
{
if (LastWidth <= 0)
{
LastWidth = 7;
}
//string message = StoreManager.ProcessCode(LastWidth, LastHeight, LastScanCodes);
string message = MoveInfo.shelfLockDatas[MoveInfo.currShelfIndex].barcode;
if (message.Equals("") || string.IsNullOrEmpty(message))
{
CodeMsg = "未扫到二维码";
LogInfo("未扫到二维码");
return false;
}
if (storeRunStatus.Equals(StoreRunStatus.Wait))
{
LogInfo("二维码【 " + message + "】,设备未启动,不需要发送服务器");
return false;
}
// CodeMsg = "收到二维码【 " + message + "】,发送给服务器获取入库PosID";
LogUtil.info(Name + "二维码【 " + message + "】,发送给服务器获取入库PosID");
//发送扫码内容到服务器进行入库操作
Operation operation = getLineBoxStatus();
operation.op = 1;
operation.data = new Dictionary<string, string>() { { "code", message }, { "boxId", 1.ToString() }, { ParamDefine.rfid, CurrShelfID } };
string server = Setting_Init.http_server;
Operation resultOperation = HttpHelper.PostJson(StoreManager.GetPostApi(server), operation, false);
if (resultOperation == null)
{
CodeMsg = "二维码【" + message + "】没有收到服务器反馈";
LogInfo("二维码【 " + message + "】没有收到服务器反馈!");
return false;
}
else if (!string.IsNullOrEmpty(resultOperation.msg))
{
//如果有提示消息,直接显示提示
LogInfo("二维码【 " + message + "】 :" + resultOperation.msg);
return false;
}
if (resultOperation.op.Equals(1))
{
Dictionary<string, string> data = resultOperation.data;
if (data != null && data.ContainsKey(ParamDefine.posId) && data.ContainsKey(ParamDefine.plateH) && data.ContainsKey(ParamDefine.plateW))
{
//服务器返回时有:posId库位编号,plateW:料盘宽度,plateH:料盘高度,
//postId格式BoxId#位置
string posId = data[ParamDefine.posId];
int plateW = FormUtil.GetIntData(data, ParamDefine.plateW);
int plateH = FormUtil.GetIntData(data, ParamDefine.plateH);
int storeId = InOutParam.GetPosStoreId(posId);
//根据发送的posId获取位置列表
ACBoxPosition position = CSVPositionReader<ACBoxPosition>.GetPositon(posId);
if (position == null)
{ //出入库没有找到服务器发送的库位,需要打印日志方便查询原因
WarnMsg = "入库未找到库位:二维码【" + message + "】库位【" + posId + "】 ";
LogUtil.error(Name + "收到服务器入库命令:入库未找到库位:二维码【" + message + "】库位【" + posId + "】");
return false;
}
int p2 = Config.GetComP2(plateH).TargetComP2(); ;
int p3 = p2 + Config.GetCom_P3_P2(plateW);
LogInfo(" 收到服务器入库命令:库位号【" + posId + "】二维码【" + message + "】设置入库参数,压紧位置["+p2+"]["+p3+"] , 开始入库!");
MoveInfo.MoveParam.UpdatePosId(message, posId, plateW, plateH, p2, p3);
return true;
}
}
else if (resultOperation.op.Equals(2))
{
ReviceOutStoreProcess(resultOperation);
}
else if (resultOperation.op.Equals(5))
{
humBean.ProcessHumidityCMD(resultOperation);
}
else
{
LogUtil.error("收到服务器命令:op=" + resultOperation.op + ",未找到对应处理");
}
}
catch (Exception ex)
{
LogUtil.error(Name + "GetPosIdByCode" + ex.StackTrace);
}
return false;
}
/// <summary>
/// 扫码枪数据接收
/// </summary>
/// <param name="codeResultType">扫码结果</param>
/// <returns></returns>
public enum CodeResultType
{
/// <summary>
/// 未扫到二维码
/// </summary>
NoCode,
/// <summary>
/// 设备未启动
/// </summary>
DeviceNotOpen,
/// <summary>
///未收到服务器反馈
/// </summary>
NotResponseFromServer,
WarnMsg,
/// <summary>
/// 未找到库位
/// </summary>
NotFoundPos,
/// <summary>
/// 不属于该仓位
/// </summary>
NotPosForPutIn,
Error,
Success
}
private bool GetPosIdByCode(int rfidLoc, out CodeResultType codeResultType)
{
try
{
if (LastWidth <= 0)
{
LastWidth = 7;
}
string message = StoreManager.ProcessCode(LastWidth, LastHeight, LastScanCodes);
if (message.Equals("") || string.IsNullOrEmpty(message))
{
CodeMsg = "未扫到二维码";
LogInfo("未扫到二维码");
codeResultType = CodeResultType.NoCode;
return false;
}
if (storeRunStatus.Equals(StoreRunStatus.Wait))
{
LogInfo("二维码【 " + message + "】,设备未启动,不需要发送服务器");
codeResultType = CodeResultType.DeviceNotOpen;
return false;
}
// CodeMsg = "收到二维码【 " + message + "】,发送给服务器获取入库PosID";
LogUtil.debug (Name + "二维码【 " + message + "】,发送给服务器获取入库PosID");
//查询该料盘所在料仓以及仓位
StoreManager.ResultType resultType = StoreManager.GetPosForPutIn(Name, Config, message, CurrShelfID, rfidLoc, out bool isLockInfoMatch);
if (resultType == StoreManager.ResultType.Error)
{
codeResultType = CodeResultType.Error;
return false;
}
else if(resultType == StoreManager.ResultType.NotInThisBox)
{
codeResultType = CodeResultType.NotPosForPutIn;
return false;
}
if (!isLockInfoMatch && MoveInfo.IsShelfLocked)//锁定信息不匹配则从第一层开始重新取料,一个料架只重新开始一次
{
MoveInfo.IsShelfLocked = false;
MoveInfo.currShelfIndex = -1;
LogUtil.info(Name + "该锁定料架" + CurrShelfID + "上的料盘信息不匹配,即将从开始位置循环取料");
}
//发送扫码内容到服务器进行入库操作
Operation operation = getLineBoxStatus();
operation.op = 1;
operation.data = new Dictionary<string, string>() { { "code", message }, { "boxId", 1.ToString() }, { ParamDefine.rfid, CurrShelfID } };
string server = Setting_Init.http_server;
Operation resultOperation = HttpHelper.PostJson(StoreManager.GetPostApi(server), operation, false);
if (resultOperation == null)
{
CodeMsg = "二维码【" + message + "】没有收到服务器反馈";
LogInfo("二维码【 " + message + "】没有收到服务器反馈!");
codeResultType = CodeResultType.NotResponseFromServer;
return false;
}
else if (!string.IsNullOrEmpty(resultOperation.msg))
{
//如果有提示消息,直接显示提示
LogInfo("二维码【 " + message + "】 :" + resultOperation.msg);
codeResultType = CodeResultType.WarnMsg;
return false;
}
if (resultOperation.op.Equals(1))
{
Dictionary<string, string> data = resultOperation.data;
if (data != null && data.ContainsKey(ParamDefine.posId) && data.ContainsKey(ParamDefine.plateH) && data.ContainsKey(ParamDefine.plateW))
{
//服务器返回时有:posId库位编号,plateW:料盘宽度,plateH:料盘高度,
//postId格式BoxId#位置
string posId = data[ParamDefine.posId];
int plateW = FormUtil.GetIntData(data, ParamDefine.plateW);
int plateH = FormUtil.GetIntData(data, ParamDefine.plateH);
int storeId = InOutParam.GetPosStoreId(posId);
//根据发送的posId获取位置列表
ACBoxPosition position = CSVPositionReader<ACBoxPosition>.GetPositon(posId);
if (position == null)
{ //出入库没有找到服务器发送的库位,需要打印日志方便查询原因
WarnMsg = "入库未找到库位:二维码【" + message + "】库位【" + posId + "】 ";
LogUtil.error(Name + "收到服务器入库命令:入库未找到库位:二维码【" + message + "】库位【" + posId + "】");
codeResultType = CodeResultType.NotFoundPos;
return false;
}
int p2 = Config.GetComP2(plateH).TargetComP2(); ;
int p3 = p2 + Config.GetCom_P3_P2(plateW);
LogInfo(" 收到服务器入库命令:库位号【" + posId + "】二维码【" + message + "】设置入库参数,压紧位置[" + p2 + "][" + p3 + "] , 开始入库!");
MoveInfo.MoveParam.UpdatePosId(message, posId, plateW, plateH, p2, p3);
codeResultType = CodeResultType.Success;
return true;
}
}
else if (resultOperation.op.Equals(2))
{
ReviceOutStoreProcess(resultOperation);
}
else if (resultOperation.op.Equals(5))
{
humBean.ProcessHumidityCMD(resultOperation);
}
else
{
LogUtil.error("收到服务器命令:op=" + resultOperation.op + ",未找到对应处理");
}
}
catch (Exception ex)
{
LogUtil.error(Name + "GetPosIdByCode" + ex.StackTrace);
}
codeResultType = CodeResultType.Error;
return false;
}
#endregion
}
}
using Asa;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
/// <summary>
/// 料架进出料仓处理:出入库模块共用
/// </summary>
public partial class AC_BOX_Bean
{
/// <summary>
/// 开始料架入库
/// </summary>
public void StartShelfInStore()
{
bool canStart = (storeRunStatus.Equals(StoreRunStatus.Runing)
&& MoveInfo.MoveType.Equals(StoreMoveType.None));
if (!canStart || isInSuddenDown || isNoAirCheck || (alarmType.Equals(StoreAlarmType.None).Equals(false)))
{
return;
}
clearNGShelfPos();
setStatus(StoreRunStatus.Busy, StoreStatus.InStoreExecute);
// EmprtShelfList = new ConcurrentQueue<string>();
if (IOValue(IO_Type.LineIn_Check).Equals(IO_VALUE.HIGH))
{
MoveInfo.NewMove(StoreMoveType.InStore, new InOutParam());
MoveInfo.MoveParam.MoveP = new LineMoveP(Config);
MoveInfo.ShelfPositionList = new List<string>(ShelfPosList);
MoveInfo.NextMoveStep(StoreMoveStep.BI_01_DoorOpen);
LogInfo(" 空闲中,检测到入料口有料架,启动料架入库 ");
// CylinderMove(MoveInfo, IO_Type.EntranceDoor_Close, IO_Type.EntranceDoor_Open);
// DoorBean.StartOpen(MoveInfo);
}
else if (IOValue(IO_Type.LineTake_Check).Equals(IO_VALUE.HIGH))
{
MoveInfo.NewMove(StoreMoveType.InStore, new InOutParam());
MoveInfo.MoveParam.MoveP = new LineMoveP(Config);
MoveInfo.ShelfPositionList = new List<string>(ShelfPosList);
MoveInfo.NextMoveStep(StoreMoveStep.BI_06_DoorClose);
LogInfo(" 空闲中,检测到入料口有料架,启动料架入库 ");
}
else
{
LogInfo(" 空闲中,需要料架入库,料架入库 " + ":入料口移门打开,更新 WaitShelfEnter=false");
WaitShelfEnter = false;
MoveInfo.NewMove(StoreMoveType.InStore, new InOutParam());
MoveInfo.MoveParam.MoveP = new LineMoveP(Config);
MoveInfo.ShelfPositionList = new List<string>(ShelfPosList);
MoveInfo.NextMoveStep(StoreMoveStep.BI_01_DoorOpen);
DoorBean.StartOpen(MoveInfo);
}
}
private void ShelfEnterProcess()
{
string mark = GetMarkInfo();
string moveName = "入库料架[" + CurrShelfID + "]";
bool instoreShelf = true;
if (MoveInfo.MoveType.Equals(StoreMoveType.OutStore))
{
instoreShelf = false;
moveName = "出库料架[" + CurrShelfID + "][" + mark + "]";
}
if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_00_ReadyShelf))
{
if (IOValue(IO_Type.LineIn_Check).Equals(IO_VALUE.HIGH))
{
BI_04_WaitTakeSingle(moveName);
}
else if (IOValue(IO_Type.LineTake_Check).Equals(IO_VALUE.HIGH))
{
BI_04_WaitTakeSingle(moveName);
}
else
{
// MoveInfo.ShelfPositionList = new List<string>(ShelfPosList);
LogRunStepInfo($"{moveName} AGV已到达,打开入料口移门");
MoveInfo.NextMoveStep(StoreMoveStep.BI_01_DoorOpen);
DoorBean.StartOpen(MoveInfo);
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_01_DoorOpen))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_03_LineRun);
LogRunStepInfo($"{moveName}调用AgvClient.MayEnter,线体正转,等待LineIn_Check 或LineTake_Check 信号");
setAgvStatus(mark, "", ClientAction.MayEnter, ClientLevel.High, true);
LineRun();
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LineIn_Check, IO_VALUE.HIGH));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LineTake_Check, IO_VALUE.HIGH));
MoveInfo.OneWaitCanEndStep = true;
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_03_LineRun))
{
BI_04_WaitTakeSingle(moveName);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_04_WaitTakeSingle))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_05_LineStop);
LogRunStepInfo($"{moveName}调用Agv Config.AgvNodeName FinishEnter,取料位检测到信号,继续转动");
LineRun();
setAgvStatus(mark, "", ClientAction.FinishEnter, ClientLevel.High, true);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_05_LineStop))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_06_DoorClose);
LogRunStepInfo($"{moveName}入料口移门关闭 ");
DoorBean.StartClose(MoveInfo);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_06_DoorClose))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_07_LineRun);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(7000));
LogRunStepInfo($"{moveName}继续转动 7000ms");
LineRun();
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_07_LineRun))
{
LineStop();
UpdateShelfId();
//如果未读到料架号,将料架送出
if (CurrShelfID.EndsWith("00") && MoveInfo.MoveType.Equals(StoreMoveType.OutStore))
{
LogRunStepInfo($" 执行出库【{MoveInfo.MoveParam.ToStr()}】失败,料架号[{CurrShelfID}]无效,加入等待队列并送出料架,稍后重新出库");
waitOutStoreList.Enqueue(MoveInfo.MoveParam.NewParam());
MoveInfo.MoveParam.rfid = CurrShelfID;
//送出料架,并且记录出库信息,等会重新出库
StartShelfOut();
return;
}
//如果该料架为入库料架,此时有出库任务,执行入库任务
if (StoreManager.CheckShelfInfo(CurrShelfID) && MoveInfo.MoveType.Equals(StoreMoveType.OutStore))
{
LogRunStepInfo($"出库 {mark}->入库 料架号[{CurrShelfID}]为入库料架,进行入库");
MoveInfo.NewMove(StoreMoveType.InStore, new InOutParam());
MoveInfo.MoveParam.MoveP = new LineMoveP(Config);
MoveInfo.ShelfPositionList = new List<string>(ShelfPosList);
mark = "0";
instoreShelf = true;
}
MoveInfo.NextMoveStep(StoreMoveStep.BI_08_LocationUp);
LogRunStepInfo($"{moveName}停止线体,读取料架{CurrShelfID},设置{Config.AgvNodeName}=None");
setAgvStatus(mark);
// CylinderMove(MoveInfo, IO_Type.LocationCylinder_Down, IO_Type.LocationCylinder_Up);
if (!instoreShelf)
{
if (MoveInfo.MoveParam.CurShelfPosID.Equals(""))
{
MoveInfo.MoveParam.UpdateShelfPosId(ShelfPosList[0]);
LogRunStepInfo($"ShelfPosID未设置,默认ShelfPosID={MoveInfo.MoveParam.CurShelfPosID}");
}
// LastRfidID = MoveInfo.MoveParam.rfid;
LastOutParam = MoveInfo.MoveParam;
}
else
{
LastOutParam = new InOutParam();
// LastRfidID = "";
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_08_LocationUp))
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_09_TopCylinderUp);
LogRunStepInfo(moveName + CurrShelfID + "顶升上升");
CylinderMove(MoveInfo, IO_Type.TopCylinder_Down, IO_Type.TopCylinder_Up);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_09_TopCylinderUp))
{
if (instoreShelf)
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_10_StartGetTray);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime((int)TimeSpan.FromMinutes(75).TotalMilliseconds));
//获取料架的锁定状态
bool lockState = StoreManager.GetShelfLockInfo(Name, CID, CurrShelfID, out MoveInfo.shelfLockDatas);
if (lockState && MoveInfo.shelfLockDatas != null)
{
MoveInfo.IsShelfLocked = true;
if (MoveInfo.shelfLockDatas.Count.Equals(0))
LogRunStepInfo(moveName + "该锁定料架上的料盘不属于该料仓,即将送出锁定料架");
else
LogRunStepInfo(moveName + "开始到料架指定位置取料盘 ");
}
else
{
MoveInfo.IsShelfLocked = false;
LogRunStepInfo(moveName + "开始循环料架取料盘 ");
}
MoveInfo.EndStepWait();
}
else
{
if (string.IsNullOrEmpty(StoreManager.FindRealRfidByTempRfid(MoveInfo.MoveParam.rfid)))
{
//新料架,检查料架上是否有治具
MoveInfo.NextMoveStep(StoreMoveStep.SO_PreCheck_01_StartGetTray);
}
else
{
SO_03_ToBagPosition();
}
}
}
}
private void UpdateShelfId()
{
//读取RFID
RFIDData data = RFIDManager.ReadRFID(Config.RFID_IP, true);
CurrShelfID = data.NumStr();
LogRunStepInfo("更新当前料架号CurrShelfID=【" + CurrShelfID + "】,LastRfidID=【" + GetLastRfid() + "】");
}
/// <summary>
/// 等待取料位检测到信号
/// </summary>
/// <param name="moveName"></param>
private void BI_04_WaitTakeSingle(string moveName)
{
MoveInfo.NextMoveStep(StoreMoveStep.BI_04_WaitTakeSingle);
LogRunStepInfo($"{moveName} 线体正转,等待LineIn_Check=Low, 信号LineTake_Check=High");
LineRun();
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LineIn_Check, IO_VALUE.LOW));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LineTake_Check, IO_VALUE.HIGH));
}
/// <summary>
/// 所有料盘已取料完成,送出料架
/// </summary>
private void StartShelfOut()
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_01_TopDown);
if (MoveInfo.MoveType.Equals(StoreMoveType.OutStore))
{
string mark = GetMarkInfo();
LogRunStepInfo("送出[" + CurrShelfID + "][" + mark + "]:顶升下降,调用 NeedLeave[" + mark + "][" + CurrShelfID + "] ");
AgvClient.NeedLeave(Config.AgvNodeName, mark, CurrShelfID);
}
else
{
LogRunStepInfo("送出空料架[" + CurrShelfID + "]:顶升下降,调用 NeedLeave[0][" + CurrShelfID + "],clearPutInRfid[" + CurrShelfID + "]");
AgvClient.NeedLeave(Config.AgvNodeName, "0", CurrShelfID);
StoreManager.clearPutInRfid(Name, CurrShelfID);
ACAxisMove(Config.UpDown_Axis, Config.UpDownAxis_P1, Config.UpDownAxis_P1_Speed);
}
CylinderMove(MoveInfo, IO_Type.TopCylinder_Up, IO_Type.TopCylinder_Down);
}
private void ShelfOutProcess()
{
string mark = GetMarkInfo();
string moveName = "送出入库料架[" + CurrShelfID + "][" + mark + "]";
if (MoveInfo.MoveType.Equals(StoreMoveType.OutStore))
{
moveName = "送出出库料架[" + CurrShelfID + "][" + mark + "]";
}
// LogCPU();
if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_01_TopDown))
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_02_LocatinDown);
LogRunStepInfo(moveName + "定位气缸下降");
// CylinderMove(MoveInfo, IO_Type.LocationCylinder_Up, IO_Type.LocationCylinder_Down);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_02_LocatinDown))
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_03_WaitEmptyAgv);
MoveInfo.TimeOutSeconds = 600;
//MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(30000));
//等待agv到达
MoveInfo.WaitList.Add(WaitResultInfo.WaitAgvAction((int)ClientAction.Arrive));
LogRunStepInfo(moveName + "再次调用 NeedLeave[" + mark + "][" + CurrShelfID + "],等待Agv " + Config.AgvNodeName + " Arrive ,最多等待1200秒");
setAgvStatus(mark, CurrShelfID, ClientAction.NeedLeave, ClientLevel.High, true);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_03_WaitEmptyAgv))
{
//agv到达
if (AgvClient.GetAction(Config.AgvNodeName).Equals(ClientAction.Arrive))
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_04_DoorOpen);
LogRunStepInfo(moveName + "agv到达,打开入料口移门");
DoorBean.StartOpen(MoveInfo);
}
else
{
//如果料架已被拉出,也算结束
if (IOValue(IO_Type.LineIn_Check).Equals(IO_VALUE.LOW) && IOValue(IO_Type.LineTake_Check).Equals(IO_VALUE.LOW))
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_06_LineBackRun);
AgvClient.SetToNone(Config.AgvNodeName);
//如果agv未到达,直接结束
MoveEndToRuningStatus();
//EmprtShelfList = new ConcurrentQueue<string>();
InOutStoreLog(moveName + "等待Agv " + Config.AgvNodeName + " Arrive超时,检测不到料架信号,认为料架已离开,出库结束,设置" + Config.AgvNodeName + "=None");
}
else
{
TimeSpan span = DateTime.Now - MoveInfo.LastSetpTime;
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime((int)span.TotalMilliseconds + 30000));
LogRunStepInfo(moveName + "等待Agv " + Config.AgvNodeName + " Arrive超时,再等待30秒");
}
}
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_04_DoorOpen))
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_05_WaitReady);
MoveInfo.TimeOutSeconds = 120;
LogRunStepInfo(moveName + "移门已打开,调用 MayLeave [" + mark + "][" + CurrShelfID + "],等待agv " + Config.AgvNodeName + " Ready");
setAgvStatus(mark, CurrShelfID, ClientAction.MayLeave, ClientLevel.High, true);
//等待agv到达
MoveInfo.WaitList.Add(WaitResultInfo.WaitAgvAction((int)ClientAction.Ready));
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_05_WaitReady))
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_06_LineBackRun);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
LogRunStepInfo(moveName + "收到agv " + Config.AgvNodeName + " Ready ,线体开始反转");
LineBackRun();
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_06_LineBackRun))
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_07_WaitShelfOut);
LogRunStepInfo(moveName + "等待取料工位无信号 ");
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LineTake_Check, IO_VALUE.LOW));
// MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LineIn_Check, IO_VALUE.HIGH));
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_07_WaitShelfOut))
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_08_WaitLineIn);
LogRunStepInfo(moveName + "等待 入料口有信号,最多等待30秒");
// MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LineTake_Check, IO_VALUE.LOW));
MoveInfo.OneWaitCanEndStep = true;
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(30000));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LineIn_Check, IO_VALUE.HIGH));
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_08_WaitLineIn))
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_09_WaitTime);
LogRunStepInfo(moveName + "再转动1000 , 等待入料口无信号,清理RFID");
RFIDManager.ReadRFID(Config.RFID_IP, true);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LineIn_Check, IO_VALUE.LOW));
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_09_WaitTime))
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_10_WaitAGVLeave);
MoveInfo.TimeOutSeconds = 180;
LogRunStepInfo(moveName + "等待DoorClose事件,最多等待180000 ");
MoveInfo.OneWaitCanEndStep = true;
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(180000));
MoveInfo.WaitList.Add(WaitResultInfo.WaitDoorClose());
//MoveInfo.WaitList.Add(WaitResultInfo.WaitAgvAction(action.FinishOut));
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_10_WaitAGVLeave))
{
MoveInfo.NextMoveStep(StoreMoveStep.BS_11_CloseDoor);
LogRunStepInfo(moveName + "停止线体转动,关闭仓门 ,发送FinishLeave ,等待最少5000");
setAgvStatus(mark, CurrShelfID, ClientAction.FinishLeave, ClientLevel.High, true);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(5000));
LineStop();
DoorBean.StartClose(MoveInfo);
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_11_CloseDoor))
{
//结束
MoveEndToRuningStatus();
setAgvStatus();
//EmprtShelfList = new ConcurrentQueue<string>();
LogRunStepInfo(moveName + "料架" + CurrShelfID + $"已离开[{getNGShelfPos()}],设置" + Config.AgvNodeName + "=None,清理rfid");
clearNGShelfPos();
RFIDManager.ReadRFID(Config.RFID_IP, true);
CurrShelfID = "";
LastOutParam = new InOutParam();
//LastRfidID = "";
}
}
}
}

using Asa;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
/// <summary>
/// 与服务器通信定时器,每1秒向服务器通知一次状态,同时执行出库操作
/// </summary>
public partial class AC_BOX_Bean
{
private string CodeMsg = "";
private bool isInProcess = false;
private DateTime lastConTime = DateTime.Now;
public void server_connect_timer_Tick(object sender, EventArgs e)
{
if (isInProcess)
{
TimeSpan span = DateTime.Now - lastConTime;
if (span.TotalSeconds < 60)
{
return;
}
}
isInProcess = true;
lastConTime = DateTime.Now;
try
{
////HumitureController.QueryData();
//humBean.HumidityProcess(this);
//if (StoreManager.IsConnectServer)
//{
// SendLineStatus();
//}
}
catch (Exception ex)
{
LogUtil.error(Name + "定时SendLineStatus出错:" + ex.ToString());
}
finally
{
isInProcess = false;
}
}
/// <summary>
/// 获取整个料仓的状态
/// </summary>
public Operation getLineBoxStatus()
{
//构建发送给服务器的对象
Operation lineOperation = new Operation();
lineOperation.msg = "";
lineOperation.alarmList = new List<AlarmInfo>();
lineOperation.cid = CID;
lineOperation.seq = ConfigAppSettings.nextSeq();
lineOperation.status = 1;
if (WarnMsg != "")
{
lineOperation.status = (int)StoreStatus.Warning;
lineOperation.msg = WarnMsg;
}
lineOperation.status = (int)StoreStatus.StoreOnline;
BoxStatus boxStatus = new BoxStatus();
boxStatus.boxId = 1;
boxStatus.msg = WarnMsg;
lineOperation.msg = WarnMsg;
if (WarnMsg.Equals(""))
{
boxStatus.msg = CodeMsg;
lineOperation.msg = CodeMsg;
}
CodeMsg = "";
//WarnMsg = "";
//状态
boxStatus.status = (int)storeStatus;
if (IsDebug)
{
boxStatus.status = (int)StoreStatus.Debugging;
}
else if (storeStatus.Equals(StoreStatus.OutStoreBoxEnd) || storeStatus.Equals(StoreStatus.InStoreEnd))
{
boxStatus.data.Add(ParamDefine.posId, lastPosId);
}
else if (!lastPosId.Equals(""))
{
boxStatus.data.Add(ParamDefine.posId, lastPosId);
boxStatus.status = (int)lastPosIdStatus;
if (lastPosId != "")
{
LogUtil.info("给服务器发送出入库完成消息:" + Name + ",status【" + lastPosIdStatus + "】posId【" + lastPosId + "】");
}
lastPosId = "";
}
//温湿度
//ASTemperateParam param = HumitureServer.GetTemperateParam(Config.Temperate_Serveraddress);
HumitureParam param = humBean.LastData;
if (param != null)
{
boxStatus.humidity = param.Humidity.ToString();
boxStatus.temperature = param.Temperate.ToString();
}
lineOperation.boxStatus.Add(1, boxStatus);
if (!alarmType.Equals(StoreAlarmType.None))
{
lineOperation.alarmList.Add(alarmInfo);
}
return lineOperation;
}
public void SendLineStatus()
{
DateTime time = DateTime.Now;
//构建发送给服务器的对象
Operation lineOperation = getLineBoxStatus();
//如果还没湿度范围,先获取
if (humBean.NeedGetTem())
{
lineOperation.op = 5;
LogUtil.error(Name + "没有湿度预警范围,需要从服务器获取,发送OP=" + lineOperation.op, DeviceID + 105);
}
string server = Setting_Init.http_server;
Operation resultOperation = HttpHelper.PostJson(StoreManager.GetPostApi(server), lineOperation, false);
//发送状态信息到服务器
if (resultOperation == null || (resultOperation.op <= 0))
{
//判断服务端是否返回出库操作
return;
}
if (resultOperation.op.Equals(1))
{
// ReviceInStoreProcess("", resultOperation);
}
else if (resultOperation.op.Equals(2))
{
ReviceOutStoreProcess(resultOperation);
}
else if (resultOperation.op.Equals(5))
{
humBean.ProcessHumidityCMD(resultOperation);
}
else
{
LogUtil.error("收到服务器命令:op=" + resultOperation.op + ",未找到对应处理");
}
TimeSpan span = DateTime.Now - time;
if (span.TotalMilliseconds > 10)
{
LogUtil.info(Name + "执行TimerProcess 共处理了【" + span.TotalMilliseconds + "】毫秒");
}
}
private void ReviceOutStoreProcess(Operation resultOperation)
{
DateTime time = DateTime.Now;
Dictionary<string, string> data = resultOperation.data;
if (data != null && data.ContainsKey(ParamDefine.posId)
&& data.ContainsKey(ParamDefine.plateH) && data.ContainsKey(ParamDefine.plateW))
{
char splitChar = '|';
string[] posIdArray = data[ParamDefine.posId].Split(splitChar);
string[] plateWArray = data[ParamDefine.plateW].Split(splitChar);
string[] plateHArray = data[ParamDefine.plateH].Split(splitChar);
bool urgentReel = FormUtil.GetBoolData(data, ParamDefine.urgentReel);
bool cutReel = FormUtil.GetBoolData(data, ParamDefine.cutReel);
bool smallReel = FormUtil.GetBoolData(data, ParamDefine.smallReel);
string rfid = data.ContainsKey(ParamDefine.rfid) ? data[ParamDefine.rfid] : "";
int rfidLoc = FormUtil.GetIntData(data, ParamDefine.rfidLoc);
string barcode = data.ContainsKey(ParamDefine.barcode) ? data[ParamDefine.barcode] : "";
string realRfid = data.ContainsKey(ParamDefine.realRfid) ? data[ParamDefine.realRfid] : "";
int taskCount = FormUtil.GetIntData(data, ParamDefine.taskCount, 0);
//urgentReel: true 表示紧急料,需要出到料串上
//cutReel: true 表示分盘料,需要出到料串上
//smallReel: true 小料(7x8),放置到小料架上
//rfid: 分配的料架RFID
//rfidLoc: 料架的架位,值为 - 1时,可以自由分配皮带线, 小料时,架位为1 - 46优先走1 / 2号皮带线,47 - 92优先走3 / 4号皮带线, 70,71,72时只能分配到3 / 4号皮带线; 大料时,架位1 - 6优先走1 / 2号皮带线, 7 - 12优先走3 / 4号皮带线
string dataStr = JsonHelper.SerializeObject(data);
LogUtil.info("收到服务器出库消息:【" + dataStr + "】");
int index = -1;
foreach (string posId in posIdArray)
{
index++;
int plateW = Convert.ToInt32(plateWArray[index]);
int plateH = Convert.ToInt32(plateHArray[index]);
string shelfPosID = StoreManager.GetShelfIDByLoc(rfidLoc, ShelfPosList);
InOutParam inoutParam = new InOutParam(barcode, posId, shelfPosID, plateW, plateH, urgentReel, cutReel, smallReel, rfid, rfidLoc, taskCount, realRfid);
//根据发送的posId获取位置列表
ACBoxPosition position = CSVPositionReader<ACBoxPosition>.GetPositon(posId);
if (position == null)
{
//出入库没有找到服务器发送的库位,需要打印日志方便查询原因
WarnMsg = Name + "未找到库位:【" + inoutParam.ToStr() + "】";
LogUtil.error(WarnMsg);
continue;
}
try
{
//判断是否接收过此库位的出库信息
if (MoveInfo.MoveType.Equals(StoreMoveType.OutStore) && MoveInfo.MoveParam.PosID.Equals(posId))
{
LogUtil.error(Name + " 出库命令【" + inoutParam.ToStr() + "】重复,正在【" + posId + "】出库中");
continue;
}
//判断排队列表中是否已存在
List<InOutParam> reviceList = new List<InOutParam>(waitOutStoreList);
reviceList = (from m in reviceList where m.PosID.Equals(posId) select m).ToList<InOutParam>();
if (reviceList.Count > 0)
{
LogUtil.error(Name + " 出库命令【" + inoutParam.ToStr() + "】重复,排队列表中已存在【" + reviceList[0].ToStr() + "】");
continue;
}
}
catch (Exception ex)
{
LogUtil.error(Name + "验证出库【" + inoutParam.ToStr() + "】是否重复出错:" + ex.ToString());
}
StartExecuctOut(inoutParam);
}
TimeSpan span = DateTime.Now - time;
if (span.TotalMilliseconds > 10)
{
LogInfo(Name + "执行 ReviceOutStoreProcess 共处理了【" + span.TotalMilliseconds + "】毫秒");
}
}
}
}
}
\ No newline at end of file
......@@ -101,9 +101,9 @@ namespace OnlineStore.DeviceLibrary
}
}
public bool StartOpen(StoreMoveInfo moveInfo)
public bool StartOpen(DeviceMoveInfo moveInfo)
{
bool UseDoor = ConfigAppSettings.GetIntValue(Setting_Init.UseDoor).Equals(1);
bool UseDoor = Setting_Init.UseDoor;
if (!UseDoor)
{
return false;
......@@ -124,9 +124,9 @@ namespace OnlineStore.DeviceLibrary
return Start(IO_Type.EntranceDoor_Open, IO_Type.EntranceDoor_Open);
}
public bool StartClose(StoreMoveInfo moveInfo)
public bool StartClose(DeviceMoveInfo moveInfo)
{
bool UseDoor = ConfigAppSettings.GetIntValue(Setting_Init.UseDoor).Equals(1);
bool UseDoor = Setting_Init.UseDoor;
if (!UseDoor)
{
return false;
......
......@@ -65,8 +65,8 @@ namespace OnlineStore.DeviceLibrary
public bool TempOrHumidityIsAlarm = false;
public DateTime TempAlarmTime = DateTime.Now;
private float StartBlowValue = (float)ConfigAppSettings.GetNumValue(Setting_Init.StartBlowValue);
private float StopBlowValue = (float)ConfigAppSettings.GetNumValue(Setting_Init.StopBlowValue);
private float StartBlowValue = (float)Setting_Init.StartBlowValue;
private float StopBlowValue = (float)Setting_Init.StopBlowValue;
public string currTempStr = "";
internal void HumidityProcess(AC_BOX_Bean box)
{
......
......@@ -29,8 +29,11 @@ namespace OnlineStore.DeviceLibrary
public Dictionary<int, AC_BOX_Bean> BoxMap = new Dictionary<int, AC_BOX_Bean>();
public Store_Config Config { get; set; }
public bool UseBuzzer = ConfigAppSettings.GetIntValue(Setting_Init.UseBuzzer).Equals(1);
public bool AutoShelfInstore = ConfigAppSettings.GetIntValue(Setting_Init.AutoShelfInstore).Equals(1);
public bool UseBuzzer = Setting_Init.UseBuzzer;
/// <summary>
/// 入口有料架自动入库
/// </summary>
public bool AutoShelfInstore = Setting_Init.AutoShelfInstore;
List<string> rfidList = new List<string>();
#region 初始化
......@@ -49,7 +52,7 @@ namespace OnlineStore.DeviceLibrary
this.Config = lineConfig;
this.DeviceID = lineConfig.DeviceID;
MoveInfo = new StoreMoveInfo(DeviceID);
MoveInfo = new DeviceMoveInfo(DeviceID);
Name = (" Store_" + Config.CID + " ").ToUpper();
List<string> ioList = new List<string>();
......@@ -324,7 +327,7 @@ namespace OnlineStore.DeviceLibrary
{
//取新的Io状态
IO_VALUE autoSingle = IOValue(IO_Type.Reset_BTN);
if (ConfigAppSettings.GetIntValue(Setting_Init.App_AutoRun).Equals(1))
if (Setting_Init.App_AutoRun)
{
if (autoSingle.Equals(IO_VALUE.HIGH) && lastAutoRun.Equals(IO_VALUE.LOW))
{
......
......@@ -23,7 +23,7 @@ namespace OnlineStore.DeviceLibrary
public static Store_Config Config = null;
public static Dictionary<int, BaseConfig> AllConfigMap = null;
private static bool isInit = false;
public static bool IsConnectServer = !ConfigAppSettings.GetValue(Setting_Init.http_server).Equals("");
public static bool IsConnectServer = !Setting_Init.http_server.Equals("");
public StoreManager()
{
}
......@@ -55,7 +55,7 @@ namespace OnlineStore.DeviceLibrary
BaseConfig.ProIOIpMap = new Dictionary<string, string>();
if (!isInit)
{
string server = ConfigAppSettings.GetValue(Setting_Init.http_server);
string server = Setting_Init.http_server;
if (server.Equals(""))
{
IsConnectServer = false;
......@@ -69,31 +69,29 @@ namespace OnlineStore.DeviceLibrary
CheckEnum(typeof(StoreRunStatus));
isInit = true;
string storeType = ConfigAppSettings.GetValue(Setting_Init.Store_Type);
int count = ConfigAppSettings.GetIntValue(Setting_Init.store_count);
string storeType = Setting_Init.Store_Type;
int count = Setting_Init.store_count;
LogUtil.info("配置的料仓 类型=" + storeType + ",开始加载料仓配置");
string appPath = Application.StartupPath;
string CID = ConfigAppSettings.GetValue(Setting_Init.Store_CID);
Dictionary<int, AC_BOX_Config> storeConfig = new Dictionary<int, AC_BOX_Config>();
if (storeType == StoreType.RC_AC_PA)
{
string linefilePath = appPath + ConfigAppSettings.GetValue(Setting_Init.Store_ConfigPath);
Config = CSVConfigReader.LoadLineConfig(0, CID, "Line", linefilePath);
string linefilePath = appPath + Setting_Init.Store_ConfigPath;
Config = CSVConfigReader.LoadLineConfig(0, Setting_Init.Store_CID, "Line", linefilePath);
AllConfigMap.Add(0, Config);
string moveEquipConfig = ConfigAppSettings.GetValue(Setting_Init.BOX_ConfigPath);
string moveEquipConfig = Setting_Init.BOX_ConfigPath;
for (int i = 1; i <= count; i++)
{
string nameStr = i.ToString().PadLeft(1, '0');
string config = appPath + moveEquipConfig.Replace(".csv", "_" + nameStr + ".csv");
string storeIdConfig = Setting_Init.Store_CID + "_" + i;
string boxCid = ConfigAppSettings.GetValue(storeIdConfig);
string boxCid = ConfigAppSettings.GetValue("Store_CID" + "_" + i, "packing-");
AC_BOX_Config moveConfig = CSVConfigReader.LoadBoxConfig(i, boxCid, "BOX", config);
AllConfigMap.Add(i, moveConfig);
storeConfig.Add(i, moveConfig);
}
string positionConfigFile = appPath + ConfigAppSettings.GetValue(Setting_Init.Store_Position_Config);
string positionConfigFile = appPath + Setting_Init.Store_Position_Config;
if (count > 1 || (!File.Exists(positionConfigFile)))
{
for (int i = 1; i <= count; i++)
......@@ -111,7 +109,7 @@ namespace OnlineStore.DeviceLibrary
}
string shelfConfig = appPath + ConfigAppSettings.GetValue(Setting_Init.Shelf_Position_Config);
string shelfConfig = appPath + Setting_Init.Shelf_Position_Config;
//if (File.Exists(shelfConfig))
//{
// CSVPositionReader<ShelfPosition>.AddCSVFile(shelfConfig);
......@@ -150,7 +148,7 @@ namespace OnlineStore.DeviceLibrary
{
//位置配置到文件中
string appPath = Application.StartupPath;
string configFile = appPath + ConfigAppSettings.GetValue(Setting_Init.BOX_ConfigPath);
string configFile = appPath + Setting_Init.BOX_ConfigPath;
if (!Directory.Exists(configFile))
{
......@@ -191,10 +189,10 @@ namespace OnlineStore.DeviceLibrary
LogUtil.error(box.Name + "GetPositon[" + param.PosID + "]=null,没有库位不能执行出入库");
return false;
}
ShelfPosition sp = CSVPositionReader<ShelfPosition>.GetPositon(param.ShelfPosID);
ShelfPosition sp = CSVPositionReader<ShelfPosition>.GetPositon(param.CurShelfPosID);
if (sp == null && needCheckShelf)
{
LogUtil.error(box.Name + "GetPositon[" + param.ShelfPosID + "]=null,没有库位不能执行出入库");
LogUtil.error(box.Name + "GetPositon[" + param.CurShelfPosID + "]=null,没有库位不能执行出入库");
return false;
}
if (param.PlateH <= 0)
......@@ -256,7 +254,7 @@ namespace OnlineStore.DeviceLibrary
{
if (host == "")
{
host = ConfigAppSettings.GetValue(Setting_Init.http_server);
host = Setting_Init.http_server;
}
if (!host.StartsWith("http://"))
{
......@@ -270,7 +268,7 @@ namespace OnlineStore.DeviceLibrary
}
private static string GetAddr(string addr, Dictionary<string, string> paramsMap)
{
string server = ConfigAppSettings.GetValue(Setting_Init.http_server);
string server = Setting_Init.http_server;
if (server.EndsWith("/"))
{
server = server.Substring(0, server.Length - 1);
......@@ -559,6 +557,54 @@ namespace OnlineStore.DeviceLibrary
return msg;
}
private static string Addr_findRealRfid = "/rest/api/qisda/device/findRealRfid";
/// <summary>
/// 根据tempRfid查找真实rfid
///
/// </summary>
/// <param name="tempRfid"></param>
/// <returns>"":未找到真实料架,即改任务还未出库</returns>
public static string FindRealRfidByTempRfid(string tempRfid)
{
string msg = "";
try
{
Dictionary<string, string> paramMap = new Dictionary<string, string>();
paramMap.Add("tempRfid", tempRfid);
string server = GetAddr(Addr_findRealRfid, paramMap);
DateTime startTime = DateTime.Now;
string resultStr = HttpHelper.Post(server, "");
LogUtil.info("根据虚拟rfid【" + tempRfid + "】 查询包装料架绑定情况 " + " 【" + server + "】【" + resultStr + "】");
RfidData serverResult = JsonHelper.DeserializeJsonToObject<RfidData>(resultStr);
if (serverResult == null)
{
msg = "虚拟rfid【" + tempRfid + "】没有收到服务器反馈";
LogUtil.error(msg);
return "";
}
if (serverResult.data["realRfid"].Equals("")) //虚拟料架未绑定料架
{
msg = "虚拟rfid【" + tempRfid + "】 未绑定真实料架";
LogUtil.debug(msg);
return "";
}
else //虚拟料架绑定料架
{
LogUtil.debug("虚拟rfid【" + tempRfid + "】 已绑定真实料架" + serverResult.data["realRfid"]);
return serverResult.data["realRfid"];
}
}
catch (Exception ex)
{
LogUtil.error(ex.Message);
}
return "";
}
private static string Addr_getShelfLockInfo = "/rest/api/qisda/device/getShelfLockInfo"; //包装仓获取料架锁定状态地址
public static bool GetShelfLockInfo(string deviceName, string cid, string rfid, out List<ShelfLockData> shelfLockDatas)
......@@ -624,10 +670,7 @@ namespace OnlineStore.DeviceLibrary
/// <summary>
/// 检查是否是入库料架
/// </summary>
/// <param name="deviceName"></param>
/// <param name="cid"></param>
/// <param name="rfid"></param>
/// <param name="shelfLockDatas"></param>
/// <returns></returns>
public static bool CheckShelfInfo(string rfid)
{
......
using Asa;
using log4net;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
......@@ -14,7 +9,6 @@ namespace OnlineStore.DeviceLibrary
{
public static bool CurrCancelState = false ;
// public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static string ServerIp = ConfigAppSettings.GetValue(Setting_Init.AgvServerIp);
private static Asa.AgvClient agvClient;
private static Dictionary<string, Asa.ClientAction> actionMap = new Dictionary<string, Asa.ClientAction>();
public static List<string> NodeList = new List<string>();
......@@ -26,7 +20,7 @@ namespace OnlineStore.DeviceLibrary
if (!isInit)
{
isInit = true;
agvClient = new Asa.AgvClient(ServerIp);
agvClient = new Asa.AgvClient(Setting_Init.AgvServerIp);
agvClient.CancelState = true;
agvClient.Log += AgvClient_Log;
agvClient.Arrive += AgvClient_Arrive;
......@@ -50,7 +44,7 @@ namespace OnlineStore.DeviceLibrary
}
catch (Exception ex)
{
LogUtil.error("初始化agvClient " + ServerIp + " 出错:"+ ex.ToString());
LogUtil.error("初始化agvClient " + Setting_Init.AgvServerIp + " 出错:"+ ex.ToString());
}
}
......@@ -183,10 +177,9 @@ namespace OnlineStore.DeviceLibrary
{
try
{
bool isLog = ConfigAppSettings.GetIntValue(Setting_Init.Agv_Log_Open).Equals(1);
if (isLog)
if (Setting_Init.Log_OpenAgv)
{
LogUtil. debug(" AGV " + ServerIp + " Log : " + s);
LogUtil. debug(" AGV " + Setting_Init.AgvServerIp + " Log : " + s);
}
}
catch (Exception ex)
......@@ -225,7 +218,7 @@ namespace OnlineStore.DeviceLibrary
}
catch (Exception ex)
{
LogUtil.error("释放 agvClient " + ServerIp + " 出错:"+ ex.ToString());
LogUtil.error("释放 agvClient " + Setting_Init.AgvServerIp + " 出错:"+ ex.ToString());
}
}
}
......
......@@ -134,12 +134,12 @@ namespace OnlineStore.DeviceLibrary
{
DOValueMap.Remove(ioIp);
}
int DIMS = ConfigAppSettings.GetIntValue("DIMS");
int DIMS = ConfigAppSettings.GetIntValue("DIMS",60);
if (DIMS < 20)
{
DIMS = 20;
}
int DOMS = ConfigAppSettings.GetIntValue("DOMS");
int DOMS = ConfigAppSettings.GetIntValue("DOMS",300);
if (DOMS < 200)
{
DOMS = 200;
......@@ -220,14 +220,6 @@ namespace OnlineStore.DeviceLibrary
private DateTime lastLogTime = DateTime.Now;
private void AioBox_Log_Out_Event(AIOBOX box, string[] s)
{
foreach (string str in s)
{
LogUtil.AIOLog.Debug("[" + box.IP + "]" + str);
}
}
private void AioBox_DI_Changed_Event(AIOBOX box, Box_Sta[] sta)
{
try
......
......@@ -148,7 +148,7 @@ namespace OnlineStore.DeviceLibrary
#endregion
public static void Init()
{
bool isAIOBox = ConfigAppSettings.GetIntValue(Setting_Init.UseAIOBOX).Equals(1);
bool isAIOBox = Setting_Init.UseAIOBOX;
if (isAIOBox)
{
instance = new AIOBOXManager();
......
......@@ -86,7 +86,7 @@ namespace OnlineStore.DeviceLibrary
{
return true;
}
int ACBaudRate = ConfigAppSettings.GetIntValue(Setting_Init.ACBaudRate);
int ACBaudRate = Setting_Init.ACBaudRate;
if (ACBaudRate <= 0)
{
ACBaudRate = 9600;
......
......@@ -25,7 +25,7 @@ namespace OnlineStore.DeviceLibrary
/// </summary>
public static void LoadConfig()
{
string codeStr = ConfigAppSettings.GetValue(Setting_Init.CodeType);
string codeStr = Setting_Init.CodeType;
codeTypeList = new List<string>();
HDLogUtil.LogName = "RollingLogFileAppender";
try
......@@ -98,7 +98,7 @@ namespace OnlineStore.DeviceLibrary
}
private static int ScanCount = 0;
private static int codeCount = ConfigAppSettings.GetIntValue(Setting_Init.CodeCount);
private static int codeCount = Setting_Init.CodeCount;
[HandleProcessCorruptedStateExceptions]
public static List<string> CameraScan(List<string> cameraList, string deviceName, int timeOut = 1500)
{
......@@ -272,7 +272,7 @@ namespace OnlineStore.DeviceLibrary
public static string GetCodeParamFilePath(string codePath)
{
string appPath = Application.StartupPath;
string path = appPath + ConfigAppSettings.GetValue(Setting_Init.CodeParamPath);
string path = appPath + Setting_Init.CodeParamPath;
string filePath = path + codePath + ".dcm";
if (File.Exists(filePath))
{
......
......@@ -17,6 +17,7 @@ namespace OnlineStore.DeviceLibrary
{
public InOutParam(string wareNo="", string posId="", string ShelfPosID="", int platew = 0, int plateh =0, bool urgentReel = false, bool cutReel = false, bool smallReel = false, string rfid = "", int rfidLoc = 0,int taskCount=0,string realRfid="")
{
this.CurShelfPosID = ShelfPosID;
this.ShelfPosID = ShelfPosID;
WareCode = wareNo;
PosID = posId;
......@@ -34,6 +35,7 @@ namespace OnlineStore.DeviceLibrary
public InOutParam(string wareNo, string posId, string ShelfPosID,LineMoveP linePosition )
{
WareCode = wareNo;
this.CurShelfPosID = ShelfPosID;
this.ShelfPosID = ShelfPosID;
PosID = posId;
MoveP = linePosition;
......@@ -50,7 +52,7 @@ namespace OnlineStore.DeviceLibrary
}
public InOutParam NewParam()
{
InOutParam newp = new InOutParam(WareCode,PosID,ShelfPosID, PlateW, PlateH, urgentReel,cutReel,smallReel,rfid,rfidLoc,taskCount,realRfid);
InOutParam newp = new InOutParam(WareCode,PosID,CurShelfPosID, PlateW, PlateH, urgentReel,cutReel,smallReel,rfid,rfidLoc,taskCount,realRfid);
return newp;
}
/// <summary>
......@@ -62,7 +64,11 @@ namespace OnlineStore.DeviceLibrary
/// </summary>
public string PosID { get; set; }
/// <summary>
/// 料架对应的库位号
/// 当前料架对应的库位号
/// </summary>
public string CurShelfPosID = "";
/// <summary>
/// 需要取放的料架对应的库位号
/// </summary>
public string ShelfPosID = "";
public LineMoveP MoveP { get; set; }
......@@ -145,21 +151,21 @@ namespace OnlineStore.DeviceLibrary
}
public string ToStr()
{
return " 库位 [" + PosID + "] [" + ShelfPosID + "], [" + WareCode + "], [" + PlateW + "x" + PlateH + "] ," +
return " 库位 [" + PosID + "] [" + CurShelfPosID + "], [" + WareCode + "], [" + PlateW + "x" + PlateH + "] ," +
"urgentReel [" + urgentReel + "],cutReel [" + cutReel + "],smallReel [" + smallReel + "],rfid [" + rfid + "],rfidLoc [" + rfidLoc + "],taskCount ["+ taskCount + "]";
}
public string ToShortStr()
{
return "["+rfid+"][" + PosID + "][" + ShelfPosID + "][" + PlateW + "x" + PlateH + "][" + WareCode + "]";
return "["+rfid+"][" + PosID + "][" + CurShelfPosID + "][" + PlateW + "x" + PlateH + "][" + WareCode + "]";
}
internal void UpdateShelfPosId(string pId)
{
this.ShelfPosID = pId;
ShelfPosition sp = CSVPositionReader<ShelfPosition>.GetPositon(ShelfPosID);
this.CurShelfPosID = pId;
ShelfPosition sp = CSVPositionReader<ShelfPosition>.GetPositon(CurShelfPosID);
if (sp == null)
{
LogUtil.error( "GetPositon[" + ShelfPosID + "]=null,没有库位不能执行出入库");
LogUtil.error( "GetPositon[" + CurShelfPosID + "]=null,没有库位不能执行出入库");
}
MoveP.InOut_P101 = sp.InoutAxis_P101;
......@@ -168,7 +174,21 @@ namespace OnlineStore.DeviceLibrary
MoveP.Middle_P101 = sp.MiddleAxis_P101;
}
internal void RestoreShelfPosId()
{
this.CurShelfPosID = ShelfPosID;
ShelfPosition sp = CSVPositionReader<ShelfPosition>.GetPositon(CurShelfPosID);
if (sp == null)
{
LogUtil.error("GetPositon[" + CurShelfPosID + "]=null,没有库位不能执行出入库");
}
MoveP.InOut_P101 = sp.InoutAxis_P101;
MoveP.UpDown_LP101 = sp.UpDownAxis_LP101;
MoveP.UpDown_HP102 = sp.UpDownAxis_HP102;
MoveP.Middle_P101 = sp.MiddleAxis_P101;
}
internal void UpdatePosId(string message, string posId, int plateW, int plateH,int comP2,int comP3)
{
this.WareCode = message;
......@@ -196,7 +216,7 @@ namespace OnlineStore.DeviceLibrary
internal void UpdatePosIdAndShelfId(string wareNo,string rfid,string posId, string ShelfPosID)
{
WareCode = wareNo;
this.ShelfPosID = ShelfPosID;
this.CurShelfPosID = ShelfPosID;
this.rfid = rfid;
ShelfPosition sp = CSVPositionReader<ShelfPosition>.GetPositon(ShelfPosID);
if (sp == null)
......
......@@ -7,6 +7,7 @@ using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Web.UI.WebControls;
namespace OnlineStore.DeviceLibrary
......@@ -219,7 +220,7 @@ namespace OnlineStore.DeviceLibrary
/// <summary>
/// 停止所有运动
/// </summary>
public abstract void StopMove( );
public abstract void StopMove();
/// <summary>
/// 重置处理
......@@ -233,7 +234,7 @@ namespace OnlineStore.DeviceLibrary
protected void ACAxisHomeMove(ConfigMoveAxis moveAxis)
{
moveAxis.TargetPosition = 0;
LogUtil.info(Name+ moveAxis.DisplayStr + "speed[" + moveAxis.TargetSpeed + "]开始原点返回");
LogUtil.info(Name + moveAxis.DisplayStr + "speed[" + moveAxis.TargetSpeed + "]开始原点返回");
MoveInfo.WaitList.Add(WaitResultInfo.WaitAxis(moveAxis, true));
ACServerManager.HomeMove(moveAxis.DeviceName, (short)moveAxis.GetAxisValue(), moveAxis.HomeHighSpeed);
}
......@@ -269,7 +270,7 @@ namespace OnlineStore.DeviceLibrary
//判断是否需要重新运动
if (MoveInfo.CanWhileCount > 0)
{
LogUtil.error(Name+ moveAxis.DisplayStr + "目标位置[" + targetPosition + "]当前位置[" + outCount +
LogUtil.error(Name + moveAxis.DisplayStr + "目标位置[" + targetPosition + "]当前位置[" + outCount +
"],误差过大,重新开始运动,剩余[" + MoveInfo.CanWhileCount + "]次");
ACServerManager.AbsMove(moveAxis.DeviceName, moveAxis.GetAxisValue(), targetPosition, targetSpeed);
MoveInfo.CanWhileCount--;
......@@ -278,7 +279,7 @@ namespace OnlineStore.DeviceLibrary
{
msg = Name + " storeMoveStep=" + MoveInfo.MoveStep + moveAxis.DisplayStr + "目标位置[" + targetPosition + "]当前位置[" + outCount
+ "],误差过大,需要报警";
LogUtil.error(Name+ msg);
LogUtil.error(Name + msg);
}
}
return false;
......@@ -298,7 +299,7 @@ namespace OnlineStore.DeviceLibrary
//判断是否需要重新运动
if (MoveInfo.CanWhileCount > 0)
{
LogUtil.error(Name+ moveAxis.DisplayStr + "收到原点完成信号,当前位置[" + outCount + "],重新回原点,剩余[" + MoveInfo.CanWhileCount + "]次");
LogUtil.error(Name + moveAxis.DisplayStr + "收到原点完成信号,当前位置[" + outCount + "],重新回原点,剩余[" + MoveInfo.CanWhileCount + "]次");
//LogUtil.error(LOGGER, StoreName + moveAxis.DisplayStr + "重新回原点");
ACServerManager.HomeMove(moveAxis.DeviceName, moveAxis.GetAxisValue(), moveAxis.HomeHighSpeed);
MoveInfo.CanWhileCount--;
......@@ -306,7 +307,7 @@ namespace OnlineStore.DeviceLibrary
else
{
msg = Name + " storeMoveStep=" + MoveInfo.MoveStep + moveAxis.DisplayStr + "收到原点完成信号,当前位置[" + outCount + "],误差过大,需要报警";
LogUtil.error(Name+ msg);
LogUtil.error(Name + msg);
}
}
return false;
......@@ -324,7 +325,7 @@ namespace OnlineStore.DeviceLibrary
{
if (!isInit)
{
MoveInfo = new StoreMoveInfo(DeviceID);
MoveInfo = new DeviceMoveInfo(DeviceID);
mainTimer = new System.Timers.Timer();
mainTimer.Enabled = false;
......@@ -350,7 +351,7 @@ namespace OnlineStore.DeviceLibrary
/// <summary>
/// 移动信息
/// </summary>
public StoreMoveInfo MoveInfo = null;
public DeviceMoveInfo MoveInfo = null;
/// <summary>
/// 定时处理,监听信号,监听IO
......@@ -449,7 +450,7 @@ namespace OnlineStore.DeviceLibrary
return sta;
}
}
public void CylinderMove(StoreMoveInfo moveInfo, string IoLowType, string IoHighType)
public void CylinderMove(DeviceMoveInfo moveInfo, string IoLowType, string IoHighType)
{
IOMove(IoLowType, IO_VALUE.LOW);
IOMove(IoHighType, IO_VALUE.HIGH);
......@@ -472,27 +473,35 @@ namespace OnlineStore.DeviceLibrary
/// </summary>c
protected bool WaitIo(string ioType, IO_VALUE value, int timeOut, string errName = "")
{
return WaitUtil.Wait(timeOut, delegate () {
return WaitUtil.Wait(timeOut, delegate ()
{
return value.Equals(IOValue(ioType));
}, errName);
}
public void LogInfo(string logInfo)
public void LogError(string msg)
{
LogUtil.info(Name + logInfo);
LogUtil.info($"{Name}{MoveInfo?.MoveType}{msg}");
}
protected void InOutStoreLog(string msg,bool isDebug=false )
public void LogInfo(string msg)
{
string posId = MoveInfo.MoveParam != null ? "["+MoveInfo.MoveParam.PosID+"]" : "";
string shelfId = MoveInfo.MoveParam != null ? "[" + MoveInfo.MoveParam.ShelfPosID+"]" : "";
if (isDebug)
LogUtil.info($"{Name}{MoveInfo?.MoveType}{msg}");
}
public void LogRunStepInfo(string msg)
{
LogUtil.debug (Name + " " + posId + "" + shelfId + " :" + msg);
LogInfo($"{MoveInfo?.SLog}{msg}");
}
else
public void LogRunStepError(string msg)
{
LogInfo(" " + posId + "" + shelfId + " :" + msg);
LogError($"{MoveInfo?.SLog}{msg}");
}
protected void InOutStoreLog(string msg)
{
string posId = MoveInfo.MoveParam != null ? "[" + MoveInfo.MoveParam.PosID + "]" : "";
string shelfId = MoveInfo.MoveParam != null ? "[" + MoveInfo.MoveParam.CurShelfPosID + "]" : "";
LogRunStepInfo($"posId={posId} shelfId={shelfId}: {msg}");
}
protected int GetAlarmCodeByAxis(ConfigMoveAxis axis)
{
int alarmCode = LineAlarm.InOutAxisAlarm;
......
......@@ -206,6 +206,102 @@ namespace OnlineStore.DeviceLibrary
#endregion
#region 检查出库料架上是否有治具
/// <summary>
/// 出库料架检查:开始循环从第一个空位逐个取料盘
/// </summary>
SO_PreCheck_01_StartGetTray,
/// <summary>
/// 出库料架检查:叉子后退到待机点P1
/// </summary>
SO_PreCheck_02_InoutToP1,
/// <summary>
/// 出库料架检查:升降轴移动到P101低点,旋转轴移动到P101点,压紧轴到压紧前点
/// </summary>
SO_PreCheck_03_MoveToShelf,
/// <summary>
/// 出库料架检查:叉子前进到P101点
/// </summary>
SO_PreCheck_04_InoutToP101,
/// <summary>
/// 出库料架检查:升降轴上升到P102点
/// </summary>
SO_PreCheck_05_UpdownToP102,
/// <summary>
/// 出库料架检查:压紧轴开始缓慢压紧
/// </summary>
SO_PreCheck_06_StartCompress,
/// <summary>
/// 出库料架检查:检测到料叉压紧确认信号,再次向下压紧指定的值
/// </summary>
SO_PreCheck_07_ComDownMove,
/// <summary>
/// 出库料架检查:记录压紧高度,叉子后退到P1
/// </summary>
SO_PreCheck_08_InoutBack,
/// <summary>
/// 到扫码位置:升降轴移动到P2,旋转轴移动到P1
/// </summary>
SO_PreCheck_09_ToScanPosition,
/// <summary>
/// 到扫码位置:进出轴到P2
/// </summary>
SO_PreCheck_10_InOutToP2,
/// <summary>
/// 到扫码位置:升降轴缓慢下降到P1,压紧轴返回压紧前点
/// </summary>
SO_PreCheck_11_PutTrayDown,
/// <summary>
/// 到扫码位置:进出轴返回待机点
/// </summary>
SO_PreCheck_12_InOutToP1,
/// <summary>
/// 检查治具:检查是否有治具
/// </summary>
SO_PreCheck_13_CheckFix,
/// <summary>
/// 检查治具:检查完成,获取结果
/// 有治具,将该治具返回料架位置
/// 无治具,到下一个位置
/// </summary>
SO_PreCheck_14_GetCheckResult,
/// <summary>
/// 检查治具:有治具
/// </summary>
SO_PreCheck_15_InoutToP2,
/// <summary>
/// 检查治具:升降轴到P1,压紧轴压紧
/// </summary>
SO_PreCheck_16_GetScanPTray,
/// <summary>
/// 检查治具:进出轴返回
/// </summary>
SO_PreCheck_17_InoutBackP1,
/// <summary>
/// 检查治具:有治具,返回料架位置
/// </summary>
SO_PreCheck_18_ToShelfPosition,
/// <summary>
/// 检查治具:叉子到料架,进出轴至P20
/// /// </summary>
SO_PreCheck_19_ToShelf,
/// <summary>
/// 检查治具:把物品放下,压紧轴到P1,升降轴至P20
/// </summary>
SO_PreCheck_20_PutReel,
/// <summary>
/// 检查治具:叉子从出料口返回,,进出轴到P1
/// 不再检查下一个位置,料架直接作为NG返回
/// </summary>
SO_PreCheck_21_InoutBack,
SO_PreCheck_22_GoBack,
#endregion
#region 出库步骤 2000开始
......
......@@ -11,15 +11,15 @@ using System.Text;
namespace OnlineStore.DeviceLibrary
{
/// <summary>
/// 料仓当前运动信息类(出入库状态,步骤记录)
/// 设备当前运动信息类(出入库状态,步骤记录)
/// </summary>
public class StoreMoveInfo
public class DeviceMoveInfo
{
/// <summary>
/// 超时时间
/// </summary>
public int TimeOutSeconds = 60;
public StoreMoveInfo(int storeId)
public DeviceMoveInfo(int storeId)
{
moveType = StoreMoveType.None;
......@@ -41,7 +41,7 @@ namespace OnlineStore.DeviceLibrary
public string SLog
{
get { return " " + MoveStep + " "; }
get { return $" {MoveStep} "; }
}
......@@ -138,9 +138,9 @@ namespace OnlineStore.DeviceLibrary
WaitList = new List<WaitResultInfo>();
CanWhileCount = 0;
}
public StoreMoveInfo clone()
public DeviceMoveInfo clone()
{
return (StoreMoveInfo)this.MemberwiseClone();
return (DeviceMoveInfo)this.MemberwiseClone();
}
public List<WaitResultInfo> WaitList = new List<WaitResultInfo>();
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!