Commit 6bfa721a LN

1

1 个父辈 1358d0b3
......@@ -50,10 +50,8 @@ namespace OnlineStore.Common
return GetNumValue(keyStr);
}
else
{
{
Decimal.TryParse(config.AppSettings.Settings[key].Value, out a);
}
{
Decimal.TryParse(config.AppSettings.Settings[key].Value, out a);
}
return a;
}
......@@ -67,11 +65,10 @@ namespace OnlineStore.Common
return GetIntValue(keyStr);
}
else
{
{
Int32.TryParse(config.AppSettings.Settings[key].Value, out a);
}
} return a;
{
Int32.TryParse(config.AppSettings.Settings[key].Value, out a);
}
return a;
}
public static string GetValue(string key)
{
......@@ -97,10 +94,8 @@ namespace OnlineStore.Common
return a;
}
else
{
{
Decimal.TryParse(config.AppSettings.Settings[key].Value, out a);
}
{
Decimal.TryParse(config.AppSettings.Settings[key].Value, out a);
}
return a;
}
......@@ -111,14 +106,13 @@ namespace OnlineStore.Common
if (config.AppSettings.Settings[key] == null)
{
LOGGER.Error("未找到配置:" + key + ",请检查配置是否完整!");
return a;
return a;
}
else
{
{
Int32.TryParse(config.AppSettings.Settings[key].Value, out a);
}
} return a;
{
Int32.TryParse(config.AppSettings.Settings[key].Value, out a);
}
return a;
}
public static void SaveValue(string key, int value)
{
......
......@@ -14,106 +14,87 @@ namespace OnlineStore.Common
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(MethodBase.GetCurrentMethod().DeclaringType);
public static Dictionary<int, DateTime> lastErrorLogTime = new Dictionary<int, DateTime>();
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public static Dictionary<int, DateTime> lastErrorLogTime = new Dictionary<int, DateTime>();
public static System.Windows.Forms.RichTextBox logBox = null;
public static int showCount = 20;
public static bool debug_opened = false;
public static void info(ILog log,string msg )
public static int showCount = 20;
public static bool debug_opened = false;
public static void info(ILog log, string msg)
{
if (log == null)
{
return;
}
log.Info( " - " + msg);
AddToBox(msg, Color.Black);
log.Info(msg);
AddToBox(msg, Color.Black);
//clear();
}
public static void info(ILog log,string msg, Color color)
public static void info(ILog log, string msg, Color color)
{
log.Info( " - " + msg);
AddToBox(msg, color);
log.Info(msg);
AddToBox(msg, color);
}
public static void debug(ILog log, string msg, Color color)
{
log.Debug( " - " + msg);
log.Debug(msg);
if (debug_opened)
{
{
AddToBox(msg, color);
}
}
public static void debug(ILog log, string msg)
{
log.Debug( " - " + msg);
log.Debug(msg);
if (debug_opened)
{
AddToBox(msg, Color.Gray);
{
AddToBox(msg, Color.Gray);
}
}
private static List<string> lasErrorLogList = new List<string>();
private static int errCount = 5;
public static void error( string errorMsg,int type,int spanSeconds=10)
}
public static void error(string errorMsg, int type)
{
if (lastErrorLogTime.ContainsKey(type))
{
try
{
TimeSpan span = DateTime.Now - lastErrorLogTime[type];
if (span.TotalSeconds < spanSeconds)
{
return;
}
else
{
lastErrorLogTime.Remove(type);
lastErrorLogTime.Add(type, DateTime.Now);
error( errorMsg);
}
}catch(Exception ex)
TimeSpan span = DateTime.Now - lastErrorLogTime[type];
if (span.TotalSeconds > 10)
{
lastErrorLogTime.Remove(type);
lastErrorLogTime.Add(type, DateTime.Now);
error(LOGGER, errorMsg);
}
}
else
{
lastErrorLogTime.Add(type, DateTime.Now);
error( errorMsg);
error(LOGGER, errorMsg);
}
}
public static void error(ILog log, string errorMsg, Exception ex = null)
{
if (errorMsg.Trim().Equals(""))
{
return;
}
if (ex == null)
{
log.Error(errorMsg);
AddToBox(errorMsg, Color.Red);
}
else
{
log.Error(errorMsg, ex);
AddToBox(errorMsg + ex.ToString(), Color.Red);
}
AddToBox(errorMsg, Color.Red);
}
private static void AddToBox(string msg, Color color)
{
try
{
ShowLogPro(msg, color);
{
ShowLogPro(msg, color);
}
catch (Exception ex)
{
LOGGER.Error("出错:" + ex.StackTrace);
}
LOGGER.Error("出错:", ex);
}
}
private static List<string> logList = new List<string>();
public static string LastText = "";
......@@ -149,7 +130,7 @@ namespace OnlineStore.Common
logBox.AppendText(now.ToLongTimeString() + " " + msg + Environment.NewLine); //增加文本
TimeSpan span = DateTime.Now - lastTime;
if (span.TotalSeconds > 1000)
if (span.TotalSeconds > 3000000)
{
lastTime = DateTime.Now;
logBox.Select(logBox.Text.Length, 0); //设置光标的位置到文本尾
......@@ -167,7 +148,15 @@ namespace OnlineStore.Common
{
if (logBox != null && logBox.Visible)
{
logBox.Text = LastText;
logBox.Text = LastText;
TimeSpan span = DateTime.Now - lastTime;
if (span.TotalSeconds > 3000000)
{
lastTime = DateTime.Now;
logBox.Select(logBox.Text.Length, 0); //设置光标的位置到文本尾
logBox.ScrollToCaret(); //滚动到控件光标处
}
}
}
public static void ClearLog()
......@@ -184,17 +173,13 @@ namespace OnlineStore.Common
{
debug(LOGGER, msg);
}
public static void error(string errorMsg,Exception ex=null)
public static void error(string errorMsg, Exception ex = null)
{
error( LOGGER,errorMsg);
error(LOGGER, errorMsg, ex);
}
public static void info(string msg)
{
info(LOGGER,msg );
info(LOGGER, msg);
}
}
}
......@@ -48,6 +48,10 @@
<Reference Include="halcondotnet">
<HintPath>..\..\..\RC32-SZBOSCH-ACSingleStore\dll\halcondotnet.dll</HintPath>
</Reference>
<Reference Include="HFReader9CSharp, Version=1.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\dll\RFID\HFReader9CSharp.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=1.2.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\dll\log4net.dll</HintPath>
......
......@@ -34,7 +34,7 @@ namespace OnlineStore.DeviceLibrary
{
if (!IOValue(ioType).Equals(ioValue))
{
IOMove(ioType, ioValues);
IOMove(ioType, ioValue);
}
}
public static IO_VALUE IOValue(string ioType)
......
......@@ -38,5 +38,5 @@ DO,出料线阻挡2下降,OutL_OutStopDown,8,PRO_AOI_IP_1,0,出料线阻挡2下降,Y729,DO-01,
PRO,IO信号超时时间(毫秒),IOSingle_TimerOut,10000,,,,,,,
PRO,出空料架流水线AGV节点名称,OutL_AgvName,A2,,,,,,,
PRO,入料架流水线AGV节点名称,InL_AgvName,A1,,,,,,,
PRO,入料架流水线入口RFIDIP,InL_In_RFIDIP,192.168.103.107,,,,,, ,
PRO,入料架流水线出口RFIDIP,InL_Out_RFIDIP,192.168.103.108,,,,,, ,
PRO,入料架流水线入口RFIDIP,InL_In_RFIDIP,192.168.102.107,,,,,, ,
PRO,入料架流水线出口RFIDIP,InL_Out_RFIDIP,192.168.102.108,,,,,, ,
......@@ -65,15 +65,16 @@ namespace OnlineStore.DeviceLibrary
/// </summary>
public bool StartRun()
{
LogUtil.info(Name + "开始启动,启动时间:" + DateTime.Now);
//急停按钮和气压检测需要一起判断
if (!AgvClient.ISConnected())
{
AgvClient.Init();
}
RFIDManager.Open(new string[] { Config.InL_In_RFIDIP,Config.InL_Out_RFIDIP});
LogUtil.info(Name + "开始启动,启动时间:" + DateTime.Now);
WarnMsg = "";
if (IOManager.IOValue(IO_Type.SuddenStop_BTN).Equals(IO_VALUE.HIGH))
{
{
//急停按钮和气压检测需要一起判断
if (!AgvClient.ISConnected())
{
AgvClient.Init();
}
RFIDManager.Open(new string[] { Config.InL_In_RFIDIP, Config.InL_Out_RFIDIP });
runStatus = RunStatus.HomeMoving;
MoveInfo.NewMove(LineMoveType.ReturnHome);
ReturnHome();
......@@ -418,9 +419,7 @@ namespace OnlineStore.DeviceLibrary
if (runStatus < RunStatus.Runing || isInSuddenDown)
{
return;
}
//若BOX和移栽都没有在等待Io的过程中则此Io超时异常可能已经处理过
}
if (alarmType.Equals(AlarmType.IoSingleTimeOut) && MoveInfo.IsInWait == false)
{
LogUtil.info(Name + "之前有IO超时报警,清理报警:" + WarnMsg);
......@@ -434,9 +433,10 @@ namespace OnlineStore.DeviceLibrary
LogUtil.error(" IOTimeOutProcess 出错:" + ex.ToString());
}
}
#region 与服务器通信定时器,每1秒向服务器通知一次状态,同时执行出库操作
#region 与服务器通信定时器,每1秒向服务器通知一次状态,同时执行出库操作
private string LastInShelfId = "";
private string LastOutShelfId = "";
private bool isInProcess = false;
public void server_connect_timer_Tick(object sender, EventArgs e)
{
......@@ -449,9 +449,10 @@ namespace OnlineStore.DeviceLibrary
{
LedProcess();
RFIDData rfidData = RFIDManager.ReadRFID(Config.InL_In_RFIDIP);
bool result = SendVmiRfid(rfidData.NumStr());
LastInShelfId = RFIDManager.ReadRFID(Config.InL_In_RFIDIP).NumStr();
LastOutShelfId = RFIDManager.ReadRFID(Config.InL_Out_RFIDIP).NumStr();
bool result = SendVmiRfid(LastInShelfId);
if (result)
{
IOManager.CIOMove(IO_Type.InL_InStopDown, IO_VALUE.HIGH);
......@@ -471,7 +472,7 @@ namespace OnlineStore.DeviceLibrary
private string http_server = ConfigAppSettings.GetValue(Setting_Init.http_server);
private string api_communication = "service/store/qisda/vmiRfid?rfid="; //流水线状态通信接口
private string lastLog = "";
public bool SendVmiRfid(string rfid)
{
try
......@@ -482,9 +483,15 @@ namespace OnlineStore.DeviceLibrary
}
string addr = http_server + api_communication + rfid;
string resultStr = HttpHelper.Post(addr, "");
string log = "vmiRfid 【" + addr + "】【" + resultStr + "】";
if (lastLog.Equals(log).Equals(false))
{
lastLog = log;
LogUtil.info(log);
}
if (resultStr.Equals("move"))
{
LogUtil.info("vmiRfid 【" + addr + "】【" + resultStr + "】");
return true;
}
}
......
......@@ -94,7 +94,7 @@ namespace OnlineStore.DeviceLibrary
}
public void SetWarnMsg(string msg = "")
{
if (String.IsNullOrEmpty(WarnMsg).Equals(false))
if (String.IsNullOrEmpty(msg).Equals(false))
{
if (WarnMsg.Equals(msg))
{
......@@ -122,6 +122,11 @@ namespace OnlineStore.DeviceLibrary
WarnMsg = msg;
}
public string GetRunInfo()
{
return "入料流水线:入库料架 ["+LastInShelfId+"] 出口料架 ["+LastOutShelfId+"]";
}
#endregion
}
......
此文件类型无法预览
......@@ -60,11 +60,11 @@
this.btnInLineRun = new System.Windows.Forms.Button();
this.btnOutL = new System.Windows.Forms.Button();
this.groupBox5 = new System.Windows.Forms.GroupBox();
this.txtname = new System.Windows.Forms.TextBox();
this.btnNeedEntry = new System.Windows.Forms.Button();
this.btnNeedLeave = new System.Windows.Forms.Button();
this.btnDis = new System.Windows.Forms.Button();
this.btnInit = new System.Windows.Forms.Button();
this.txtname = new System.Windows.Forms.TextBox();
this.groupBox3.SuspendLayout();
this.panel1.SuspendLayout();
this.contextMenuStrip1.SuspendLayout();
......@@ -84,9 +84,9 @@
//
this.lblWarnMsg.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblWarnMsg.ForeColor = System.Drawing.Color.Red;
this.lblWarnMsg.Location = new System.Drawing.Point(9, 66);
this.lblWarnMsg.Location = new System.Drawing.Point(267, 66);
this.lblWarnMsg.Name = "lblWarnMsg";
this.lblWarnMsg.Size = new System.Drawing.Size(1114, 52);
this.lblWarnMsg.Size = new System.Drawing.Size(856, 52);
this.lblWarnMsg.TabIndex = 224;
this.lblWarnMsg.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
......@@ -108,7 +108,7 @@
this.lblThisSta.AutoSize = true;
this.lblThisSta.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblThisSta.ForeColor = System.Drawing.Color.Green;
this.lblThisSta.Location = new System.Drawing.Point(303, 12);
this.lblThisSta.Location = new System.Drawing.Point(8, 83);
this.lblThisSta.Name = "lblThisSta";
this.lblThisSta.Size = new System.Drawing.Size(65, 19);
this.lblThisSta.TabIndex = 216;
......@@ -120,6 +120,7 @@
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox3.Controls.Add(this.lblWarnMsg);
this.groupBox3.Controls.Add(this.panel1);
this.groupBox3.Controls.Add(this.lblThisSta);
this.groupBox3.Location = new System.Drawing.Point(10, 6);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(1129, 124);
......@@ -134,7 +135,6 @@
this.panel1.Controls.Add(this.lblInfo);
this.panel1.Controls.Add(this.btnVmiExit);
this.panel1.Controls.Add(this.btnVmiStart);
this.panel1.Controls.Add(this.lblThisSta);
this.panel1.Controls.Add(this.chbDebug);
this.panel1.Controls.Add(this.btnVmiStop);
this.panel1.Controls.Add(this.chbAuto);
......@@ -146,7 +146,7 @@
// lblInfo
//
this.lblInfo.AutoSize = true;
this.lblInfo.Location = new System.Drawing.Point(593, 14);
this.lblInfo.Location = new System.Drawing.Point(274, 14);
this.lblInfo.Name = "lblInfo";
this.lblInfo.Size = new System.Drawing.Size(56, 17);
this.lblInfo.TabIndex = 273;
......@@ -157,7 +157,7 @@
//
this.btnVmiExit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnVmiExit.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnVmiExit.Location = new System.Drawing.Point(985, 3);
this.btnVmiExit.Location = new System.Drawing.Point(984, 3);
this.btnVmiExit.Name = "btnVmiExit";
this.btnVmiExit.Size = new System.Drawing.Size(132, 39);
this.btnVmiExit.TabIndex = 4;
......@@ -180,10 +180,10 @@
//
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(864, 10);
this.chbDebug.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chbDebug.Location = new System.Drawing.Point(893, 10);
this.chbDebug.Name = "chbDebug";
this.chbDebug.Size = new System.Drawing.Size(93, 25);
this.chbDebug.Size = new System.Drawing.Size(84, 24);
this.chbDebug.TabIndex = 271;
this.chbDebug.Text = "调试状态";
this.chbDebug.UseVisualStyleBackColor = true;
......@@ -192,7 +192,7 @@
// btnVmiStop
//
this.btnVmiStop.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnVmiStop.Location = new System.Drawing.Point(137, 3);
this.btnVmiStop.Location = new System.Drawing.Point(139, 3);
this.btnVmiStop.Name = "btnVmiStop";
this.btnVmiStop.Size = new System.Drawing.Size(132, 39);
this.btnVmiStop.TabIndex = 1;
......@@ -204,10 +204,10 @@
//
this.chbAuto.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.chbAuto.AutoSize = true;
this.chbAuto.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chbAuto.Location = new System.Drawing.Point(711, 10);
this.chbAuto.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chbAuto.Location = new System.Drawing.Point(772, 10);
this.chbAuto.Name = "chbAuto";
this.chbAuto.Size = new System.Drawing.Size(125, 25);
this.chbAuto.Size = new System.Drawing.Size(112, 24);
this.chbAuto.TabIndex = 270;
this.chbAuto.Text = "开机自动启动";
this.chbAuto.UseVisualStyleBackColor = true;
......@@ -501,6 +501,16 @@
this.groupBox5.TabStop = false;
this.groupBox5.Text = "AGV调度通信";
//
// txtname
//
this.txtname.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtname.Location = new System.Drawing.Point(299, 29);
this.txtname.MaxLength = 4;
this.txtname.Name = "txtname";
this.txtname.Size = new System.Drawing.Size(53, 26);
this.txtname.TabIndex = 5;
this.txtname.Text = "C2";
//
// btnNeedEntry
//
this.btnNeedEntry.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
......@@ -545,16 +555,6 @@
this.btnInit.UseVisualStyleBackColor = true;
this.btnInit.Click += new System.EventHandler(this.btnInit_Click);
//
// txtname
//
this.txtname.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtname.Location = new System.Drawing.Point(299, 29);
this.txtname.MaxLength = 4;
this.txtname.Name = "txtname";
this.txtname.Size = new System.Drawing.Size(53, 26);
this.txtname.TabIndex = 5;
this.txtname.Text = "C2";
//
// FrmVMIClient
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
......@@ -574,6 +574,7 @@
this.Load += new System.EventHandler(this.FrmTest_Load);
this.Shown += new System.EventHandler(this.FrmStoreBox_Shown);
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.contextMenuStrip1.ResumeLayout(false);
......
......@@ -122,8 +122,9 @@ namespace OnlineStore.ACSingleStore
return;
}
ReadIOList();
lblWarnMsg.Text = vmiLine.WarnMsg;
lblThisSta.Text = LineManager.GetRunStr(vmiLine.runStatus);
lblWarnMsg.Text = vmiLine.WarnMsg;
lblInfo.Text = vmiLine.GetRunInfo();
}
private void FrmTest_FormClosing(object sender, FormClosingEventArgs e)
......@@ -347,7 +348,7 @@ namespace OnlineStore.ACSingleStore
private void btnOutL_Click(object sender, EventArgs e)
{
BtnMove(btnOutL, "出料线体运转", "出料线体运转", IO_Type.InL_Run);
BtnMove(btnOutL, "出料线体运转", "出料线体停止", IO_Type.InL_Run);
}
private void btnOLOutStopDown_Click(object sender, EventArgs e)
......
......@@ -8,7 +8,7 @@
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OnlineStore.ACSingleStore</RootNamespace>
<AssemblyName>ACSingleStore</AssemblyName>
<AssemblyName>VMILineClient</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
......@@ -50,7 +50,7 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>box.ico</ApplicationIcon>
<ApplicationIcon>DfIcon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="halcondotnet">
......@@ -143,6 +143,7 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="box.ico" />
<Content Include="DfIcon.ico" />
<Content Include="记录.txt" />
</ItemGroup>
<ItemGroup>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!