// Initialize values using config file, or default values if config values not specified void InitConfigurable() { FeederConfig feederConfig = new FeederConfig(); // if running the game from the battery, override `feederConfig` with the config class from Battery FeederConfig tempConfig = (FeederConfig)Battery.Instance.GetCurrentConfig(); if (tempConfig != null) { feederConfig = tempConfig; } else { Debug.Log("Battery not found, using default values"); } // use battery's config values, or default values if running game by itself seed = !String.IsNullOrEmpty(feederConfig.Seed) ? feederConfig.Seed : DateTime.Now.ToString(); // if no seed provided, use current DateTime maxGameTime = feederConfig.MaxGameTime > 0 ? feederConfig.MaxGameTime : Default(90f, "MaxGameTime"); maxFoodDispensed = feederConfig.MaxFoodDispensed > 0 ? feederConfig.MaxFoodDispensed : Default(20, "MaxFoodDispensed"); uniqueFoods = feederConfig.UniqueFoods >= 2 && feederConfig.UniqueFoods <= dispenser.allFoods.Length ? feederConfig.UniqueFoods : Default(6, "UniqueFoods"); avgUpdateFreq = feederConfig.AverageUpdateFrequency > 0 ? feederConfig.AverageUpdateFrequency : Default(3f, "AverageUpdateFrequency"); updateFreqVariance = feederConfig.UpdateFreqVariance >= 0 && feederConfig.UpdateFreqVariance <= 1 ? feederConfig.UpdateFreqVariance : Default(0.3f, "UpdateFreqVariance"); // udpate battery config with actual/final values being used feederConfig.Seed = seed; feederConfig.MaxGameTime = maxGameTime; feederConfig.MaxFoodDispensed = maxFoodDispensed; feederConfig.UniqueFoods = uniqueFoods; feederConfig.AverageUpdateFrequency = avgUpdateFreq; feederConfig.UpdateFreqVariance = updateFreqVariance; }
/// <summary> /// 获得下一个吸标位置 /// </summary> public override void CheckContinue() { if (this.GetNextSuck(ref this.MoveParam)) { this.Feeder = FeederDefine.Instance[this.machine.Module, this.MoveParam.Feeder]; base.CheckContinue(); } else { this.OnExit(); // 获取不到进行一个步骤 } }
private void tAdd_Click(object sender, EventArgs e) { string name = Interaction.InputBox("请输入新创建的Feeder配置名称", "新建Feeder配置", "Feeder"); if (name == string.Empty) { return; } else if (FeederDefine.Instance.FeederExit(Module, name)) { MessageBox.Show("创建的Feeder 信息已经存在,请重新命名!!!"); return; } FeederConfig config = new FeederConfig(); config.Module = Module; config.FeederName = name; this.feederInfo.FeederConfig = config; this.feederInfo.Visible = true; FeederDefine.Instance.SaveFeederConfig(config); this.ReloadFeederList(); }
/// <summary> /// 开始流程 /// </summary> public void Start() { if (FeederDefine.Instance.InstallFeederName[this.Module][Feeder.Right] == string.Empty && FeederDefine.Instance.InstallFeederName[this.Module][Feeder.Left] == string.Empty) { MessageBox.Show($"没有安装Feeder信息 请给该模组安装Feeder信息!!!"); return; } // 相机状态设置 for (Camera cam = Camera.Top; cam <= Camera.Bottom2; ++cam) { CameraDefine.Instance.Camera[this.Module][cam].StopGrab(); CameraDefine.Instance.Camera[this.Module][cam].StartGrab(); // 相机设置可采图 } for (Feeder feeder = Feeder.Left; feeder <= Feeder.Right; ++feeder) { FeederConfig left = null; if (FeederDefine.Instance.InstallFeederName[this.Module][feeder] != string.Empty) { string feederName = CommonHelper.GetEnumDescription(typeof(Feeder), feeder); left = FeederDefine.Instance[this.Module, feeder]; if (left == null) { MessageBox.Show($"找不到可{feederName} [{FeederDefine.Instance.InstallFeederName[this.Module][feeder]}] 请检查程式!!!"); return; } string loadrtn = VisionCalHelper.Instance.InstallVision(left.LabelName); if (!string.IsNullOrEmpty(loadrtn)) { MessageBox.Show($"{feederName} 视觉方法导入失败 [{left.LabelName}] 请检查视觉库!!!"); return; } } } // 安装视觉 string rtn = VisionCalHelper.Instance.InstallVision(this.Program.VisionList); if (rtn != string.Empty) { MessageBox.Show(rtn); return; } TrackManager.Instance.TrackStart((Config.Track) this.Module); if (CurStep == null) { CurStep = new SuckLabelStep(this, this.MachineEntiy); CurStep.CurState = FlowStep.State.Enter; this.RunData.Restet(this.Program); } else { CurStep.ReStart(); } if (FlowThd == null) { FlowThd = new Thread(Thread_Main); FlowThd.Start(); } this.MachineEntiy.MachineIO.StopBtnLight.SetIO(false); this.MachineEntiy.MachineIO.StartBtnLight.SetIO(true); this.Pasued = false; }
public void ShowFeederInfo(FeederConfig config) { this.FeederConfig = config.Clone() as FeederConfig; }