protected override object GetEditObject() { if (_facade == null) { _facade = new BaseModelFacadeFactory(base.DataProvider).Create(); } StepSequence stepSequence = this._facade.CreateNewStepSequence(); stepSequence.StepSequenceDescription = FormatHelper.CleanString(this.txtStepSequenceDescriptionEdit.Text, 100); stepSequence.StepSequenceCode = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtStepSequenceCodeEdit.Text, 40)); stepSequence.SegmentCode = this.drpSegmentCodeEdit.SelectedValue; stepSequence.MaintainUser = this.GetUserCode(); stepSequence.OrganizationID = int.Parse(this.DropDownListOrg.SelectedValue); stepSequence.BigStepSequenceCode = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.DropDownListBigStepSequenceCodeEdit.Text, 40)); stepSequence.StepSequenceOrder = int.Parse(this.txtBigStepSequenceSEQ.Text); stepSequence.ShiftTypeCode = this.drpShifTypeCode.SelectedValue; if (this.chbSaveIntoStock.Checked) { stepSequence.SaveInStock = "Y"; } else { stepSequence.SaveInStock = "N"; } return(stepSequence); }
public bool InitWithoutResAndOP(IDomainDataProvider dataProvider, string ssCode, DBDateTime dbDateTime) { bool returnValue = false; BaseModelFacade baseModelFacade = new BaseModelFacade(dataProvider); ShiftModelFacade shiftModelFacade = new ShiftModelFacade(dataProvider); _DataProvider = dataProvider; _DBDateTime = dbDateTime; //获取对应的SS _StepSequence = (StepSequence)baseModelFacade.GetStepSequence(ssCode); if (_StepSequence == null) { return(returnValue); } //获取当前的ShiftDate _ShiftDate = shiftModelFacade.GetShiftDayBySS(_StepSequence, _DBDateTime.DateTime); //获取当前的Shift _Shift = (Shift)shiftModelFacade.GetShift(_StepSequence.ShiftTypeCode, _DBDateTime.DBTime); if (_Shift == null) { return(returnValue); } returnValue = true; return(returnValue); }
protected override void UpdateDomainObject(object domainObject) { if (_facade == null) { _facade = new BaseModelFacadeFactory(base.DataProvider).Create(); } object OldObject = this._facade.GetStepSequence(this.DropDownListBigStepSequenceCodeEdit.Text.ToString(), int.Parse(this.txtBigStepSequenceSEQ.Text)); if (OldObject != null) { if (this.txtSave1.Text.Trim() != this.DropDownListBigStepSequenceCodeEdit.Text.Trim() || this.txtSave2.Text.Trim() != this.txtBigStepSequenceSEQ.Text.Trim()) { ExceptionManager.Raise(this.GetType().BaseType, "$Error_BigSSCodeSeqUsed"); } } this._facade.UpdateStepSequence((StepSequence)domainObject); StepSequence newStepSequence = (StepSequence)domainObject; //UpdateStepSequence中已经有Update下面所有RES的逻辑,此处不用再添加了 //object[] objStepSequence ={ }; //object[] objStepSequence = this._facade.GetResourceByStepSequenceCode(newStepSequence.StepSequenceCode); //for (int i = 0; i < objStepSequence.Length;i++ ) //{ // Resource newResource = (Resource)objStepSequence[i]; // newResource.ShiftTypeCode = this.drpShifTypeCode.SelectedValue; // this._facade.UpdateResource(newResource); //} }
public AaxcDownloadConverter(string outFileName, string cacheDirectory, DownloadLicense dlLic, OutputFormat outputFormat) { ArgumentValidator.EnsureNotNullOrWhiteSpace(outFileName, nameof(outFileName)); OutputFileName = outFileName; var outDir = Path.GetDirectoryName(OutputFileName); if (!Directory.Exists(outDir)) { throw new ArgumentNullException(nameof(outDir), "Directory does not exist"); } if (File.Exists(OutputFileName)) { File.Delete(OutputFileName); } if (!Directory.Exists(cacheDirectory)) { throw new ArgumentNullException(nameof(cacheDirectory), "Directory does not exist"); } cacheDir = cacheDirectory; downloadLicense = ArgumentValidator.EnsureNotNull(dlLic, nameof(dlLic)); OutputFormat = outputFormat; steps = new StepSequence { Name = "Download and Convert Aaxc To " + (outputFormat == OutputFormat.Mp4a ? "M4b" : "Mp3"), ["Step 1: Get Aaxc Metadata"] = Step1_GetMetadata, ["Step 2: Download Decrypted Audiobook"] = Step2_DownloadAndCombine, ["Step 3: Create Cue"] = Step3_CreateCue, ["Step 4: Create Nfo"] = Step4_CreateNfo, ["Step 5: Cleanup"] = Step5_Cleanup, }; }
private AaxToM4bConverter(string inputFile, string decryptKey) { ArgumentValidator.EnsureNotNullOrWhiteSpace(inputFile, nameof(inputFile)); if (!File.Exists(inputFile)) { throw new ArgumentNullException(nameof(inputFile), "File does not exist"); } steps = new StepSequence { Name = "Convert Aax To M4b", ["Step 1: Create Dir"] = Step1_CreateDir, ["Step 2: Decrypt Aax"] = Step2_DecryptAax, ["Step 3: Chapterize and tag"] = Step3_Chapterize, ["Step 4: Insert Cover Art"] = Step4_InsertCoverArt, ["Step 5: Cleanup"] = Step5_Cleanup, ["Step 6: Add Tags"] = Step6_AddTags, ["End: Create Cue"] = End_CreateCue, ["End: Create Nfo"] = End_CreateNfo }; inputFileName = inputFile; this.decryptKey = decryptKey; }
public UnencryptedAudiobookDownloader(string outFileName, string cacheDirectory, DownloadLicense dlLic) : base(outFileName, cacheDirectory, dlLic) { Steps = new StepSequence { Name = "Download Mp3 Audiobook", ["Step 1: Get Mp3 Metadata"] = Step_GetMetadata, ["Step 2: Download Audiobook"] = Step_DownloadAudiobookAsSingleFile, ["Step 3: Create Cue"] = Step_CreateCue, ["Step 4: Cleanup"] = Step_Cleanup, }; }
public AaxcDownloadSingleConverter(string outFileName, string cacheDirectory, DownloadLicense dlLic, OutputFormat outputFormat) : base(outFileName, cacheDirectory, dlLic, outputFormat) { Steps = new StepSequence { Name = "Download and Convert Aaxc To " + OutputFormat, ["Step 1: Get Aaxc Metadata"] = Step_GetMetadata, ["Step 2: Download Decrypted Audiobook"] = Step_DownloadAudiobookAsSingleFile, ["Step 3: Create Cue"] = Step_CreateCue, ["Step 4: Cleanup"] = Step_Cleanup, }; }
public AaxcDownloadMultiConverter(string outFileName, string cacheDirectory, DownloadLicense dlLic, OutputFormat outputFormat, Func <MultiConvertFileProperties, string> multipartFileNameCallback = null) : base(outFileName, cacheDirectory, dlLic, outputFormat) { Steps = new StepSequence { Name = "Download and Convert Aaxc To " + OutputFormat, ["Step 1: Get Aaxc Metadata"] = Step_GetMetadata, ["Step 2: Download Decrypted Audiobook"] = Step_DownloadAudiobookAsMultipleFilesPerChapter, ["Step 3: Cleanup"] = Step_Cleanup, }; this.multipartFileNameCallback = multipartFileNameCallback ?? MultiConvertFileProperties.DefaultMultipartFilename; }
// resolve the steps, broken into a separate method to aid inlining private DoubleArray resolveSteps(IList <SchedulePeriod> periods, RollConvention rollConv) { int size = periods.Count; double[] result = new double[size]; IList <ValueStep> resolvedSteps = StepSequence.map(seq => seq.resolve(steps, rollConv)).orElse(steps); // expand ValueStep to array of adjustments matching the periods // the steps are not sorted, so use fixed size array to absorb incoming data ValueAdjustment[] expandedSteps = new ValueAdjustment[size]; IList <ValueStep> invalidSteps = new List <ValueStep>(); foreach (ValueStep step in resolvedSteps) { int index = step.findIndex(periods); if (index < 0) { invalidSteps.Add(step); continue; } if (expandedSteps[index] != null && !expandedSteps[index].Equals(step.Value)) { throw new System.ArgumentException(Messages.format("Invalid ValueSchedule, two steps resolved to the same schedule period starting on {}, schedule defined as {}", periods[index].UnadjustedStartDate, this)); } expandedSteps[index] = step.Value; } // apply each adjustment double value = initialValue; for (int i = 0; i < size; i++) { if (expandedSteps[i] != null) { value = expandedSteps[i].adjust(value); } result[i] = value; } // ensure that invalid steps cause no changes foreach (ValueStep step in invalidSteps) { double baseValue = result[step.findPreviousIndex(periods)]; double adjusted = step.Value.adjust(baseValue); if (adjusted != baseValue) { throw new System.ArgumentException("ValueStep date does not match a period boundary: " + step.Date.get()); } } // return result return(DoubleArray.ofUnsafe(result)); }
public bool Init(IDomainDataProvider dataProvider, string resCode, DBDateTime dbDateTime) { bool returnValue = false; BaseModelFacade baseModelFacade = new BaseModelFacade(dataProvider); ShiftModelFacade shiftModelFacade = new ShiftModelFacade(dataProvider); _DataProvider = dataProvider; _ResCode = resCode; _DBDateTime = dbDateTime; //获取对应的OPCode Operation2Resource op2Res = (Operation2Resource)baseModelFacade.GetOperationByResource(_ResCode); if (op2Res != null) { _Operation = (Operation)baseModelFacade.GetOperation(op2Res.OPCode); } if (_Operation == null) { return(returnValue); } //获取对应的SS Resource res = (Resource)baseModelFacade.GetResource(_ResCode); if (res != null) { _StepSequence = (StepSequence)baseModelFacade.GetStepSequence(res.StepSequenceCode); } if (_StepSequence == null) { return(returnValue); } //获取当前的ShiftDate _ShiftDate = shiftModelFacade.GetShiftDayBySS(_StepSequence, _DBDateTime.DateTime); //获取当前的Shift _Shift = (Shift)shiftModelFacade.GetShift(_StepSequence.ShiftTypeCode, _DBDateTime.DBTime); if (_Shift == null) { return(returnValue); } returnValue = true; return(returnValue); }
public int GetShiftDayBySS(StepSequence stepSequence, DateTime currentDateTime) { int returnValue = FormatHelper.TODateInt(currentDateTime); if (stepSequence != null) { TimePeriod tp = (TimePeriod)GetTimePeriod(stepSequence.ShiftTypeCode, FormatHelper.TOTimeInt(currentDateTime)); if (tp != null) { returnValue = GetShiftDay(tp, currentDateTime); } } return(returnValue); }
public void TestStepSequence() { this.broker.Execute("delete from TBLSS where SSCODE='code'"); this.broker.Execute("delete from tblseg where segcode='code'"); Segment segment = facade.CreateNewSegment(); segment.SegmentCode = "code"; segment.SegmentSequence = 0; segment.SegmentDescription = ""; segment.ShiftTypeCode = "code"; segment.MaintainUser = "******"; facade.AddSegment(segment); string sql = "select count(*) from TBLSS where sscode='code'"; StepSequence obj = facade.CreateNewStepSequence(); obj.StepSequenceCode = "code"; obj.StepSequenceOrder = 0; obj.StepSequenceDescription = ""; obj.SegmentCode = "code"; obj.MaintainUser = "******"; facade.AddStepSequence(obj); DataSet ds = this.broker.Query(sql); Assert.AreEqual(System.Int32.Parse(ds.Tables[0].Rows[0][0].ToString()), 1); Assert.AreEqual(facade.QueryStepSequenceCount(obj.StepSequenceCode, "code"), 1); obj.StepSequenceDescription = "description"; facade.UpdateStepSequence(obj); StepSequence result = (StepSequence)facade.GetStepSequence("code"); Assert.AreEqual(result.StepSequenceDescription, "description"); Assert.IsTrue(facade.GetAllStepSequence().Length > 0); Assert.IsTrue(facade.QueryStepSequence("code", "code", 0, 20).Length > 0); Assert.IsTrue(facade.QueryStepSequenceCount("code", "code") > 0); facade.DeleteSegment(segment); // facade.DeleteStepSequence( obj ); // ds = this.broker.Query(sql); // Assert.AreEqual( System.Int32.Parse(ds.Tables[0].Rows[0][0].ToString()), 0); }
protected override void UpdateDomainObject(object domainObject) { if (_facade == null) { _facade = new BaseModelFacadeFactory(base.DataProvider).Create(); } this._facade.UpdateSegment((Segment)domainObject); Segment newSegment = (Segment)domainObject; object[] segquenceObj = this._facade.GetStepSequenceBySegmentCode(newSegment.SegmentCode); if (segquenceObj != null) { for (int i = 0; i < segquenceObj.Length; i++) { StepSequence newStepSequence = (StepSequence)segquenceObj[i]; if (newStepSequence.ShiftTypeCode == "") { newStepSequence.ShiftTypeCode = newSegment.ShiftTypeCode; this._facade.UpdateStepSequence(newStepSequence); } } } }
public Messages Execute(ActionEventArgs actionEventArgs) { Messages messages = new Messages(); DataCollectDebug dataCollectDebug = new DataCollectDebug(this.GetType().ToString() + "Collect"); dataCollectDebug.WhenFunctionIn(messages); try { ActionOnLineHelper dataCollect = new ActionOnLineHelper(this.DataProvider); //填写SIMULATION 检查工单、ID、途程、操作 // 联美兰达的下料不检查途程 //messages.AddMessages( dataCollect.CheckID(actionEventArgs)); if (messages.IsSuccess()) { // 联美兰达下料不更新Simulation //messages.AddMessages( dataCollect.Execute(actionEventArgs)); if (messages.IsSuccess()) { /* 由于界面上会自动调用GOOD采集,因此不用写报表 * //填写测试报表 * ReportHelper reportCollect= new ReportHelper(this.DataProvider); * messages.AddMessages(reportCollect.ReportLineQuanMaster(this.DataProvider,actionEventArgs.ActionType,actionEventArgs.ProductInfo)); * messages.AddMessages(reportCollect.ReportResQuanMaster(this.DataProvider,actionEventArgs.ActionType,actionEventArgs.ProductInfo)); */ //Laws Lu,2005/10/20,新增 使用配置文件来控制物料模块是否使用 if (System.Configuration.ConfigurationSettings.AppSettings["NeedMaterialModule"].Trim() == "1") { BenQGuru.eMES.Material.CastDownHelper castHelper = new BenQGuru.eMES.Material.CastDownHelper(DataProvider); ArrayList arRcard = new ArrayList(); castHelper.GetAllRCardByMo(ref arRcard, actionEventArgs.ProductInfo.NowSimulation.RunningCard, actionEventArgs.ProductInfo.NowSimulation.MOCode); if (arRcard.Count == 0) { arRcard.Add(actionEventArgs.RunningCard); } string runningCards = "('" + String.Join("','", (string[])arRcard.ToArray(typeof(string))) + "')"; object[] objs = (actionEventArgs as DropMaterialEventArgs).OnwipItems; //下料并归还库房 BenQGuru.eMES.Material.WarehouseFacade wfacade = new BenQGuru.eMES.Material.WarehouseFacade(this.DataProvider); wfacade.RemoveWarehouse( objs , runningCards , actionEventArgs.ProductInfo.NowSimulation.MOCode , actionEventArgs.UserCode , actionEventArgs.ProductInfo.NowSimulationReport.StepSequenceCode , actionEventArgs.ProductInfo.NowSimulation.OPCode); } else // Added by Icyer 2006/11/16 { DropMaterialEventArgs arg = (DropMaterialEventArgs)actionEventArgs; if (arg.OnwipItems != null) { // 查询需要管控的KeyPart ArrayList listKeyPart = new ArrayList(); ArrayList listAllKeyPart = new ArrayList(); //ArrayList partsToUnload = new ArrayList(); //ArrayList partsToReplace = new ArrayList(); //for (int i = 0; i < arg.OnwipItems.Length; i++) //{ // BenQGuru.eMES.Material.InnoObject io = (BenQGuru.eMES.Material.InnoObject)arg.OnwipItems[i]; // if (io.NewBarcode.Trim().Length > 0) // partsToReplace.Add(io); // else // partsToUnload.Add(io); //} string sql = string.Empty; CastDownHelper castDownHelper = new CastDownHelper(DataProvider); BaseModelFacade baseModelFacade = new BaseModelFacade(this.DataProvider); DataCollectFacade dataCollectFacade = new DataCollectFacade(this.DataProvider); ShiftModelFacade shiftModelFacade = new ShiftModelFacade(this.DataProvider); DBDateTime dbDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider); foreach (InnoObject io in arg.OnwipItems) { //获取arRcard ArrayList arRcard = new ArrayList(); castDownHelper.GetAllRCard(ref arRcard, actionEventArgs.ProductInfo.NowSimulation.RunningCard); if (arRcard.Count == 0) { arRcard.Add(actionEventArgs.RunningCard); } //获取dropop Operation2Resource objOP = baseModelFacade.GetOperationByResource(arg.ResourceCode); string dropop = string.Empty; if (objOP != null) { dropop = objOP.OPCode; } #region 针对旧料所作的动作 string runningCards = "('" + String.Join("','", (string[])arRcard.ToArray(typeof(string))) + "')"; sql = string.Format("update TBLONWIPITEM set TRANSSTATUS='{0}',ActionType=" + (int)MaterialType.DropMaterial + ",DropOP = '" + dropop + "'" + ",DropUser='******'" + ",DropDate=" + dbDateTime.DBDate + ",DropTime=" + dbDateTime.DBTime + " where RCARD in {1} and ActionType='{2}'" + " and MCARD in ('" + io.MCard.Trim().ToUpper() + "')" , TransactionStatus.TransactionStatus_YES , runningCards , (int)Web.Helper.MaterialType.CollectMaterial); this.DataProvider.CustomExecute(new SQLCondition(sql)); if (io.MCardType == MCardType.MCardType_Keyparts) { sql = "update TBLSIMULATIONREPORT set IsLoadedPart='0',LoadedRCard='' " + " where RCARD in ('" + io.MCard.Trim().ToUpper() + "')"; this.DataProvider.CustomExecute(new SQLCondition(sql)); sql = "update TBLITEMLOTDETAIL set SERIALSTATUS='STORAGE' " + " where SERIALNO in ('" + io.MCard.Trim().ToUpper() + "')"; this.DataProvider.CustomExecute(new SQLCondition(sql)); } #endregion #region 针对新料所做的动作 if (io.NewBarcode.Trim().Length > 0) { object[] oldOnWIPItemList = dataCollectFacade.QueryOnWIPItem(io.MCard, runningCards, ((int)Web.Helper.MaterialType.DropMaterial).ToString()); if (oldOnWIPItemList != null && oldOnWIPItemList.Length > 0) { OnWIPItem oldOnWIPItem = (OnWIPItem)oldOnWIPItemList[0]; OnWIPItem newOnWIPItem = dataCollectFacade.CreateNewOnWIPItem(); newOnWIPItem.RunningCard = oldOnWIPItem.RunningCard; newOnWIPItem.MSequence = oldOnWIPItem.MSequence; newOnWIPItem.MOCode = oldOnWIPItem.MOCode; newOnWIPItem.ModelCode = oldOnWIPItem.ModelCode; newOnWIPItem.ItemCode = oldOnWIPItem.ItemCode; newOnWIPItem.MItemCode = oldOnWIPItem.MItemCode; newOnWIPItem.MCardType = oldOnWIPItem.MCardType; newOnWIPItem.Qty = oldOnWIPItem.Qty; newOnWIPItem.RouteCode = oldOnWIPItem.RouteCode; newOnWIPItem.OPCode = oldOnWIPItem.OPCode; newOnWIPItem.ResourceCode = oldOnWIPItem.ResourceCode; newOnWIPItem.SegmentCode = oldOnWIPItem.SegmentCode; newOnWIPItem.StepSequenceCode = oldOnWIPItem.StepSequenceCode; newOnWIPItem.EAttribute1 = oldOnWIPItem.EAttribute1; newOnWIPItem.MOSeq = oldOnWIPItem.MOSeq; newOnWIPItem.MCARD = io.NewBarcode; newOnWIPItem.LotNO = io.NewLotNo; newOnWIPItem.PCBA = io.NewPCBA; newOnWIPItem.BIOS = io.NewBIOS; newOnWIPItem.Version = io.NewVersion; newOnWIPItem.VendorItemCode = io.NewVendorItemCode; newOnWIPItem.VendorCode = io.NewVendorCode; newOnWIPItem.DateCode = io.NewDateCode; newOnWIPItem.TransactionStatus = TransactionStatus.TransactionStatus_NO; newOnWIPItem.ActionType = (int)Web.Helper.MaterialType.CollectMaterial; newOnWIPItem.MaintainUser = actionEventArgs.UserCode; newOnWIPItem.MaintainDate = dbDateTime.DBDate; newOnWIPItem.MaintainTime = dbDateTime.DBTime; //RunningCardSequence取当前RCard的最小再减一 newOnWIPItem.RunningCardSequence = dataCollectFacade.GetMinRCardSequenceFromOnWipItem(runningCards); //重新抓取ShiftTypeCode、ShiftCode、TimePeriodCode StepSequence stepSequence = (StepSequence)baseModelFacade.GetStepSequence(newOnWIPItem.StepSequenceCode); if (stepSequence == null) { newOnWIPItem.ShiftTypeCode = stepSequence.ShiftTypeCode; } else { newOnWIPItem.ShiftTypeCode = oldOnWIPItem.ShiftTypeCode; } TimePeriod timePeriod = (TimePeriod)shiftModelFacade.GetTimePeriod(newOnWIPItem.ShiftTypeCode, dbDateTime.DBTime); if (timePeriod != null) { newOnWIPItem.TimePeriodCode = timePeriod.TimePeriodCode; newOnWIPItem.ShiftCode = timePeriod.ShiftCode; } dataCollectFacade.AddOnWIPItem(newOnWIPItem); } if (io.MCardType == MCardType.MCardType_Keyparts) { sql = "update TBLSIMULATIONREPORT set IsLoadedPart='1',LoadedRCard='" + String.Join(",", (string[])arRcard.ToArray(typeof(string))) + "' " + " where RCARD in ('" + io.NewBarcode.Trim().ToUpper() + "')"; this.DataProvider.CustomExecute(new SQLCondition(sql)); sql = "update TBLITEMLOTDETAIL set SERIALSTATUS='UNSTORAGE' " + " where SERIALNO in ('" + io.NewBarcode.Trim().ToUpper() + "')"; this.DataProvider.CustomExecute(new SQLCondition(sql)); } // Added By Hi1/Venus.feng on 20081114 for Hisense Version : Add Remove Pallet and Carton // 拆箱和拆Pallet DataCollectFacade dcf = new DataCollectFacade(this.DataProvider); if (messages.IsSuccess()) { messages.AddMessages(dcf.RemoveFromPallet(io.NewBarcode.Trim().ToUpper(), actionEventArgs.UserCode, true)); if (messages.IsSuccess()) { messages.ClearMessages(); } } if (messages.IsSuccess()) { messages.AddMessages(dcf.RemoveFromCarton(io.NewBarcode.Trim().ToUpper(), actionEventArgs.UserCode)); if (messages.IsSuccess()) { messages.ClearMessages(); } } // End Added } #endregion } } } } } } catch (Exception e) { messages.Add(new Message(e)); } dataCollectDebug.WhenFunctionOut(messages); return(messages); }
protected override void DoSolve() { RuleOutcome outcome; GameState actualGameState = Coordinator.CurrentGameState.Clone(); Position initialPosition = actualGameState.YourOriginalCell.Position; int initialY = initialPosition.Y; int initialX = initialPosition.X; int equatorY; int distance; bool flipY = false; if (initialY > 14) { equatorY = 15; flipY = true; distance = initialY - equatorY; } else { equatorY = 14; flipY = false; distance = equatorY - initialY; } /* Original... * Step<PendulumState> program = new StepSequence<PendulumState> { * FlipX = FlipSetting.No, * FlipY = (flipY ? FlipSetting.Yes : FlipSetting.No), * Steps = new Step<PendulumState>[] { * new MoveInALine<PendulumState> { * Name = "MoveToEquator", * Direction = Direction.Down, * Distance = distance, * AfterStep = InitializePendulumState * }, * new RepeatWithIncreasingLevels<PendulumState> { * Name = "Pendulum", * GetInitialLevel = previousLevel => 1, * GetFinalLevel = previousLevel => (Constants.Rows - 2)/4, // Lower hemisphere => divide by 2; go down 2 blocks per turn => divide by 2 again * Steps = new Step<PendulumState>[] { * new MoveInALine<PendulumState>{ Name = "1_L", Direction = Direction.Left, GetDistanceFromLevel = level => level }, // N left * new MoveInALine<PendulumState>{ Name = "2_U", Direction = Direction.Up, GetDistanceFromLevel = level => 2 * level - 1}, // Nth odd number up * new MoveInALine<PendulumState>{ Name = "3_L", Direction = Direction.Left, Distance = 1}, // 1 left * new MoveInALine<PendulumState>{ Name = "4_D", Direction = Direction.Down, GetDistanceFromLevel = level => 2 * level}, // Nth odd number +1 down * new MoveInALine<PendulumState>{ Name = "5_R", Direction = Direction.Right, GetDistanceFromLevel = level => level + 2}, // N+2 right - split into N+1 right, then evaluate whether to backtrack or expand right * new MoveInALine<PendulumState>{ Name = "6_U", Direction = Direction.Up, GetDistanceFromLevel = level => level + 1}, // N+1 up * new MoveInALine<PendulumState>{ Name = "7_R", Direction = Direction.Right, Distance = 1}, // 1 right * new MoveInALine<PendulumState>{ Name = "8_D", Direction = Direction.Down, GetDistanceFromLevel = level => level + 2}, // N+2 down * new MoveInALine<PendulumState>{ Name = "9_L", Direction = Direction.Left, GetDistanceFromLevel = level => level + 2} // Move back under the vertical line * } * } * } * }; */ Step <PendulumState> program = new StepSequence <PendulumState> { FlipX = FlipSetting.No, FlipY = (flipY ? FlipSetting.Yes : FlipSetting.No), Steps = new Step <PendulumState>[] { new MoveInALine <PendulumState> { Name = "MoveToEquator", Direction = Direction.Down, Distance = distance, AfterStep = InitializePendulumState }, new StepSequence <PendulumState> { Name = "Pendulum", Repeat = true, Steps = new Step <PendulumState>[] { new MoveToAPoint <PendulumState> { Name = "1_L", GetPosition = GetFirstPosition, AfterEachMove = AfterFirstPosition }, // N left new MoveInALine <PendulumState> { Name = "2_U", Direction = Direction.Up, GetDistanceFromLevel = level => 2 * level - 1 }, // Nth odd number up new MoveInALine <PendulumState> { Name = "3_L", Direction = Direction.Left, Distance = 1 }, // 1 left new MoveInALine <PendulumState> { Name = "4_D", Direction = Direction.Down, GetDistanceFromLevel = level => 2 * level }, // Nth odd number +1 down new MoveInALine <PendulumState> { Name = "5_R", Direction = Direction.Right, GetDistanceFromLevel = level => level + 2 }, // N+2 right - split into N+1 right, then evaluate whether to backtrack or expand right new MoveInALine <PendulumState> { Name = "6_U", Direction = Direction.Up, GetDistanceFromLevel = level => level + 1 }, // N+1 up new MoveInALine <PendulumState> { Name = "7_R", Direction = Direction.Right, Distance = 1 }, // 1 right new MoveInALine <PendulumState> { Name = "8_D", Direction = Direction.Down, GetDistanceFromLevel = level => level + 2 }, // N+2 down new MoveInALine <PendulumState> { Name = "9_L", Direction = Direction.Left, GetDistanceFromLevel = level => level + 2 } // Move back under the vertical line } } } }; outcome = program.RunRulesEngine(actualGameState); if (outcome.Status == RuleStatus.NextMoveSuggested) { actualGameState.MakeMove(outcome.SuggestedMove); Coordinator.SetBestMoveSoFar(actualGameState); } else { NegaMaxSolver solver = new NegaMaxSolver(); DelegateSolvingToAnotherSolver(solver); } }
//保存老化信息 private void SaveBurnWip() { DataCollectFacade dataCollectFacade = new DataCollectFacade(this.DataProvider); BaseModelFacade baseModelFacade = new BaseModelFacade(this.DataProvider); ShiftModelFacade shiftModelFacade = new ShiftModelFacade(this.DataProvider); DBDateTime dbDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider); ItemFacade itemFacade = new ItemFacade(this.DataProvider); BurnFacade burnFacade = new BurnFacade(this.DataProvider); //获取时段代码 StepSequence _StepSequence = (StepSequence)baseModelFacade.GetStepSequence(Resource.StepSequenceCode); TimePeriod tp = (TimePeriod)shiftModelFacade.GetTimePeriod(Resource.ShiftTypeCode, dbDateTime.DBTime); BurnWip burnWip = new BurnWip(); string sourceRCard = dataCollectFacade.GetSourceCard(this.txtRunningCard.Value.Trim().ToUpper(), string.Empty); burnWip.RunningCard = sourceRCard; burnWip.MOCode = product.LastSimulation.MOCode; burnWip.ItemCode = this.txtItem.Value; burnWip.SsCode = Resource.StepSequenceCode; burnWip.ResCode = Resource.ResourceCode; if (tp != null) { burnWip.TpCode = tp.TimePeriodCode; burnWip.ShiftDay = shiftModelFacade.GetShiftDay(tp, dbDateTime.DateTime); } burnWip.ProductStatus = ProductStatus.GOOD; if (rdoBurnIn.Checked) { burnWip.Status = BurnType.BurnIn; burnWip.BurnInDate = dbDateTime.DBDate; burnWip.BurnInTime = dbDateTime.DBTime; object objItem = itemFacade.GetItem(this.txtItem.Value, GlobalVariables.CurrentOrganizations.First().OrganizationID); if (objItem != null && ((Item)objItem).BurnUseMinutes.ToString() != "") { burnWip.ForecastOutDate = FormatHelper.TODateInt(dbDateTime.DateTime.AddMinutes(((Item)objItem).BurnUseMinutes)); burnWip.ForecastOutTime = FormatHelper.TOTimeInt(dbDateTime.DateTime.AddMinutes(((Item)objItem).BurnUseMinutes)); } } else { burnWip.Status = BurnType.BurnOut; burnWip.BurnOutDate = dbDateTime.DBDate; burnWip.BurnOutTime = dbDateTime.DBTime; if (rdoNG.Checked) { burnWip.ProductStatus = ProductStatus.NG; } } burnWip.MaintainUser = userCode; burnWip.MaintainDate = dbDateTime.DBDate; burnWip.MaintainTime = dbDateTime.DBTime; object objBurn = burnFacade.GetBurnWip(burnWip.RunningCard, burnWip.MOCode); if (objBurn == null) { burnFacade.AddBurnWip(burnWip); } else { if (((BurnWip)objBurn).Status == BurnType.BurnOut && rdoBurnOut.Checked) //返工或维修回流时,若没有走burn in工序,则预计完成时间更新为系统时间 { burnWip.BurnInDate = dbDateTime.DBDate; burnWip.BurnInTime = dbDateTime.DBTime; burnWip.ForecastOutDate = dbDateTime.DBDate; burnWip.ForecastOutTime = dbDateTime.DBTime; } else { burnWip.BurnInDate = ((BurnWip)objBurn).BurnInDate; burnWip.BurnInTime = ((BurnWip)objBurn).BurnInTime; burnWip.ForecastOutDate = ((BurnWip)objBurn).ForecastOutDate; burnWip.ForecastOutTime = ((BurnWip)objBurn).ForecastOutTime; } burnFacade.UpdateBurnWip(burnWip); } }