public bool makeAndRequestAction(c_Action cRequestAction, bool bFirstActionInAutoMode)
        {
            bool bret = false;

            if (IsActionFree() || bFirstActionInAutoMode)
            {
                {
                    cRequestAction.m_sActionID = RandomString(6);
                } while (cRequestAction.m_sActionID == m_cCurrentAction.m_sActionID) // Falls zufällig eine gleiche ID erstellt wurde erneut durchführen

                {
                    m_cLastAction = m_cCurrentAction;
                }


                m_cCurrentAction = cRequestAction;
            }
            else
            {
                return(false);
            }


            // Senden der Aktion an PLC
            string sJSon;

            sJSon = JsonConvert.SerializeObject(m_cCurrentAction);
            bret  = m_cAdsWriteInterface.writeToPLCString("MAIN.sJsonDocAction", sJSon);
            m_cCurrentAction.m_iActionState = 1;
            m_cFabric.updateActionString(); // Message
            return(bret);
        }
        public c_ActionHandler(c_Fabric cFabric)
        {
            m_cFabric = cFabric;

            m_cCurrentAction = new c_Action();
            m_cLastAction    = new c_Action();

            m_cAdsWriteInterface = new ADSWriteInterface();
            ADSReadJSon          = new ADSReadInterface("MAIN.sJsonDocLastAction");
            ADSReadJSon.Registrate((c_Base_ADSReadInterface)this);
        }
        public override void Update(string sJSon)
        {
            c_Action cPlcAction = new c_Action();

            cPlcAction = JsonConvert.DeserializeObject <c_Action>(sJSon);
            if (m_cCurrentAction.m_sActionID == cPlcAction.m_sActionID)
            {
                m_cCurrentAction.m_iActionState = cPlcAction.m_iActionState;
            }


            m_cFabric.update();
        }
Beispiel #4
0
        private void EndOfAction()  // Hier AKtionen die nach der Ausführung einer Aktion Notwendig sind zb. GUI Update etc.
        {
            c_Action cCurrentAction = m_cAktionHandler.GetCurrentAction();
            c_Action cLastAction    = m_cAktionHandler.GetLastAction();

            if (cCurrentAction == null || m_bFirstActionInAutoMode)
            {
                if (m_bFirstActionInAutoMode)
                {
                    AutoActionUpdate();
                    if (!m_cWorkingScheduleHandler.IsEmpty())
                    {
                        m_cAktionHandler.makeAndRequestAction(m_cWorkingScheduleHandler.PopNexAction(), m_bFirstActionInAutoMode);
                        m_bFirstActionInAutoMode = false;
                    }
                }
            }

            if (cCurrentAction.isFinished())
            {
                if (cLastAction.m_sActionID != cCurrentAction.m_sActionID) // Nur wenn die Aktion nicht die alte ist
                {
                    //Storage-Update
                    if (!m_cCellArea.IsCellVirtualByName(cCurrentAction.m_sCell))// Platzsituation bei Virtuellen Zellen nicht ändern
                    {
                        if (cCurrentAction.m_eActionType == eAction.PutToCell)
                        {
                            m_cMHS.m_cStorage.SetPlaceEmpty(cCurrentAction.m_iWPPlace);
                        }
                        else
                        {
                            m_cMHS.m_cStorage.SetPlaceOccupied(cCurrentAction.m_iWPPlace);
                        }
                    }
                }

                if (m_cWorkingScheduleHandler.IsEmpty() && m_bAutoModeActive && m_cAktionHandler.IsActionFree())
                {
                    AutoActionUpdate();
                    m_bFirstActionInAutoMode = false;
                }


                if (!m_cWorkingScheduleHandler.IsEmpty() && m_cAktionHandler.IsActionFree())
                {
                    m_cAktionHandler.makeAndRequestAction(m_cWorkingScheduleHandler.PopNexAction(), false);
                }
            }
        }
Beispiel #5
0
 private void CheckAndPushVirtualActions(Queue <c_WorkingStep> QueueOfNextSteps)
 {
     // Virtuelle Aktionen im Schritt finden
     foreach (c_WorkingStep Step in QueueOfNextSteps)
     {
         if (m_cCellArea.IsCellVirtualByName(Step.m_sCell))
         {
             // neue Aktion erstellen
             c_Action cVirtualAction = new c_Action();
             cVirtualAction.m_sWPID       = "0";
             cVirtualAction.m_iWPPlace    = Step.m_iWorkpiece;
             cVirtualAction.m_sCell       = Step.m_sCell;
             cVirtualAction.m_eActionType = eAction.PutToCell;
             // Aktion in den Stack zur Abarbeitung pushen
             m_cWorkingScheduleHandler.PushAction(cVirtualAction);
         }
     }
 }
        public void PushAction(c_Action cAction)
        {
            // nur wenn die gleiche Aktion nicht schon vorhande ist

            StackOfActions.Push(cAction);
        }
