1. gocator添加重试和清理缓存操作
2. gts板卡调整监听频率
3. 记录产品数据使用filsstream避免程序崩溃影响
| | |
| | | } |
| | | set |
| | | { |
| | | LogAsync(DateTime.Now, $"设备状态切换:{_currentState.ToString()}->{value.ToString()}", ""); |
| | | _currentState = value; |
| | | |
| | | if (value != EnumHelper.DeviceState.TBD) |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | public override bool AllAxisOn() |
| | | { |
| | | List<Task<bool>> taskList = new List<Task<bool>>(); ; |
| | |
| | | responseMessage.Result = resultList.All(u => u == true); |
| | | if (!responseMessage.Result) |
| | | { |
| | | responseMessage.Message = $"点位运动异常"; |
| | | responseMessage.Message = $"点位运动异常,运动结果:{string.Join(" ", resultList.Select(u => u ? "1" : "0"))}"; |
| | | } |
| | | } |
| | | return responseMessage; |
| | |
| | | repeatTime--; |
| | | } |
| | | |
| | | return (ret == (short)GTSRetCode.GRCRunOK) && isStop; |
| | | if (repeatTime <= 0) |
| | | { |
| | | LogAsync(DateTime.Now, "轴" + optionPara.AxisIndex + "APS_absolute_move未停止", ""); |
| | | return false; |
| | | } |
| | | |
| | | //return (ret == (short)GTSRetCode.GRCRunOK) && isStop; |
| | | return true; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | OnExceptionOccured?.Invoke(DateTime.Now, ex); |
| | | return false; |
| | | } |
| | | finally |
| | | { |
| | | |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | } |
| | | }); |
| | | |
| | | _positionWait.SpinOnce(); |
| | | Task.Delay(100).Wait(); |
| | | |
| | | //_positionWait.SpinOnce(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | } |
| | | }); |
| | | |
| | | _statusWait.SpinOnce(); |
| | | Thread.Sleep(10); |
| | | //Task.Delay(10).Wait(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 |
| | | //通过使用 "*",如下所示: |
| | | // [assembly: AssemblyVersion("1.0.*")] |
| | | [assembly: AssemblyVersion("1.0.0.0")] |
| | | [assembly: AssemblyFileVersion("1.0.0.0")] |
| | | [assembly: AssemblyVersion("1.0.1.0")] |
| | | [assembly: AssemblyFileVersion("1.0.1.0")] |
| | |
| | | using System.Drawing; |
| | | using System.IO; |
| | | using System.Linq; |
| | | using System.Runtime.CompilerServices; |
| | | using System.Runtime.InteropServices; |
| | | using System.Text; |
| | | using System.Threading; |
| | |
| | | } |
| | | } |
| | | |
| | | [MethodImpl(MethodImplOptions.Synchronized)] |
| | | public override IImageSet Snapshot(IOperationConfig config) |
| | | { |
| | | GocatorOperationConfig opConfig = config as GocatorOperationConfig; |
| | |
| | | { |
| | | try |
| | | { |
| | | system.Start(); |
| | | sensor.Start(); |
| | | LogAsync(DateTime.Now, $"传感器状态:{sensor.State.ToString()}", ""); |
| | | if (sensor.State != GoState.Running) |
| | | { |
| | | Thread.Sleep(100); |
| | |
| | | catch (Exception ex) |
| | | { |
| | | LogAsync(DateTime.Now, $"开启异常:{ex.GetExceptionMessage()}", ""); |
| | | Thread.Sleep(100); |
| | | } |
| | | } while (true); |
| | | |
| | |
| | | return null; |
| | | } |
| | | |
| | | try |
| | | int reTryTime = 3; |
| | | do |
| | | { |
| | | dataSet = system.ReceiveData(IIConfig.SnapshotTimeout); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogAsync(DateTime.Now, $"{Name}获取图像异常", ex.GetExceptionMessage()); |
| | | imgSet.HImage = null; |
| | | dataSet = null; |
| | | //return imgSet; |
| | | } |
| | | try |
| | | { |
| | | dataSet = system.ReceiveData(IIConfig.SnapshotTimeout); |
| | | reTryTime = 0; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | reTryTime--; |
| | | LogAsync(DateTime.Now, $"{Name}获取图像异常", ex.GetExceptionMessage()); |
| | | |
| | | if (reTryTime <= 0) |
| | | { |
| | | imgSet.HImage = null; |
| | | dataSet = null; |
| | | system.ClearData(); |
| | | } |
| | | } |
| | | } while (reTryTime > 0); |
| | | } |
| | | |
| | | if (!IIConfig.IsAsyncMode) |
| | |
| | | { |
| | | try |
| | | { |
| | | system.Stop(); |
| | | sensor.Stop(); |
| | | |
| | | LogAsync(DateTime.Now, $"传感器状态:{sensor.State.ToString()}", ""); |
| | | if (sensor.State != GoState.Ready) |
| | | { |
| | | Thread.Sleep(100); |
| | |
| | | catch (Exception ex) |
| | | { |
| | | LogAsync(DateTime.Now, $"关闭异常:{ex.GetExceptionMessage()}", ""); |
| | | Thread.Sleep(100); |
| | | } |
| | | } while (true); |
| | | |
| | |
| | | { |
| | | base.Start(); |
| | | |
| | | //system.Start(); |
| | | if (sensor.State != GoState.Ready) |
| | | { |
| | | system.Start(); |
| | | } |
| | | |
| | | if (IIConfig.IsAsyncMode) |
| | | system.Start(); |
| | | { |
| | | sensor.Start(); |
| | | } |
| | | else |
| | | { |
| | | //if (sensor.State == GoState.Ready) |
| | | { |
| | | sensor.Stop(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | protected override void Stop() |
| | |
| | | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 |
| | | //通过使用 "*",如下所示: |
| | | // [assembly: AssemblyVersion("1.0.*")] |
| | | [assembly: AssemblyVersion("1.0.1.0")] |
| | | [assembly: AssemblyFileVersion("1.0.1.0")] |
| | | [assembly: AssemblyVersion("1.0.2.0")] |
| | | [assembly: AssemblyFileVersion("1.0.2.0")] |
| | |
| | | using System.Drawing.Imaging; |
| | | using System.IO; |
| | | using System.Linq; |
| | | using System.Runtime.CompilerServices; |
| | | using System.Text; |
| | | using System.Threading; |
| | | using System.Threading.Tasks; |
| | |
| | | List<ProductionMeasurement> productionList = new List<ProductionMeasurement>(); |
| | | |
| | | [ProcessMethod("", "StartJob", "开始扫描", InvokeType.TestInvoke)] |
| | | [MethodImpl(MethodImplOptions.Synchronized)] |
| | | public ProcessResponse StartJob(IOperationConfig opConfig, IDevice invokeDevice, IDevice sourceDevice) |
| | | { |
| | | if (!IsAllowedWork) |
| | |
| | | using System.ComponentModel; |
| | | using System.Data; |
| | | using System.Drawing; |
| | | using System.IO; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading; |
| | | using System.Threading.Tasks; |
| | | using System.Windows.Forms; |
| | | using static Bro.Common.Helper.EnumHelper; |
| | |
| | | /// </summary> |
| | | private void InitializeComponent() |
| | | { |
| | | this.components = new System.ComponentModel.Container(); |
| | | this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); |
| | | this.plStatistic = new System.Windows.Forms.Panel(); |
| | | this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); |
| | | this.ctmsClearQty = new System.Windows.Forms.ContextMenuStrip(this.components); |
| | | this.tsmiClearQty = new System.Windows.Forms.ToolStripMenuItem(); |
| | | this.label1 = new System.Windows.Forms.Label(); |
| | | this.label2 = new System.Windows.Forms.Label(); |
| | | this.label3 = new System.Windows.Forms.Label(); |
| | |
| | | this.flowLayoutPanel1.SuspendLayout(); |
| | | this.plStatistic.SuspendLayout(); |
| | | this.tableLayoutPanel1.SuspendLayout(); |
| | | this.ctmsClearQty.SuspendLayout(); |
| | | this.plCT.SuspendLayout(); |
| | | this.tableLayoutPanel2.SuspendLayout(); |
| | | this.plOEE.SuspendLayout(); |
| | |
| | | this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 30F)); |
| | | this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 35F)); |
| | | this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 35F)); |
| | | this.tableLayoutPanel1.ContextMenuStrip = this.ctmsClearQty; |
| | | this.tableLayoutPanel1.Controls.Add(this.label1, 0, 0); |
| | | this.tableLayoutPanel1.Controls.Add(this.label2, 0, 1); |
| | | this.tableLayoutPanel1.Controls.Add(this.label3, 0, 2); |
| | |
| | | this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 33F)); |
| | | this.tableLayoutPanel1.Size = new System.Drawing.Size(215, 100); |
| | | this.tableLayoutPanel1.TabIndex = 0; |
| | | // |
| | | // ctmsClearQty |
| | | // |
| | | this.ctmsClearQty.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { |
| | | this.tsmiClearQty}); |
| | | this.ctmsClearQty.Name = "ctmsClearQty"; |
| | | this.ctmsClearQty.Size = new System.Drawing.Size(125, 26); |
| | | // |
| | | // tsmiClearQty |
| | | // |
| | | this.tsmiClearQty.Name = "tsmiClearQty"; |
| | | this.tsmiClearQty.Size = new System.Drawing.Size(124, 22); |
| | | this.tsmiClearQty.Text = "计数清零"; |
| | | this.tsmiClearQty.Click += new System.EventHandler(this.tsmiClearQty_Click); |
| | | // |
| | | // label1 |
| | | // |
| | |
| | | this.btnClearStatistic.TabIndex = 8; |
| | | this.btnClearStatistic.Text = "清 零"; |
| | | this.btnClearStatistic.UseVisualStyleBackColor = true; |
| | | this.btnClearStatistic.Visible = false; |
| | | this.btnClearStatistic.Click += new System.EventHandler(this.btnClearStatistic_Click); |
| | | // |
| | | // plCT |
| | |
| | | this.plStatistic.ResumeLayout(false); |
| | | this.tableLayoutPanel1.ResumeLayout(false); |
| | | this.tableLayoutPanel1.PerformLayout(); |
| | | this.ctmsClearQty.ResumeLayout(false); |
| | | this.plCT.ResumeLayout(false); |
| | | this.tableLayoutPanel2.ResumeLayout(false); |
| | | this.tableLayoutPanel2.PerformLayout(); |
| | |
| | | private System.Windows.Forms.Button btnRefreshOEE; |
| | | private System.Windows.Forms.Label lblCT; |
| | | private System.Windows.Forms.Label lblUPH; |
| | | private System.Windows.Forms.ContextMenuStrip ctmsClearQty; |
| | | private System.Windows.Forms.ToolStripMenuItem tsmiClearQty; |
| | | } |
| | | } |
| | |
| | | using System; |
| | | using System.Configuration; |
| | | using System.IO; |
| | | using System.Runtime.CompilerServices; |
| | | using System.Threading.Tasks; |
| | | using System.Windows.Forms; |
| | | using WeifenLuo.WinFormsUI.Docking; |
| | | using static Bro.Common.Helper.EnumHelper; |
| | | |
| | |
| | | CurrentState = RunState.Stop; |
| | | } |
| | | |
| | | if (state == EnumHelper.DeviceState.DSClose) |
| | | { |
| | | SaveNumRecord(); |
| | | } |
| | | //if (state == EnumHelper.DeviceState.DSClose) |
| | | //{ |
| | | // SaveNumRecord(); |
| | | //} |
| | | } |
| | | |
| | | private void CheckIdle(object state) |
| | |
| | | |
| | | Task.Run(() => |
| | | { |
| | | SaveNumRecord(); |
| | | SaveNumRecord(Qty_OK, Qty_NG); |
| | | }); |
| | | } |
| | | |
| | |
| | | AvailableTime = AvailableTime.Add(new TimeSpan(0, 0, 1)); |
| | | } |
| | | |
| | | private void OnClearQty() |
| | | { |
| | | Qty_OK = Qty_NG = 0; |
| | | } |
| | | //private void OnClearQty() |
| | | //{ |
| | | // Qty_OK = Qty_NG = 0; |
| | | //} |
| | | |
| | | string numRecordFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Statistic.json"); |
| | | static object numLock = new object(); |
| | | private void SaveNumRecord() |
| | | |
| | | [MethodImpl(MethodImplOptions.Synchronized)] |
| | | private void SaveNumRecord(int okNum, int ngNum) |
| | | { |
| | | lock (numLock) |
| | | { |
| | | using (StreamWriter writer = new StreamWriter(numRecordFile, false, System.Text.Encoding.UTF8)) |
| | | try |
| | | { |
| | | string dataStr = JsonConvert.SerializeObject(new { Qty_OK, Qty_NG }); |
| | | writer.Write(dataStr); |
| | | writer.Flush(); |
| | | //using (StreamWriter writer = new StreamWriter(numRecordFile, false, System.Text.Encoding.UTF8)) |
| | | //{ |
| | | // if (okNum % 5 == 0) |
| | | // { |
| | | // Application.Exit(); |
| | | // throw new AccessViolationException(); |
| | | // } |
| | | // string dataStr = JsonConvert.SerializeObject(new StatisticModel() { Qty_OK = okNum, Qty_NG = ngNum }); |
| | | // if (!string.IsNullOrWhiteSpace(dataStr)) |
| | | // { |
| | | // writer.Write(dataStr); |
| | | // writer.Flush(); |
| | | // } |
| | | //} |
| | | |
| | | using (FileStream fs = new FileStream(numRecordFile, FileMode.OpenOrCreate, FileAccess.Write)) |
| | | { |
| | | fs.Seek(0, SeekOrigin.Begin); |
| | | |
| | | string dataStr = JsonConvert.SerializeObject(new StatisticModel() { Qty_OK = okNum, Qty_NG = ngNum }); |
| | | |
| | | byte[] dataBuf = System.Text.Encoding.UTF8.GetBytes(dataStr); |
| | | fs.Write(dataBuf, 0, dataBuf.Length); |
| | | fs.SetLength(dataBuf.Length); |
| | | fs.Flush(); |
| | | fs.Close(); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogAsync(DateTime.Now, $"保存统计数据异常,{ex.GetExceptionMessage()}"); |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | string dataStr = reader.ReadToEnd(); |
| | | |
| | | JObject data = JsonConvert.DeserializeObject<JObject>(dataStr); |
| | | //JObject data = JsonConvert.DeserializeObject<JObject>(dataStr); |
| | | |
| | | if (data != null) |
| | | //if (data != null) |
| | | //{ |
| | | // Qty_OK = data.Value<int>("Qty_OK"); |
| | | // Qty_NG = data.Value<int>("Qty_NG"); |
| | | //} |
| | | |
| | | StatisticModel model = JsonConvert.DeserializeObject<StatisticModel>(dataStr); |
| | | if (model != null) |
| | | { |
| | | Qty_OK = data.Value<int>("Qty_OK"); |
| | | Qty_NG = data.Value<int>("Qty_NG"); |
| | | Qty_OK = model.Qty_OK; |
| | | Qty_NG = model.Qty_NG; |
| | | } |
| | | else |
| | | { |
| | | //LogAsync(DateTime.Now, $"载入统计数据错误", ""); |
| | | MessageBox.Show($"载入统计数据错误"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //LogAsync(DateTime.Now, $"统计数据文件不存在", ""); |
| | | MessageBox.Show($"统计数据文件不存在"); |
| | | } |
| | | } |
| | | |
| | | private void btnClearStatistic_Click(object sender, EventArgs e) |
| | | { |
| | | //Qty_OK = Qty_NG = 0; |
| | | } |
| | | |
| | | private void tsmiClearQty_Click(object sender, EventArgs e) |
| | | { |
| | | Qty_OK = Qty_NG = 0; |
| | | } |
| | | } |
| | | |
| | | public class StatisticModel |
| | | { |
| | | public int Qty_OK { get; set; } |
| | | |
| | | public int Qty_NG { get; set; } |
| | | } |
| | | } |
| | |
| | | <resheader name="writer"> |
| | | <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
| | | </resheader> |
| | | <metadata name="ctmsClearQty.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> |
| | | <value>17, 17</value> |
| | | </metadata> |
| | | </root> |
| | |
| | | // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 |
| | | // 方法是按如下所示使用“*”: : |
| | | // [assembly: AssemblyVersion("1.0.*")] |
| | | [assembly: AssemblyVersion("1.0.0.0")] |
| | | [assembly: AssemblyFileVersion("1.0.0.0")] |
| | | [assembly: AssemblyVersion("1.0.1.0")] |
| | | [assembly: AssemblyFileVersion("1.0.1.0")] |