private void MakeProcess()
        {
            FAExtendECPart.ECResult ecResult = new FAExtendECPart.ECResult();

            var seq = Process;

            seq.OnStart +=
                delegate
                {
                    RetryBarcodeScan.ClearCount();
                    RetryBarcodeDecoding.ClearCount();
                };

            seq.Steps.Add("ConfirmScanCompleted", new StepInfo());
            seq.Steps.Add("ConfirmLotChange", new StepInfo());
            seq.Steps.Add("PreStopperDown", new StepInfo());
            seq.Steps.Add("RetryScan", new StepInfo());

            seq.AddItem(
                delegate(object obj)
                {
                    SSDBoxInletUnit.ConveyorMotor.Run.Execute(this);
                    ProductInfo.VT5070ProductInfo.LastProductInfoInstance.TrackOutCompleted = false;
                });
            seq.Steps["ConfirmScanCompleted"].StepIndex = seq.AddItem(
                delegate(FASequence actor, TimeSpan time)
                {
                    if (Equipment.RunMode == FAFramework.Equipment.RunModeTypes.DRY_RUN)
                        actor.NextStep();
                    else if (string.IsNullOrEmpty(SSDBoxInletUnit.Scanner.Barcode.Barcode) == false)
                    {
                        SSDBoxInletUnit.Scanner.TriggerOff(actor);
                        ProductInfo.VT5070ProductInfo.TurnkeyBoxBarcode = SSDBoxInletUnit.Scanner.Barcode.Barcode;
                        WriteTraceLog(string.Format("T/K Box Scan Success : {0}", ProductInfo.VT5070ProductInfo.TurnkeyBoxBarcode));
                        actor.NextStep();
                    }
                    else if (TimeBarcodeScanTimeout.Time < time)
                    {
                        if (RetryBarcodeScan.IncreaseCount() == false)
                            RaiseAlarm(actor, AlarmBarcodeScanFail);

                        actor.NextStep("RetryScan");
                    }
                });
            seq.AddItem(
                delegate(FASequence actor, TimeSpan time)
                {
                    if (Equipment.RunMode == FAFramework.Equipment.RunModeTypes.HOT_RUN)
                        actor.NextStep();
                    else
                    {
                        actor.NextStep("ConfirmLotChange");
                    }
                });
            seq.AddItem(
                delegate(object obj)
                {
                    FAECInfo.PACKING_MASTER_INFO_REQ command = new FAECInfo.PACKING_MASTER_INFO_REQ();
                    command.SERIAL = ProductInfo.VT5070ProductInfo.TurnkeyBoxBarcode;
                    ecResult.Clear();
                    InterfaceUnit.ECPart.AddCommand(command, ecResult);
                });
            seq.AddItem(
                delegate(FASequence actor, TimeSpan time)
                {
                    if (ecResult.ReceiveOk)
                    {
                        if (ecResult.ParsingSuccess)
                        {
                            if (ecResult.ECInfo.PackingMasterInfo.RESULT == FAECInfo.FAECResult.PASS)
                            {
                                ecResult.ECInfo.PackingMasterInfo.CopyTo(ProductInfo.ECInfo.PackingMasterInfo);
                                actor.NextStep();
                            }
                            else
                            {
                                RaiseAlarm(actor, ecResult.LastAlarmNo,
                                    string.Format("EC MSG : {0}\nFail Message : {1}",
                                        ecResult.ECInfo.PackingMasterInfo.MSG,
                                        ecResult.ParsingFailMessage));
                                actor.NextStep("RetryScan");
                            }
                        }
                        else
                        {
                            RaiseAlarm(actor, ecResult.LastAlarmNo,
                                    string.Format("EC MSG : {0}\nFail Message : {1}",
                                        ecResult.ECInfo.PackingMasterInfo.MSG,
                                        ecResult.ParsingFailMessage));
                            actor.NextStep("RetryScan");
                        }
                    }
                    else if (ecResult.LastAlarmNo != 0)
                    {
                        RaiseAlarm(actor, ecResult.LastAlarmNo,
                                    string.Format("EC MSG : {0}\nFail Message : {1}",
                                        ecResult.ECInfo.PackingMasterInfo.MSG,
                                        ecResult.ParsingFailMessage));
                        actor.NextStep("RetryScan");
                    }
                });
            seq.Steps["ConfirmLotChange"].StepIndex = seq.AddItem(
                delegate(FASequence actor, TimeSpan time)
                {
                    bool changedLot = false;
                    bool duplicateSerial = false;
                    bool differentLot = false;

                    if (AddLoadingCount(ProductInfo.ECInfo.PackingMasterInfo,
                        ProductInfo.VT5070ProductInfo.TurnkeyBoxBarcode,
                        out changedLot,
                        out differentLot,
                        out duplicateSerial) == true)
                    {
                        if (changedLot)
                        {
                            CurrentLastProductInfo = new VT5070ProductInfo.LastProductInfo();
                            FARobotControlModule.RobotWork work = new FARobotControlModule.RobotWork();
                            RobotControlModule.AddWork(ProductInfo.ECInfo.PackingMasterInfo, ProductInfo);
                            Equipment.ProductOutput.TrackInLot(DateTime.Now, ProductInfo.ECInfo.PackingMasterInfo.LOT_ID);
                            WriteTraceLog(string.Format("TRACK IN LOT : {0}", ProductInfo.ECInfo.PackingMasterInfo.LOT_ID));
                        }

                        ProductInfo.VT5070ProductInfo.LastProductInfoInstance = CurrentLastProductInfo;
                        Equipment.ProductOutput.AddProduct(DateTime.Now, ProductInfo.ECInfo.PackingMasterInfo.LOT_ID);
                        WriteTraceLog(string.Format("Add T/K Box : {0}", ProductInfo.VT5070ProductInfo.TurnkeyBoxBarcode));
                        actor.NextStep();
                    }
                    else
                    {
                        if (differentLot)
                            RaiseAlarm(actor, AlarmDifferentLotInput);
                        else if (duplicateSerial)
                        {
                            if (RetryBarcodeDecoding.IncreaseCount() == false)
                                RaiseAlarm(actor, AlarmDuplicationSerialInput);
                        }

                        actor.NextStep("RetryScan");
                    }
                });
            seq.Steps["PreStopperDown"].StepIndex =
                seq.AddItem(
                delegate(FASequence actor, TimeSpan time)
                {
                    if (SelectedStackerNo == StackerNo.Stacker2)
                    {
                        if (SSDStackerModule1.SafetyForMoving)
                            actor.NextStep();
                    }
                    else
                        actor.NextStep();
                });
            seq.AddTerminate();

            seq.Steps["RetryScan"].StepIndex = seq.AddItem(SSDBoxInletUnit.Scanner.TriggerOff);
            seq.AddItem(new FATime(FATimeType.millisecond, 300));
            seq.AddItem((object obj) => SSDBoxInletUnit.Scanner.Barcode.Clear());
            seq.AddItem(SSDBoxInletUnit.Scanner.TriggerOn);
            seq.AddItem("ConfirmScanCompleted");
        }
 private void buttonSend_Click(object sender, RoutedEventArgs e)
 {
     FAExtendECPart.ECResult result = new FAExtendECPart.ECResult();
     Part.AddCommand(Command, result);
 }
        private void MakeLoading()
        {
            FAExtendECPart.ECResult ecResult = new FAExtendECPart.ECResult();
            bool notWantConveyorRun = false;

            var seq = Loading;

            seq.Steps.Add("Start", new StepInfo());
            seq.Steps.Add("ReceiveData", new StepInfo());
            seq.Steps.Add("MoveGuideToGuidePosition", new StepInfo());
            seq.Steps.Add("RequestPackingMasterInfo", new StepInfo());

            seq.AddWatcher(
                delegate
                {
                    if (seq.State == SequenceState.Running)
                    {
                        if (notWantConveyorRun && Unloading.IsStartable())
                            LoadingUnit.ConveyorMotor.Stop.Execute(this);
                    }
                });

            seq.OnStart +=
                delegate
                {
                    notWantConveyorRun = false;
                };

            seq.OnSuspended +=
                delegate
                {
                    if (Unloading.IsStartable() || Unloading.State == SequenceState.Suspended)
                    {
                        LoadingUnit.ConveyorMotor.Stop.Execute(this);
                    }
                };
            seq.OnStop += delegate { LoadingUnit.ConveyorMotor.Stop.Execute(this); };
            seq.OnTerminate +=
                delegate
                {
                    if (Unloading.IsStartable() || Unloading.State == SequenceState.Suspended)
                        LoadingUnit.ConveyorMotor.Stop.Execute(this);

                    ProductInfo.ExistProduct = true;
                };

            seq.AddItem(
                delegate(object obj)
                {
                    notWantConveyorRun = true;
                    WriteTraceLog("CurrentLotInputCount=" + CurrentLotInputCount.ToString());

                    if (CurrentLotInputCount >= CurrentLotInfo.LOT_QTY)
                    {
                        InterfaceUnit.AMTInterfaceRequstCheck.Off.Execute(this);
                        InterfaceUnit.AMTInterFaceTransferCheck.Off.Execute(this);
                        WriteTraceLog("LOADING LOT CHANGED");
                        CurrentLotInfo.Clear();
                        CurrentLotInputCount = 0;
                    }
                });
            seq.AddItem(
                delegate(FASequence actor, TimeSpan time)
                {
                    if (CurrentLotInputCount == 0)
                    {
                        Tact = TimeSpan.Zero;
                        actor.NextStep();
                    }
                    else
                        actor.NextStep("MoveGuideToGuidePosition");
                });
            seq.AddItem(
                delegate(FASequence actor, TimeSpan time)
                {
                    ProductInfo.ECInfo.PackingMasterInfo.LOT_ID = "TEST";
                    ProductInfo.ECInfo.PackingMasterInfo.PART_ID = "TEST";
                    ProductInfo.ECInfo.PackingMasterInfo.S_BOX_MOQ = 10;
                    ProductInfo.ECInfo.PackingMasterInfo.LOT_QTY = 30;
                    ProductInfo.ECInfo.PackingMasterInfo.L_BOX_MOQ = 6;

                    if (Equipment.RunMode == FAFramework.Equipment.RunModeTypes.DRY_RUN ||
                        Equipment.RunMode == FAFramework.Equipment.RunModeTypes.COLD_RUN)
                    {
                        LoadingUnit.Stopper.Up.Execute(actor);
                        actor.NextStep("MoveGuideToGuidePosition");
                    }
                    else if (ManualMode)
                    {
                        if (CurrentLotInputCount == 0)
                        {
                            ProductInfo.ECInfo.PackingMasterInfo.CopyTo(CurrentLotInfo);
                        }

                        actor.NextStep("MoveGuideToGuidePosition");
                    }
                    else
                    {
                        actor.NextStep();
                    }
                });
            seq.Steps["ReceiveData"].StepIndex = seq.AddItem(
                delegate(FASequence actor, TimeSpan time)
                {
                    if (ReceivedDataFromAMT.ReceivedData == true)
                    {
                        if (ReceivedDataFromAMT.Error)
                        {
                            RaiseAlarm(actor, AlarmFrontMachineDataError);
                        }
                        else
                        {
                            Equipment.RequestStart();
                            ProductInfo.ECInfo.PackingMasterInfo.LOT_ID = ReceivedDataFromAMT.InterfaceInfo.ReceiveData.LotID;
                            ReceivedDataFromAMT.ReceivedData = false;
                            actor.NextStep();
                        }
                    }
                });
            seq.AddItem(
                delegate(FASequence actor, TimeSpan time)
                {
                    if (CurrentLotInputCount == 0)
                        actor.NextStep();
                    else
                        actor.NextStep("Start");
                });
            seq.Steps["RequestPackingMasterInfo"].StepIndex = seq.AddItem(
                delegate(object obj)
                {
                    FAECInfo.PACKING_MASTER_INFO_REQ command = new FAECInfo.PACKING_MASTER_INFO_REQ();
                    command.LOT_ID = ProductInfo.ECInfo.PackingMasterInfo.LOT_ID;
                    ecResult.Clear();
                    InterfaceUnit.ECPart.AddCommand(command, ecResult);

                });
            seq.AddItem(
                delegate(FASequence actor, TimeSpan time)
                {
                    if (ecResult.ReceiveOk)
                    {
                        if (ecResult.ParsingSuccess)
                        {
                            if (ecResult.ECInfo.PackingMasterInfo.RESULT == FAECInfo.FAECResult.PASS)
                            {
                                ecResult.ECInfo.PackingMasterInfo.CopyTo(ProductInfo.ECInfo.PackingMasterInfo);
                                ProductInfo.ECInfo.PackingMasterInfo.CopyTo(CurrentLotInfo);
                                actor.NextStep();
                            }
                            else
                            {
                                RaiseAlarm(actor, ecResult.LastAlarmNo);
                                actor.NextStep("RequestPackingMasterInfo");
                            }
                        }
                        else
                        {
                            RaiseAlarm(actor, ecResult.LastAlarmNo);
                            actor.NextStep("RequestPackingMasterInfo");
                        }
                    }
                    else if (ecResult.LastAlarmNo != 0)
                    {
                        RaiseAlarm(actor, ecResult.LastAlarmNo);
                        actor.NextStep("RequestPackingMasterInfo");
                    }
                });
            seq.Steps["MoveGuideToGuidePosition"].StepIndex = seq.AddItem(MoveGuideToGuidePosition);

            seq.Steps["Start"].StepIndex =
                seq.AddItem(
                    delegate(FASequence actor, TimeSpan time)
                    {
                        if (LoadingReady)
                        {
                            actor.NextStep();
                        }
                    });
            seq.AddItem(LoadingUnit.Stopper.Down.Sequence);
            seq.AddItem(
                delegate(object obj)
                {
                    InterfaceUnit.AMTInterfaceRequstCheck.Off.Execute(this);
                    InterfaceUnit.AMTInterFaceTransferCheck.Off.Execute(this);
                });
            seq.AddItem(
                    delegate(FASequence actor, TimeSpan time)
                    {
                        if (InterfaceUnit.AMTInterfaceReadySignal.IsOff &&
                            InterfaceUnit.AMTInterfaceTransferSignal.IsOff)
                        {
                            actor.NextStep();
                        }
                    });
            seq.AddItem(
                delegate(FASequence actor, TimeSpan time)
                {
                    if (ManualMode)
                        actor.NextStep();
                    else
                    {
                        InterfaceUnit.AMTInterfaceRequstCheck.On.Execute(actor);

                        if (InterfaceUnit.AMTInterfaceReadySignal.IsOn)
                        {
                            actor.NextStep();
                        }
                    }
                });
            seq.AddItem((object obj) => notWantConveyorRun = false);
            seq.AddItem(new FASequenceAtomicInfo(LoadingBox, true));
            seq.AddItem(
                    delegate(FASequence actor, TimeSpan time)
                    {
                        if (Unloading.IsStartable())
                        {
                            actor.NextStep();
                        }
                    });
            seq.AddItem(LoadingUnit.Stopper.Up.Sequence);
            seq.AddItem(
                delegate(object obj)
                {
                    Equipment.RequestStart();
                    CurrentLotInfo.CopyTo(ProductInfo.ECInfo.PackingMasterInfo);
                    CurrentLotInputCount++;
                });
        }