Commit 3e7085ac 几米阳光

增加开机自启动功能。出库需要等待物品拿走或等待10秒

1 个父辈 5e426b78
......@@ -83,6 +83,7 @@
<Compile Include="FrmStoreBox.Designer.cs">
<DependentUpon>FrmStoreBox.cs</DependentUpon>
</Compile>
<Compile Include="ManagerUtil.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="WCFControl.cs" />
......@@ -222,7 +223,11 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="AuToRunManager.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="box.ico" />
<Content Include="记录.txt" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services\" />
......
此文件类型无法预览
......@@ -155,6 +155,7 @@
this.groupBox6 = new System.Windows.Forms.GroupBox();
this.btnOpenWCF = new System.Windows.Forms.Button();
this.btnCloseWCF = new System.Windows.Forms.Button();
this.chbAuto = new System.Windows.Forms.CheckBox();
this.groupBox5.SuspendLayout();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
......@@ -1600,28 +1601,28 @@
// 启动ToolStripMenuItem
//
this.启动ToolStripMenuItem.Name = "启动ToolStripMenuItem";
this.启动ToolStripMenuItem.Size = new System.Drawing.Size(124, 22);
this.启动ToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.启动ToolStripMenuItem.Text = "启动";
this.启动ToolStripMenuItem.Click += new System.EventHandler(this.启动ToolStripMenuItem_Click);
//
// 停止ToolStripMenuItem
//
this.停止ToolStripMenuItem.Name = "停止ToolStripMenuItem";
this.停止ToolStripMenuItem.Size = new System.Drawing.Size(124, 22);
this.停止ToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.停止ToolStripMenuItem.Text = "停止";
this.停止ToolStripMenuItem.Click += new System.EventHandler(this.停止ToolStripMenuItem_Click);
//
// 复位ToolStripMenuItem
//
this.复位ToolStripMenuItem.Name = "复位ToolStripMenuItem";
this.复位ToolStripMenuItem.Size = new System.Drawing.Size(124, 22);
this.复位ToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.复位ToolStripMenuItem.Text = "复位";
this.复位ToolStripMenuItem.Click += new System.EventHandler(this.复位ToolStripMenuItem_Click);
//
// 回待机点ToolStripMenuItem
//
this.回待机点ToolStripMenuItem.Name = "回待机点ToolStripMenuItem";
this.回待机点ToolStripMenuItem.Size = new System.Drawing.Size(124, 22);
this.回待机点ToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.回待机点ToolStripMenuItem.Text = "回待机点";
this.回待机点ToolStripMenuItem.Click += new System.EventHandler(this.回待机点ToolStripMenuItem_Click);
//
......@@ -1793,11 +1794,23 @@
this.btnCloseWCF.UseVisualStyleBackColor = true;
this.btnCloseWCF.Click += new System.EventHandler(this.btnCloseWCF_Click);
//
// chbAuto
//
this.chbAuto.AutoSize = true;
this.chbAuto.Location = new System.Drawing.Point(515, 693);
this.chbAuto.Name = "chbAuto";
this.chbAuto.Size = new System.Drawing.Size(99, 21);
this.chbAuto.TabIndex = 270;
this.chbAuto.Text = "开机自动启动";
this.chbAuto.UseVisualStyleBackColor = true;
this.chbAuto.CheckedChanged += new System.EventHandler(this.chbAuto_CheckedChanged);
//
// FrmStoreBox
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.ClientSize = new System.Drawing.Size(1008, 726);
this.Controls.Add(this.chbAuto);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.groupBox6);
this.Controls.Add(this.groupBox3);
......@@ -1962,6 +1975,7 @@
private System.Windows.Forms.Button btnCloseWCF;
private System.Windows.Forms.CheckBox chbAutoRead;
private System.Windows.Forms.Label lblTemp;
private System.Windows.Forms.CheckBox chbAuto;
}
}
......@@ -28,6 +28,7 @@ namespace OnlineStore.ACSingleStore
{
Control.CheckForIllegalCrossThreadCalls = false;
InitializeComponent();
chbAuto.Checked = ConfigAppSettings.GetIntValue(Setting_Init.App_AutoRun).Equals(1);
}
#region "初始化界面数据"
......@@ -136,12 +137,14 @@ namespace OnlineStore.ACSingleStore
复位ToolStripMenuItem.Enabled = isOpen;
}
private bool LoadOk = false;
private void FrmTest_Load(object sender, EventArgs e)
{
LogUtil.logBox = this.richTextBox1;
initValue();
this.ShowInTaskbar = true;
this.Text = ConfigAppSettings.GetValue(Setting_Init.App_Title);
LoadOk = true;
}
private DateTime preReadModblsTime = DateTime.Now;
private void timer1_Tick(object sender, EventArgs e)
......@@ -1044,58 +1047,7 @@ namespace OnlineStore.ACSingleStore
}
public List<WaitResultInfo> waitResultList = new List<WaitResultInfo>();
//private void btnStart_Click(object sender, EventArgs e)
//{
// waitResultList = new List<WaitResultInfo>();
// string deviceName = "";
// short slvAddr = 0;
// int position=0;
// if (chb1.Checked)
// {
// position=FormUtil.GetIntValue(txtPosition1);
// deviceName = store.Config.Middle_Axis.DeviceName;
// slvAddr = store.Config.Middle_Axis.GetAxisValue();
// if (ACServerManager.ServerOnStatus(deviceName, slvAddr))
// {
// ACServerManager.AbsMove(deviceName, slvAddr, position);
// waitResultList.Add(WaitResultInfo.WaitAxis(store.Config.Middle_Axis,position,store.Config.Middle_Axis.TargetSpeed));
// }
// }
// if (chb2.Checked)
// {
// position = FormUtil.GetIntValue(txtPosition2);
// deviceName = store.Config.UpDown_Axis.DeviceName;
// slvAddr = store.Config.UpDown_Axis.GetAxisValue();
// if (ACServerManager.ServerOnStatus(deviceName, slvAddr))
// {
// ACServerManager.AbsMove(deviceName, slvAddr, position);
// waitResultList.Add(WaitResultInfo.WaitAxis(store.Config.UpDown_Axis, position, store.Config.UpDown_Axis.TargetSpeed));
// }
// }
// if (chb3.Checked)
// {
// position = FormUtil.GetIntValue(txtPosition3);
// deviceName = store.Config.InOut_Axis.DeviceName;
// slvAddr = store.Config.InOut_Axis.GetAxisValue();
// if (ACServerManager.ServerOnStatus(deviceName, slvAddr))
// {
// ACServerManager.AbsMove(deviceName, slvAddr, position);
// waitResultList.Add(WaitResultInfo.WaitAxis(store.Config.UpDown_Axis, position, store.Config.UpDown_Axis.TargetSpeed));
// }
// }
// if (waitResultList.Count > 0)
// {
// LOGGER.Info("运动开始");
// // MessageBox.Show("运动开始!");
// }
// else
// {
// MessageBox.Show("未选择运动轴或伺服未打开");
// }
//}
private int GetSlaveAddr()
{
return FormUtil.GetShortValue(txtAxisValue);
......@@ -1146,5 +1098,23 @@ namespace OnlineStore.ACSingleStore
{
WCFControl.CloseWCF();
}
private void chbAuto_CheckedChanged(object sender, EventArgs e)
{
if (!LoadOk)
{
return;
}
if (chbAuto.Checked)
{
ConfigAppSettings.SaveValue(Setting_Init.App_AutoRun, 1);
ManagerUtil.AutoRun(Application.ExecutablePath, true);
}
else
{
ConfigAppSettings.SaveValue(Setting_Init.App_AutoRun, 0);
ManagerUtil.AutoRun(Application.ExecutablePath, false);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Forms;
namespace OnlineStore.ACSingleStore
{
public class ManagerUtil
{
public static void AutoRun(string strName, bool value)
{
try
{
//创建启动对象
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
//设置运行文件
startInfo.FileName = System.Windows.Forms.Application.StartupPath + "\\AuToRunManager.exe";
//设置启动参数
startInfo.Arguments = String.Join(" ", new string[2] { strName, value.ToString() });
//设置启动动作,确保以管理员身份运行
startInfo.Verb = "runas";
//如果不是管理员,则启动UAC
System.Diagnostics.Process.Start(startInfo);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
}
1.出库到入料口后,出库之后等待10秒钟如果不拿走,自动扫码
2.添加开机自动启动的功能
......@@ -863,7 +863,7 @@ namespace OnlineStore.DeviceLibrary
{
//取新的Io状态
IO_VALUE autoSingle = KNDIOValue(IO_Type.AutoRun_Single);
if (ConfigAppSettings.GetIntValue(Setting_Init.App_AutoRun) == 1)
if (ConfigAppSettings.GetIntValue(Setting_Init.App_AutoRun) .Equals( 1))
{
if (autoSingle.Equals(IO_VALUE.HIGH) && lastAutoRun.Equals(IO_VALUE.LOW))
{
......
......@@ -674,6 +674,14 @@ namespace OnlineStore.DeviceLibrary
}
else if (StoreMove.MoveStep == StoreMoveStep.SO_13_GoBack)
{
StoreMove.NextMoveStep(StoreMoveStep.SO_14_WaitTake);
OutStoreLog("出库:SO_14_WaitTake 等待拿走物品,最多等待10秒");
StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.TrayCheck_Door,IO_VALUE.LOW ));
StoreMove.WaitList.Add(WaitResultInfo.WaitTime(10000));
StoreMove.OneWaitCanEndStep = true;
}
else if (StoreMove.MoveStep == StoreMoveStep.SO_14_WaitTake)
{
string posId = StoreMove.MoveParam != null ? StoreMove.MoveParam.PositionNum : "";
storeStatus = StoreStatus.OutStoreBoxEnd;
......
......@@ -325,6 +325,10 @@ namespace OnlineStore.DeviceLibrary
/// 料仓出库,,升降轴返回,, 轴2至P1( 待机点)
/// </summary>
SO_13_GoBack = 113,
/// <summary>
/// 等待拿走物品
/// </summary>
SO_14_WaitTake=114,
#endregion
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!