Commit 46106a0a LN

增加移栽出库判断

1 个父辈 fc1d7511
......@@ -7,7 +7,7 @@
<!--是否开机自动启动料仓-->
<add key="App_AutoRun" value="1"/>
<add key="App_Title" value="AC_SA_料仓_1"/>
<add key="scanner_start_command" value="S"/>
<!-- 开始吹气的判断值(配置值=服务器发送的湿度值-开始吹气值)-->
<add key="StartBlowValue" value="4"/>
<!-- 停止吹气的判断值(配置值=服务器发送的湿度值-停止吹气值)-->
......@@ -22,29 +22,20 @@
<add key="Store_Type" value="RC_AC_SA"/>
<add key="Store_CID" value="rc1246ac-1"/>
<add key ="Store_ID" value ="1"/>
<!--end one store config-->
<!--摄像机名称列表配置,用#分割-->
<add key="CameraName" value="GigE:MV-CE100-30GC (00C69898483)"/>
<!--二维码类型列表配置,用#分割,一维码=Barcode-->
<add key="CodeType" value="QR Code#Data Matrix ECC 200#Micro QR Code"/>
<!--<add key="CodeType" value="Data Matrix ECC 200"/>-->
<!--二维码参数文件所在路径,文件名与二维码类型名一样-->
<add key="CodeParamPath" value="\CodeParam\"/>
<add key="AI_ConvertPosition" value="55"/>
<!--end one store config-->
<add key="InOutDefaultPosition" value="8000"/>
<add key="Config_Pwd" value="123456"/>
<!--出库等待料盘拿走的时间,秒-->
<add key="OutStoreWaitSeconds" value="10"/>
<!--压紧轴对应1mm的脉冲-->
<add key="ComAxisChangeValue" value="2400"/>
<add key="OutStoreWaitSeconds" value="10"/>
<!--温控器类型,0=壁挂王字壳温湿度变送器,1=妙昕温湿度记录仪-->
<add key="HumitureControllerType" value="0"/>
<add key="UseAIOBOX" value="1"/>
<!--流水线地址和端口配置-->
<!--<add key ="LineServerIp" value ="192.168.1.110"/>-->
<add key ="LineServerIp" value =""/>
<!--<add key ="LineServerIp" value ="192.168.1.110"/>-->
<add key ="LineServerPort" value ="5246"/>
<!--是否调试状态-->
<add key ="IsInDebug" value ="1"/>
</appSettings>
<log4net>
......
......@@ -169,6 +169,8 @@
this.清理日志ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.lblThisSta = new System.Windows.Forms.Label();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.lblMoveEquipInfo = new System.Windows.Forms.Label();
this.chbDebug = new System.Windows.Forms.CheckBox();
this.chbAuto = new System.Windows.Forms.CheckBox();
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.显示ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
......@@ -1955,6 +1957,7 @@
//
// groupBox3
//
this.groupBox3.Controls.Add(this.lblMoveEquipInfo);
this.groupBox3.Controls.Add(this.lblWarnMsg);
this.groupBox3.Controls.Add(this.lblThisSta);
this.groupBox3.Location = new System.Drawing.Point(7, 90);
......@@ -1964,6 +1967,30 @@
this.groupBox3.TabStop = false;
this.groupBox3.Text = "设备状态";
//
// lblMoveEquipInfo
//
this.lblMoveEquipInfo.AutoSize = true;
this.lblMoveEquipInfo.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblMoveEquipInfo.ForeColor = System.Drawing.Color.Blue;
this.lblMoveEquipInfo.Location = new System.Drawing.Point(221, 30);
this.lblMoveEquipInfo.Name = "lblMoveEquipInfo";
this.lblMoveEquipInfo.Size = new System.Drawing.Size(65, 19);
this.lblMoveEquipInfo.TabIndex = 272;
this.lblMoveEquipInfo.Text = "移栽状态";
//
// chbDebug
//
this.chbDebug.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.chbDebug.AutoSize = true;
this.chbDebug.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chbDebug.Location = new System.Drawing.Point(799, 12);
this.chbDebug.Name = "chbDebug";
this.chbDebug.Size = new System.Drawing.Size(93, 25);
this.chbDebug.TabIndex = 271;
this.chbDebug.Text = "调试状态";
this.chbDebug.UseVisualStyleBackColor = true;
this.chbDebug.CheckedChanged += new System.EventHandler(this.chbDebug_CheckedChanged);
//
// chbAuto
//
this.chbAuto.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
......@@ -2396,6 +2423,7 @@
// tabPage4
//
this.tabPage4.Controls.Add(this.btnStoreExit);
this.tabPage4.Controls.Add(this.chbDebug);
this.tabPage4.Controls.Add(this.btnStoreHome);
this.tabPage4.Controls.Add(this.chbAuto);
this.tabPage4.Controls.Add(this.btnSotreReset);
......@@ -2830,6 +2858,8 @@
private System.Windows.Forms.Button button5;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.CheckBox chbDebug;
private System.Windows.Forms.Label lblMoveEquipInfo;
}
}
......@@ -33,12 +33,35 @@ namespace OnlineStore.ACSingleStore
}
#region "初始化界面数据"
private bool LoadOk = false;
private void initValue()
private void FrmTest_Load(object sender, EventArgs e)
{
InitStoreValue();
string version = GetVersion();
LogUtil.logBox = this.richTextBox1;
LoadStore();
chbDebug.Checked = store.IsDebug;
this.ShowInTaskbar = true;
this.Text = ConfigAppSettings.GetValue(Setting_Init.App_Title);
notifyIcon1.Text = ConfigAppSettings.GetValue(Setting_Init.App_Title);
//cmbHomeType.SelectedIndex = 1;
HideForm();
this.Opacity = 1;
txtTempPort.Text = store.Config.Humiture_Port;
if (HumitureController.HumitureControllerType.Equals(1))
{
groupHistory.Visible = true;
}
else
{
groupHistory.Visible = false;
}
LoadOk = true;
}
private void InitStoreValue()
private void LoadStore()
{
this.store = StoreManager.InitStore();
if (store == null)
......@@ -88,7 +111,7 @@ namespace OnlineStore.ACSingleStore
txtInOutP2.Text = ktkPosition.InOutAxis_DoorPosition_P2.ToString();
//txtUpDownP1.Text = ktkPosition.UpDownAxis_DoorOPosition_P1.ToString();
}
//List<string> port = new List<string>(SerialPort.GetPortNames());
//comboBoxPortName.DataSource = port;
//if (port.IndexOf(store.Config.CompressAxis_PortName) >= 0)
......@@ -97,7 +120,7 @@ namespace OnlineStore.ACSingleStore
//}
//cmbHomeType.SelectedIndex = 0;
timer1.Enabled = true;
}
}
#endregion
......@@ -141,40 +164,15 @@ namespace OnlineStore.ACSingleStore
btnStoreStop.Enabled = isOpen;
}
private bool LoadOk = false;
private void FrmTest_Load(object sender, EventArgs e)
{
string version = GetVersion();
LogUtil.logBox = this.richTextBox1;
initValue();
this.ShowInTaskbar = true;
this.Text = ConfigAppSettings.GetValue(Setting_Init.App_Title);
notifyIcon1.Text = ConfigAppSettings.GetValue(Setting_Init.App_Title);
LoadOk = true;
//cmbHomeType.SelectedIndex = 1;
HideForm();
this.Opacity = 1;
txtTempPort.Text = store.Config.Humiture_Port;
if (HumitureController.HumitureControllerType.Equals(1))
{
groupHistory.Visible = true;
}
else
{
groupHistory.Visible = false;
}
}
private DateTime preReadModblsTime = DateTime.Now;
private void timer1_Tick(object sender, EventArgs e)
{
if (!this.Visible)
{
return;
}
lblTemp.Text = store.currTempStr;
lblTemp.Text = store.currTempStr;
lblMoveEquipInfo.Text = "移栽状态:"+(LineConnect.CanStartOut() ? "可出库":"不可出库" )+" "+LineConnect.LastUpdateTime.ToLongTimeString() ;
//忙碌状态不读取状态
if (!store.storeRunStatus.Equals(StoreRunStatus.Busy))
{
......@@ -918,13 +916,7 @@ namespace OnlineStore.ACSingleStore
{
MessageBox.Show("请先启动料仓!");
}
}
//private void btnAxisConfig_Click(object sender, EventArgs e)
//{
// FormManager.ShowAxisConfig(store);
//}
}
private void 轴卡点动ToolStripMenuItem_Click(object sender, EventArgs e)
{
button1_Click(null, null);
......@@ -994,10 +986,7 @@ namespace OnlineStore.ACSingleStore
}
private void 打开舱门ToolStripMenuItem_Click(object sender, EventArgs e)
{
// IOManager.IOMove(IO_Type.Door_Up, IO_VALUE.HIGH);
// IOManager.IOMove(IO_Type.Door_Down, IO_VALUE.LOW);
{
StoreManager.Store.OpenDoor(false);
}
......@@ -1008,9 +997,7 @@ namespace OnlineStore.ACSingleStore
}
private void 关闭仓门ToolStripMenuItem_Click(object sender, EventArgs e)
{
// IOManager.IOMove(IO_Type.Door_Down, IO_VALUE.HIGH);
// IOManager.IOMove(IO_Type.Door_Up, IO_VALUE.LOW);
{
StoreManager.Store.CloseDoor(false);
}
......@@ -1098,49 +1085,7 @@ namespace OnlineStore.ACSingleStore
}
return false;
}
public bool IsInProcess = false;
public void CheckWait()
{
if (IsInProcess)
{
return;
}
IsInProcess = true;
List<WaitResultInfo> list = waitResultList;
if (list.Count > 0)
{
bool isOk = true;
foreach (WaitResultInfo wait in list)
{
if (wait.WaitType == 1)
{
string msg = "";
bool isEnd = ACAxisMoveIsEnd(wait.AxisInfo, wait.TargetPosition, wait.TargetSpeed, out msg);
if (!msg.Equals(""))
{
isOk = false;
break;
}
else if (!isEnd)
{
isOk = false;
break;
}
}
}
if (list.Count > 0 && isOk.Equals(true))
{
waitResultList.Clear();
list.Clear();
MessageBox.Show("运动完成!");
}
}
IsInProcess = false;
}
public List<WaitResultInfo> waitResultList = new List<WaitResultInfo>();
private int GetSlaveAddr()
{
return FormUtil.GetShortValue(txtAxisValue);
......@@ -1291,9 +1236,7 @@ namespace OnlineStore.ACSingleStore
{
ExitApp();
}
}
}
private void 学习二维码ToolStripMenuItem_Click(object sender, EventArgs e)
{
......@@ -1412,7 +1355,43 @@ namespace OnlineStore.ACSingleStore
private void button6_Click(object sender, EventArgs e)
{
LineConnect.SendHeart(StoreManager.Config.Id, StoreManager.Config.CID, (int)StoreStatus.StoreOnline, (int)StoreRunStatus.Runing, "");
int hasTray = (int)IOManager.IOValue(IO_Type.TrayCheck_Door);
LineConnect.SendHeart(StoreManager.Config.Id, StoreManager.Config.CID, (int)StoreStatus.StoreOnline, (int)StoreRunStatus.Runing, hasTray,"");
}
private void chbDebug_CheckedChanged(object sender, EventArgs e)
{
if (!LoadOk)
{
return;
}
if (chbDebug.Checked)
{
if (!store.IsDebug)
{
DialogResult result = MessageBox.Show("是否切换到调试状态?", "是否确认切换", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
if (result.Equals(DialogResult.Yes))
{
store.IsDebug = true;
ConfigAppSettings.SaveValue(Setting_Init.IsInDebug, 1);
LogUtil.info("用户切换到调试状态 ");
}
}
}
else
{
if (store.IsDebug)
{
DialogResult result = MessageBox.Show("是否切换到正常工作状态?", "是否确认切换", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
if (result.Equals(DialogResult.Yes))
{
store.IsDebug = false ;
ConfigAppSettings.SaveValue(Setting_Init.IsInDebug, 0);
LogUtil.info("用户切换到正常工作状态 ");
}
}
}
}
}
}
......@@ -1263,7 +1263,7 @@
</value>
</data>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>25</value>
<value>56</value>
</metadata>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
......
......@@ -20,10 +20,7 @@ namespace OnlineStore.Common
/// 系统主界面标题
/// </summary>
public static string App_Title = "App_Title";
/// <summary>
/// 扫码枪开始命令发送给socket的消息
/// </summary>
public static string scanner_start_command = "scanner_start_command";
public static string http_server = "http.server";
public static string Store_CID = "Store_CID";
......@@ -76,10 +73,7 @@ namespace OnlineStore.Common
/// 出库等待料盘拿走的时间,秒
/// </summary>
public static string OutStoreWaitSeconds = "OutStoreWaitSeconds";
/// <summary>
/// 压紧轴1mm对应的脉冲
/// </summary>
public static string ComAxisChangeValue = "ComAxisChangeValue";
/// <summary>
/// 温控器类型,0=壁挂王字壳温湿度变送器,1=妙昕温湿度记录仪
......@@ -90,5 +84,9 @@ namespace OnlineStore.Common
public static string LineServerIp = "LineServerIp";
public static string LineServerPort = "LineServerPort";
/// <summary>
/// 是否调试状态
/// </summary>
public static string IsInDebug = "IsInDebug";
}
}
......@@ -80,10 +80,18 @@ namespace OnlineStore.Common
return connectState;
#endregion
}
/// <summary>
/// 是否在运行中
/// </summary>
/// <returns></returns>
public bool IsRun()
{
return ReConnectTimer.Enabled;
}
/// <summary>
/// 连接服务器
/// </summary>
public bool connect(string serverIP, int serverPort, HandleMessage HandleMessage,int ReConnectMs=0)
public bool StartConnect(string serverIP, int serverPort, HandleMessage HandleMessage,int ReConnectMs=0)
{
m_clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Parse(serverIP), serverPort);
......@@ -96,9 +104,7 @@ namespace OnlineStore.Common
{
ReConnectTimer.AutoReset = true;
ReConnectTimer.Elapsed += ReConnectTimer_Elapsed;
}
}
try
{
m_clientSocket.Connect(remoteEndPoint);
......@@ -111,8 +117,7 @@ namespace OnlineStore.Common
return true;
}
else
{
ReConnectTimer.Start();
{
LogUtil.info(LOGGER, "Connect to " + serverIP + ":" + serverPort + " fail!");
}
}
......@@ -121,6 +126,8 @@ namespace OnlineStore.Common
LogUtil.error(LOGGER,"Connect to " + serverIP + ":" + serverPort + " fail!" + ex.ToString(),3);
m_clientSocket = null;
}
ReConnectTimer.Start();
return false;
}
......
......@@ -28,8 +28,7 @@ PRO,进出轴(轴3)P1待机原位点,InOutAxis_P1_Position,1000,,,,,,,
PRO,压紧轴(轴4)P1待机原位点,CompressAxis_P1_Position,-7500,,,,,,,
PRO,是否使用定位气缸,IsHasLocationCylinder,0,,,,,,,
PRO,是否有左右侧门,IsHasDoorLimit,1,,,,,,,
PRO,是否使用压紧轴(1=使用),IsHasCompress_Axis,1,,,,, ,,
PRO,设备是否处于调试状态(1=调试,0=正常),IsInDebug,0,,,,,,,
PRO,是否使用压紧轴(1=使用),IsHasCompress_Axis,1,,,,, ,,
PRO,气压检测IO关闭需要持续的时间,AirCheckSeconds,3,,,,,,,
,,,,,,,,,,
PRO,预警温度,WarnTemperate,80,,,,,,,
......
......@@ -57,15 +57,14 @@ namespace OnlineStore.DeviceLibrary
IoCheckTimer.AutoReset = true;
IoCheckTimer.Enabled = false;
IoCheckTimer.Elapsed += IoCheckTimer_Elapsed;
//添加调试
if (config.IsInDebug == 1)
{
IsDebug = true;
}
//添加调试
IsDebug = ConfigAppSettings.GetIntValue(Setting_Init.IsInDebug).Equals(1);
IsHasCompress_Axis = config.IsHasCompress_Axis.Equals(1);
StoreName = ("料仓BOX_" + config.Id + " ").ToUpper();
this.StoreID = config.Id;
this.Config = config;
this.Config = config;
moveAxisList = new List<ConfigMoveAxis>();
MoveAxisConfig();
List<ACStorePosition> positionList = CSVPositionReader<ACStorePosition>.getPositionList();
......@@ -81,9 +80,9 @@ namespace OnlineStore.DeviceLibrary
}
}
}
IOManager.Init();
IOManager.instance.ConnectionIOList(Config.DIODeviceNameList);
IOManager.Init();
IOManager.instance.ConnectionIOList(Config.DIODeviceNameList);
mainTimer.Enabled = false;
int isAuto = ConfigAppSettings.GetIntValue(Setting_Init.App_AutoRun);
......@@ -947,43 +946,7 @@ namespace OnlineStore.DeviceLibrary
ShowTimeLog("BusyMoveProcess");
}
else if (storeRunStatus.Equals(StoreRunStatus.Runing))
{
//判断是否需要出入库
if (StoreMove.MoveType.Equals(StoreMoveType.None) && alarmType.Equals(StoreAlarmType.None))
{
IO_VALUE checkIO = IOManager.IOValue(IO_Type.TrayCheck_Door);
//判断料门口是否有料
if ((checkIO.Equals(IO_VALUE.HIGH)) && IOManager.IOValue(IO_Type.TrayCheck_Fixture).Equals(IO_VALUE.LOW))
{
if (IsScanCode)
{
return;
}
//检测到料盘,等待1.5秒后扫码
if (isWaitScan)
{
//TimeSpan span = DateTime.Now - StartWaitScanTime;
//if (span.TotalSeconds > 1)
//{
// isWaitScan = false;
// IsScanCode = true;
// LogUtil.info(StoreName + "检测到" + height + "寸料盘,开始扫码");
// GetCameraCode();
//}
}
else
{
isWaitScan = true;
StartWaitScanTime = DateTime.Now;
}
}
else
{
isWaitScan = false;
}
}
{
ShowTimeLog("判断是否需要出入库");
AutoResetProcess();
......@@ -1070,7 +1033,7 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info(LOGGER, StoreName + "已经累计出入库" + CurrInOutCount + "次,需要复位一下旋转轴");
}
}
else
else if (LineConnect.CanStartOut() || IsDebug)
{
FixtureCodeInfo currInOutFixture = null;
lock (waitOutListLock)
......@@ -1083,15 +1046,13 @@ namespace OnlineStore.DeviceLibrary
}
if (currInOutFixture != null)
{ //出库
if (currInOutFixture.WareNum.Equals(""))
LogUtil.info(LOGGER, StoreName + "开始执行排队中的出库【" + currInOutFixture.ToStr() + "】");
bool result = StartOutStoreMove(new InOutStoreParam("", currInOutFixture.PosId, currInOutFixture.plateH, currInOutFixture.plateW));
if (!result)
{
LogUtil.info(LOGGER, StoreName + "开始执行排队中的出库【" + currInOutFixture.ToStr() + "】");
bool result = StartOutStoreMove(new InOutStoreParam("", currInOutFixture.PosId, currInOutFixture.plateH, currInOutFixture.plateW));
if (!result)
{
LogUtil.info(LOGGER, StoreName + " 执行排队中的出库【" + currInOutFixture.ToStr() + "】失败,重新加入等待队列");
AddWaitOutInfo(currInOutFixture);
}
LogUtil.info(LOGGER, StoreName + " 执行排队中的出库【" + currInOutFixture.ToStr() + "】失败,重新加入等待队列");
AddWaitOutInfo(currInOutFixture);
}
}
}
......@@ -1534,7 +1495,8 @@ namespace OnlineStore.DeviceLibrary
{
posID = StoreMove.MoveParam.PositionNum;
}
LineConnect.SendHeart(Config.Id, Config.CID, (int)storeStatus, (int)storeRunStatus, posID);
int hasTray = (int)IOManager.IOValue(IO_Type.TrayCheck_Door);
LineConnect.SendHeart(Config.Id, Config.CID, (int)storeStatus, (int)storeRunStatus, hasTray, posID);
}
HumitureController.QueryData();
HumidityProcess();
......@@ -1567,14 +1529,7 @@ namespace OnlineStore.DeviceLibrary
BoxStatus boxStatus = new BoxStatus();
boxStatus.boxId = StoreID;
//状态
boxStatus.status = (int)storeStatus;
if (IsDebug)
{
boxStatus.status = (int)StoreStatus.Debugging;
}
boxStatus.msg = WarnMsg;
lineOperation.msg = WarnMsg;
......@@ -1737,7 +1692,7 @@ namespace OnlineStore.DeviceLibrary
else
{
FixtureCodeInfo currInOutFixture = new FixtureCodeInfo(0, "", posId, plateW, plateH);
if (CanStarInOut())
if (CanStarInOut() &&( LineConnect.CanStartOut()||IsDebug))
{
bool result = StartOutStoreMove(new InOutStoreParam("", posId, position));
if (!result)
......
......@@ -655,7 +655,8 @@ namespace OnlineStore.DeviceLibrary
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P1, Config.UpDownAxis_P1_Speed);
CloseDoor();
//发送消息给流水线
LineConnect.OutStoreEnd(Config.Id, Config.CID, (int)storeStatus, (int)storeRunStatus, StoreMove.MoveParam.PositionNum, StoreMove.MoveParam.PlateH,StoreMove.MoveParam.PlateW);
int hasTray =(int) IOManager.IOValue(IO_Type.TrayCheck_Door);
LineConnect.OutStoreEnd(Config.Id, Config.CID, (int)storeStatus, (int)storeRunStatus, hasTray,StoreMove.MoveParam.PositionNum, StoreMove.MoveParam.PlateH,StoreMove.MoveParam.PlateW);
}
else if (StoreMove.MoveStep == StoreMoveStep.SO_13_GoBack)
{
......
......@@ -17,9 +17,7 @@ namespace OnlineStore.DeviceLibrary
/// 当前出入库的模式
/// </summary>
public static int CurrInOutType = 0;
public static readonly ILog LOGGER = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public static AC_SA_BoxBean Store = null;
public static AC_SA_Config Config = null;
......@@ -28,24 +26,7 @@ namespace OnlineStore.DeviceLibrary
public StoreManager()
{
}
//public static bool OpenShuoKe(AC_SA_BoxBean box)
//{
// //打开硕科步进驱动器端口
// Parity parity = (Parity)box.Config.CompressAxis_PortParity;
// StopBits bit = (StopBits)box.Config.CompressAxis_StopBits;
// bool result = ShuoKeControls.InitPort(box.Config.CompressAxis_PortName, box.Config.CompressAxis_PortBaudrate,
// box.Config.CompressAxis_PortParity, 8, bit);
// if (result)
// {
// LogUtil.info(box.StoreName + "打开硕科步进控制器【" + box.Config.CompressAxis_PortName + "】成功");
// return true;
// }
// else
// {
// LogUtil.error(box.StoreName + "打开硕科步进控制器【" + box.Config.CompressAxis_PortName + "】失败,启动失败!");
// return false;
// }
//}
public static void CheckEnum(Type type)
{
if (type.IsEnum)
......
......@@ -17,10 +17,11 @@ namespace OnlineStore.DeviceLibrary
int linePort = ConfigAppSettings.GetIntValue(Setting_Init.LineServerPort);
if (lineServer.Equals(""))
{
LogUtil.error("未配置流水线地址,不需要连接");
return;
}
}
client = new TcpClient();
bool result = client.connect(lineServer, linePort, HandlerMsg,2000);
bool result = client.StartConnect(lineServer, linePort, HandlerMsg,2000);
}
......@@ -44,7 +45,7 @@ namespace OnlineStore.DeviceLibrary
return seq;
}
public static void SendHeart(int id,string cid,int ss,int runs,string posid)
public static void SendHeart(int id,string cid,int ss,int runs,int doorHasTray,string posid)
{
if (client == null)
{
......@@ -52,14 +53,24 @@ namespace OnlineStore.DeviceLibrary
}
try
{
string heartMsg = cmd_heart + cmd_spilt + id + cmd_spilt + cid + cmd_spilt + nextSeq() + cmd_spilt + ss + cmd_spilt + runs + cmd_spilt + posid + cmd_spilt+"\r";
List<object> paramList = new List<object>();
paramList.Add(cmd_heart);
paramList.Add(id);
paramList.Add(cid);
paramList.Add(nextSeq());
paramList.Add(ss);
paramList.Add(runs);
paramList.Add(doorHasTray);
paramList.Add(posid);
string heartMsg = ToParamStr(paramList);
client.send(heartMsg);
}catch(Exception ex)
{
LogUtil.error("SendHeart 出错:"+ex.ToString());
}
}
public static void OutStoreEnd(int id, string cid, int ss, int runs, string posid, string plateH, string plateW)
public static void OutStoreEnd(int id, string cid, int ss, int runs, int doorHasTray, string posid, string plateH, string plateW)
{
if (client == null)
{
......@@ -67,8 +78,22 @@ namespace OnlineStore.DeviceLibrary
}
try
{
string heartMsg = cmd_outend + cmd_spilt + id + cmd_spilt + cid + cmd_spilt + nextSeq() + cmd_spilt + ss + cmd_spilt + runs + cmd_spilt + posid + cmd_spilt;
string msg = heartMsg + posid + cmd_spilt + plateH + cmd_spilt + plateW + cmd_spilt + "\r";
List<object> paramList = new List<object>();
paramList.Add(cmd_outend);
paramList.Add(id);
paramList.Add(cid);
paramList.Add(nextSeq());
paramList.Add(ss);
paramList.Add(runs);
paramList.Add(doorHasTray);
paramList.Add(posid);
paramList.Add(posid);
paramList.Add(plateH);
paramList.Add(plateW);
//string heartMsg = cmd_outend + cmd_spilt + id + cmd_spilt + cid + cmd_spilt + nextSeq() + cmd_spilt + ss + cmd_spilt + runs + cmd_spilt + doorHasTray+ cmd_spilt + posid + cmd_spilt;
//string msg = heartMsg + posid + cmd_spilt + plateH + cmd_spilt + plateW + cmd_spilt + "\r";
string msg = ToParamStr(paramList);
client.send(msg );
}
catch (Exception ex)
......@@ -76,45 +101,74 @@ namespace OnlineStore.DeviceLibrary
LogUtil.error("OutStoreEnd 出错:" + ex.ToString());
}
}
private static string ToParamStr(List<object> paramList)
{
string result = "";
foreach(object str in paramList)
{
result += str + cmd_spilt.ToString();
}
return result+"\r";
}
private static void HandlerMsg(string message)
{
try
{
string[] msgArray = message.Split(cmd_spilt);
if (msgArray.Length > 4)
if (msgArray.Length > 2)
{
string cmd = msgArray[0];
int canStartOut = Convert.ToInt32(msgArray[1]);
CanOutStore = canStartOut.Equals(1);
LastUpdateTime = DateTime.Now;
if (cmd.Equals(cmd_startIn))
{
string posId = msgArray[1];
string plateH = msgArray[2];
string plateW = msgArray[3];
string code = msgArray[4];
LogUtil.info("收到流水线入库消息:" + message);
string posId = msgArray[2];
string plateH = msgArray[3];
string plateW = msgArray[4];
string code = msgArray[5];
StoreManager.Store.ReviceLineInStoreCMD(posId, plateH, plateW, code);
}
else
{
LogUtil.info("收到消息:" + message);
}
}
}
catch (Exception ex)
{
LogUtil.error("处理流水线消息出错:" + message );
}
}
public static char cmd_spilt = ';';
private static string cmd_heart = "heart";
private static string cmd_outend = "outend";
private static string cmd_startIn = "starIn";
private static bool CanOutStore = false;
public static DateTime LastUpdateTime = new DateTime(0);
public static bool IsConnect()
{
{
if (client == null)
{
return false;
}
if (client.IsConnected())
if (client.IsRun()&& client.IsConnected())
{
return true;
}
return false ;
}
public static bool CanStartOut()
{
TimeSpan span = DateTime.Now - LastUpdateTime;
if (span.TotalSeconds < 3 && CanOutStore)
{
return true;
}
return false;
}
}
}
......@@ -45,7 +45,7 @@ namespace OnlineStore.DeviceLibrary
private bool isInit = false;
protected bool IsDebug = false;
public bool IsDebug = false;
public KTK_Store()
{
......
......@@ -332,11 +332,11 @@ namespace OnlineStore.LoadCSVLibrary
[ConfigProAttribute("IsUse_Tray_Check")]
public int IsUse_Tray_Check { get; set; }
/// <summary>
/// 设备是否处于调试状态(1=调试,0=正常)
/// </summary>
[ConfigProAttribute("IsInDebug")]
public int IsInDebug { get; set; }
///// <summary>
///// 设备是否处于调试状态(1=调试,0=正常)
///// </summary>
//[ConfigProAttribute("IsInDebug")]
//public int IsInDebug { get; set; }
/// <summary>
///轴2升降轴 运动上下轴
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!