Beispiel #7
0
        private bool AutoActionUpdate()
        {
            c_WorkingStep         cNextStep             = new c_WorkingStep();
            Queue <c_WorkingStep> QueueOfNextSteps      = new Queue <c_WorkingStep>();
            Stack <c_Action>      ReverseStackOfActions = new Stack <c_Action>();

            if (m_cWorkingScheduleHandler.IsEmpty())
            {
                if (m_cWorkingSchedule.NextSteps(ref QueueOfNextSteps))
                {
                    c_Cell cCell = new c_Cell();
                    foreach (c_WorkingStep Step in QueueOfNextSteps)
                    {
                        if (Step.m_sAction == "pickup")
                        {
                            if (!m_cCellArea.SearchWPInCells(Step.m_iWorkpiece, ref cCell))
                            {
                                m_cWorkingSchedule.SetStepCountBack();
                                m_cWorkingScheduleHandler.ClearStackOfActions();
                                return(false);
                            }
                            if (!cCell.Idle)
                            {
                                m_cWorkingSchedule.SetStepCountBack();
                                m_cWorkingScheduleHandler.ClearStackOfActions();
                                return(false);
                            }
                            c_Action cNewAction = new c_Action();
                            cNewAction.m_sWPID       = m_cMHS.GetStorage().GetStorageIDOfPlace(Step.m_iWorkpiece);
                            cNewAction.m_iWPPlace    = Step.m_iWorkpiece;
                            cNewAction.m_sCell       = Step.m_sCell;
                            cNewAction.m_eActionType = eAction.GetFromCell;
                            // Aktion in den Stack zur Abarbeitung pushen
                            ReverseStackOfActions.Push(cNewAction);
                            //m_cWorkingScheduleHandler.PushAction(cNewAction);
                        }
                        if (Step.m_sAction == "put")
                        {
                            if (!m_cCellArea.GetCellOfName(Step.m_sCell, ref cCell))
                            {
                                m_cWorkingSchedule.SetStepCountBack();
                                m_cWorkingScheduleHandler.ClearStackOfActions();
                                return(false);
                            }
                            if (!cCell.Idle)
                            {
                                m_cWorkingSchedule.SetStepCountBack();
                                m_cWorkingScheduleHandler.ClearStackOfActions();
                                return(false);
                            }


                            c_Action cNewAction = new c_Action();
                            cNewAction.m_sWPID       = m_cMHS.GetStorage().GetStorageIDOfPlace(Step.m_iWorkpiece);
                            cNewAction.m_iWPPlace    = Step.m_iWorkpiece;
                            cNewAction.m_sCell       = Step.m_sCell;
                            cNewAction.m_eActionType = eAction.PutToCell;
                            // Aktion in den Stack zur Abarbeitung pushen
                            ReverseStackOfActions.Push(cNewAction);

                            // m_cWorkingScheduleHandler.PushAction(cNewAction);
                        }
                    }
                }
            }


            foreach (c_Action Action in ReverseStackOfActions)
            {
                m_cWorkingScheduleHandler.PushAction(Action);
            }

            return(true);
        }
        //konstruktor
        public c_MainViewModel()
        {
            // Config

            c_Config.m_sProtocolPath = "ysdfgb";

            CommonFunctions Reader = new CommonFunctions();

            string sJSon = "";
            string sPathOfConfig;
            string sRef = "";

            // Einlesen der Konfigurierten Pfade aus der confoig.json
            sPathOfConfig = "Config/Config.json";

            Reader.ReadJSonFile(sPathOfConfig, ref sJSon);
            Dictionary <string, string> dicConfig = JsonConvert.DeserializeObject <Dictionary <string, string> >(sJSon);


            if (dicConfig.TryGetValue("m_sSysDemStatusFile", out sRef) == false)
            {
                c_Config.bConfigErr = true; // Fehler
            }
            c_Config.m_sSysDemStatusFile = sRef;

            if (dicConfig.TryGetValue("m_sStorageFile", out sRef) == false)
            {
                c_Config.bConfigErr = true; // Fehler
            }
            c_Config.m_sStorageFile = sRef;

            if (dicConfig.TryGetValue("m_sRegenarationPathFile", out sRef) == false)
            {
                c_Config.bConfigErr = true; // Fehler
            }
            c_Config.m_sRegenarationPathFile = sRef;

            if (dicConfig.TryGetValue("m_sRegenarationPathApp", out sRef) == false)
            {
                c_Config.bConfigErr = true; // Fehler
            }
            c_Config.m_sRegenarationPathApp = sRef;

            if (dicConfig.TryGetValue("m_sProtocolPath", out sRef) == false)
            {
                c_Config.bConfigErr = true; // Fehler
            }
            c_Config.m_sProtocolPath = sRef;



            // FabrikTeileReal
            m_cFabric = new c_Fabric(this);


            //GUI Elemente
            m_cGuiAction = new c_Action();
            m_cGuiAction.m_eActionType = eAction.PutToCell;
            m_cGuiAction.m_sCell       = "A2";
            m_cGuiAction.m_iWPPlace    = 3;
            m_cGuiAction.m_sWPID       = "Muster1";
            m_GUIListCells             = new List <c_Cell> ();
            m_GUIStorage = new List <c_StoragePlace>();
            List <c_WorkingStep> m_GUIListOfWorkingSteps = new List <c_WorkingStep>();

            m_bAutoModeActive   = false;
            m_bManualModeActive = true;
            m_sAutoModeBtnText  = "Start";
            m_sMessageText      = "";
            m_sMessageText      = "Messages:";
            m_sAutoModeText     = "Automode: OFF";

            if (c_Config.bConfigErr) // Wenn die Confoig Datei einen Fehler hat eine Message anzeigen
            {
                AddToMessages("Error: Check Config!!!");
            }
            //Commands
            UpdateListsCommand  = new ICUpdateListsCommand(this);
            CreateActionCommand = new ICCreateAction(this);
            AutoModeCommand     = new ICAutoMode(this);
        }