private void generateInitAct(ref ITcPlcImplementation actImpl, ref string[] boxName)
        {
            string sImplementationTextFormat = @"
    {0}MdrSettings.xDI_Invert_Input_1:= FALSE;// invert zone 1 PE
    {0}MdrSettings.xDI_Invert_Input_3:= FALSE;// invert zone 2 PE
    {0}MdrSettings.xReverse_Motor_1:= FALSE;
    {0}MdrSettings.xReverse_Motor_2:= false;

    a{0}ZpaSettings[1].xEnable:= TRUE;
    a{0}ZpaSettings[1].iPeOffDelay:= 10;
    a{0}ZpaSettings[1].iPeOnDelay:= 10;
    a{0}ZpaSettings[1].iReleaseDelay:= 0;
    a{0}ZpaSettings[1].iZoneTraverseTime:= 1000;
    a{0}ZpaSettings[1].iPowerSaveTimeout:= 300;
    a{0}ZpaSettings[1].iMinimumVelocity:= 400;
    a{0}ZpaSettings[1].iReleaseJamTime:= 5000;
    a{0}ZpaSettings[1].iReleaseVelocity:= 1200;
    a{0}ZpaSettings[1].iReceiveVelocity:= 1000;
    a{0}ZpaSettings[1].uiAccel:= 1000;
    a{0}ZpaSettings[1].uiDecel:= 5000;
    a{0}ZpaSettings[1].eZpaMode:= e_ZpaMode.eSlugMode;

    a{0}ZpaSettings[2].xEnable:= TRUE;
    a{0}ZpaSettings[2].iPeOffDelay:= 10;
    a{0}ZpaSettings[2].iPeOnDelay:= 10;
    a{0}ZpaSettings[2].iReleaseDelay:= 0;
    a{0}ZpaSettings[2].iZoneTraverseTime:= 1000;
    a{0}ZpaSettings[2].iPowerSaveTimeout:= 300;
    a{0}ZpaSettings[2].iMinimumVelocity:= 400;
    a{0}ZpaSettings[2].iReleaseJamTime:= 5000;
    a{0}ZpaSettings[2].iReleaseVelocity:= 1200;
    a{0}ZpaSettings[2].iReceiveVelocity:= 1000;
    a{0}ZpaSettings[2].uiAccel:= 1000;
    a{0}ZpaSettings[2].uiDecel:= 5000;
    a{0}ZpaSettings[2].eZpaMode:= e_ZpaMode.eSingulationMode;" + Environment.NewLine;

            string sImplementationText = "";

            for (int i = 0; i < _nDriveCount - 1; i++)
            {
                sImplementationText += string.Format(sImplementationTextFormat, boxName[i]);
            }

            actImpl.ImplementationText = sImplementationText;
        }//GenerateInitAct()
        }//GenerateMainDecl()

        private void generateMainImpl(ref ITcPlcImplementation mainImpl)
        {
            string sImplemenetationText = @"
IF NOT xInitFlag THEN
xInitFlag := TRUE;
A_Init();
ELSE
A_Block();
END_IF

IF xStart THEN
    xRun := TRUE;
ELSIF xStop THEN
    xRun := FALSE;
END_IF";

            mainImpl.ImplementationText = sImplemenetationText;
        }
        }//GenerateInitAct()

        private void generateBlockAct(ref ITcPlcImplementation actImpl, ref string[] boxName)
        {
            string sImplementationTextFormat = @"{1}(
                    i_xEnable:= xEnable,
                    i_xStartCmd:= xRun,
                    i_xClearError:= xClearError,
                    i_axWakeUp:= {0}Feed,
                    i_astZpaSettings:= a{0}ZpaSettings,
                    i_stMdrSettings:= {0}MdrSettings,
                    i_pstEP7402:= ADR({0}));" + Environment.NewLine;

            string sImplementationText = "";

            for (int i = 0; i < _nDriveCount - 1; i++)
            {
                sImplementationText += string.Format(sImplementationTextFormat, boxName[i], boxName[i].Remove(0, 2));
            }//for

            actImpl.ImplementationText = sImplementationText;
        }//generateBlockAct()
        private void createFBCalls(string[] boxName)
        {
            //acuire project instance of MAIN Pou
            //then tell TwinCAT to create 3 new Actions for MAIN
            ITcSmTreeItem mainPOU    = sysMan.LookupTreeItem("TIPC^Untitled1^Untitled1 Project^POUs^MAIN");
            ITcSmTreeItem fbBlockAct = mainPOU.CreateChild("A_Block", 608, "");
            ITcSmTreeItem fbInitAct  = mainPOU.CreateChild("A_Init", 608, "");

            ITcPlcPou pouMain = (ITcPlcPou)mainPOU;


            ITcPlcImplementation actBlock = (ITcPlcImplementation)fbBlockAct;
            ITcPlcImplementation actInit  = (ITcPlcImplementation)fbInitAct;

            ITcPlcImplementation pouMainImpl = (ITcPlcImplementation)pouMain;

            ITcPlcDeclaration pouMainDecl = (ITcPlcDeclaration)pouMain;

            generateMainDecl(ref pouMainDecl, ref boxName);
            generateMainImpl(ref pouMainImpl);
            generateBlockAct(ref actBlock, ref boxName);
            generateInitAct(ref actInit, ref boxName);
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            //-----------------------------------------------------------------------------------------------------------------------
            //                                          Retrieve all relevant data from config file
            //-----------------------------------------------------------------------------------------------------------------------

            ConfigFileReader configFileReader = new ConfigFileReader();
            Assigner         assigner         = new Assigner();

            MessageFilter.Register();

            //-----------------------------------------------------------------------------------------------------------------------
            //                                          Attach to existing Dte
            //-----------------------------------------------------------------------------------------------------------------------



            AssignedConfigFileData.pathToSolution = Assigner.ReplaceBlueprintValues(
                AssignedConfigFileData.pathToSolution,
                new string[] { "@NameOfProject@" },
                new string[] { AssignedConfigFileData.nameOfProject }
                );

            Console.WriteLine("pathToSolution: {0}", AssignedConfigFileData.pathToSolution);

            AssignedConfigFileData.pathToPOUsFolder = Assigner.ReplaceBlueprintValues(
                AssignedConfigFileData.pathToPOUsFolder,
                new string[] { "@NameOfPLCProject@" },
                new string[] { AssignedConfigFileData.nameOfPlcProject }
                );

            Console.WriteLine("pathToPOUsFolder: {0}", AssignedConfigFileData.pathToPOUsFolder);

            AssignedConfigFileData.pathToDUTsFolder = Assigner.ReplaceBlueprintValues(
                AssignedConfigFileData.pathToDUTsFolder,
                new string[] { "@NameOfPLCProject@" },
                new string[] { AssignedConfigFileData.nameOfPlcProject }
                );

            Console.WriteLine("pathToDUTsFolder: {0}", AssignedConfigFileData.pathToDUTsFolder);

            AssignedConfigFileData.pathToGVLsFolder = Assigner.ReplaceBlueprintValues(
                AssignedConfigFileData.pathToGVLsFolder,
                new string[] { "@NameOfPLCProject@" },
                new string[] { AssignedConfigFileData.nameOfPlcProject }
                );

            Console.WriteLine("pathToGVLsFolder: {0}", AssignedConfigFileData.pathToGVLsFolder);

            AssignedConfigFileData.pathToMAIN = Assigner.ReplaceBlueprintValues(
                AssignedConfigFileData.pathToMAIN,
                new string[] { "@NameOfPLCProject@" },
                new string[] { AssignedConfigFileData.nameOfPlcProject }
                );

            Console.WriteLine("pathToMAIN: {0}", AssignedConfigFileData.pathToMAIN);

            List <Project> projectList  = new List <Project>();
            Project        plcProj      = null;
            bool           projectFound = false;

            ITcPlcDeclaration    decl = (ITcPlcDeclaration)null;
            ITcPlcImplementation impl = (ITcPlcImplementation)null;

            ITcSmTreeItem currentMethod = null;
            ITcSmTreeItem pou           = null;
            ITcSmTreeItem dut           = null;
            ITcSmTreeItem gvl           = null;
            ITcSmTreeItem main          = null;
            ITcSmTreeItem modules       = null;
            ITcSmTreeItem constants     = null;
            ITcSmTreeItem system        = null;
            ITcSmTreeItem targetModule  = null;
            ITcSmTreeItem triggers      = null;
            ITcSmTreeItem eventManagers = null;
            ITcSmTreeItem interfaces    = null;
            ITcSmTreeItem i_sequence    = null;

            ITcSysManager sysManager = null;

            EnvDTE.DTE dte =
                DteAttacher.attachToExistingDte(
                    AssignedConfigFileData.pathToSolution,
                    AssignedConfigFileData.visualStudioVersion,
                    AssignedConfigFileData.nameOfProject

                    );

            dynamic solution = dte.Solution;

            Console.WriteLine("Full solution name:");
            Console.WriteLine(solution.FullName);

            Projects prjs = solution.projects;

            Console.WriteLine("Projects in solution: {0}", prjs.Count);
            for (int i = 1; i <= prjs.Count; i++)
            {
                projectList.Add(prjs.Item(i));
                Console.WriteLine("Project found: {0}", prjs.Item(i).Name);
                Console.WriteLine("Searching for project: {0}", AssignedConfigFileData.nameOfProject);
                if (prjs.Item(i).Name.Equals(AssignedConfigFileData.nameOfProject))
                {
                    plcProj      = prjs.Item(i);
                    projectFound = true;
                }
            }

            //-----------------------------------------------------------------------------------------------------------------------
            //                                          Perform checks
            //-----------------------------------------------------------------------------------------------------------------------

            Console.WriteLine("Performing checks:");

            if (projectFound)
            {
                Console.WriteLine("Project found.");
                sysManager = plcProj.Object;
            }
            else
            {
                Console.WriteLine("Project not found. Exiting on Enter.");
                Console.Read();
                return;
            }

            //Is POUs item available?
            Functions.SearchForItem(AssignedConfigFileData.pathToPOUsFolder, ref sysManager, ref pou);

            //Is DUTs item available?
            Functions.SearchForItem(AssignedConfigFileData.pathToDUTsFolder, ref sysManager, ref dut);

            //Is GVLs item available?
            Functions.SearchForItem(AssignedConfigFileData.pathToGVLsFolder, ref sysManager, ref gvl);

            //Is Main item available?
            Functions.SearchForItem(AssignedConfigFileData.pathToMAIN, ref sysManager, ref main);

            if (AssignedConfigFileData.activity.Equals("SpecificEventsModuleCreator"))
            {
                //-----------------------------------------------------------------------------------------------------------------------
                //--------------------------------- MAIN implementation -----------------------------------------------------------------
                //-----------------------------------------------------------------------------------------------------------------------
                impl = (ITcPlcImplementation)main;
                impl.ImplementationText = AssignedConfigFileData.blueprintMainImplementation;

                //-----------------------------------------------------------------------------------------------------------------------
                //--------------------------------- Create methods for MAIN -------------------------------------------------------------
                //-----------------------------------------------------------------------------------------------------------------------
                currentMethod        = main.CreateChild("systemTime", 609, "");
                decl                 = (ITcPlcDeclaration)currentMethod;
                decl.DeclarationText = AssignedConfigFileData.blueprintMainSystemTimeDeclaration;

                impl = (ITcPlcImplementation)currentMethod;
                impl.ImplementationText = AssignedConfigFileData.blueprintMainSystemTimeImplementation;

                //-----------------------------------------------------------------------------------------------------------------------
                //--------------------------------- Create the  ModulesGVL --------------------------------------------------------------
                //-----------------------------------------------------------------------------------------------------------------------
                modules = gvl.CreateChild("Modules", 615, "", AssignedConfigFileData.blueprintModulesGvlDeclaration);

                //-----------------------------------------------------------------------------------------------------------------------
                //--------------------------------- Create the  ConstantsGVL ------------------------------------------------------------
                //-----------------------------------------------------------------------------------------------------------------------
                constants = gvl.CreateChild("Constants", 615, "", AssignedConfigFileData.blueprintConstantsGvlDeclaration);

                //-----------------------------------------------------------------------------------------------------------------------
                //--------------------------------- Create the SystemGVL ----------------------------------------------------------------
                //-----------------------------------------------------------------------------------------------------------------------
                system = gvl.CreateChild("System", 615, "", AssignedConfigFileData.blueprintSystemGvlDeclaration);

                //-----------------------------------------------------------------------------------------------------------------------
                //--------------------------------- Create the EventManagers folder -----------------------------------------------------
                //-----------------------------------------------------------------------------------------------------------------------
                eventManagers = pou.CreateChild("EventManagers", 601, "", "1");

                //-----------------------------------------------------------------------------------------------------------------------
                //--------------------------------- Create the Interfaces folder --------------------------------------------------------
                //-----------------------------------------------------------------------------------------------------------------------
                interfaces = pou.CreateChild("Interfaces", 601, "", "1");

                //-----------------------------------------------------------------------------------------------------------------------
                //--------------------------------- Create the I_Sequence interface -----------------------------------------------------
                //-----------------------------------------------------------------------------------------------------------------------
                i_sequence = interfaces.CreateChild("I_Sequence", 618);

                //-----------------------------------------------------------------------------------------------------------------------
                //--------------------------------- Create the sequence interface method ------------------------------------------------
                //-----------------------------------------------------------------------------------------------------------------------
                currentMethod        = i_sequence.CreateChild("sequence", 610);
                decl                 = (ITcPlcDeclaration)currentMethod;
                decl.DeclarationText = AssignedConfigFileData.blueprintInterfaceSequenceMethodDeclaration;
            }
            else
            {
                //Is the Module GVL present?
                Functions.SearchForSubItem("Modules", ref gvl, ref modules);

                //Is the Triggers GVL present?
                //Functions.SearchForSubItem("Triggers", ref gvl, ref triggers);

                //Is the Eventmanagers folder present?
                Functions.SearchForSubItem("EventManagers", ref pou, ref eventManagers);
            }

            //Is TargetModule present?

            /*
             * if (AssignedConfigFileData.activity.Equals("InjectNewEventManagerInTarget"))
             * {
             *  Functions.SearchForItem(AssignedConfigFileData.pathToTargetModule, ref sysManager, ref targetModule);
             * }
             */
            //Is the Interfaces folder present?
            //Functions.SearchForSubItem("Interfaces", ref pou, ref interfaces);

            //-----------------------------------------------------------------------------------------------------------------------
            //                                          Start activity
            //-----------------------------------------------------------------------------------------------------------------------

            Console.WriteLine("Executing program.");

            for (int i = 0; i < AssignedConfigFileData.modulesContainer.content.Length; i++)
            {
                if (AssignedConfigFileData.activity.Equals("GeneralEventsModuleCreator"))
                {
                    new GeneralEventsModuleCreator(i, pou, dut, gvl, eventManagers, modules, triggers);
                }
                else if (AssignedConfigFileData.activity.Equals("SpecificEventsModuleCreator"))
                {
                    new SpecificEventsModuleCreator(i, pou, dut, gvl, eventManagers, modules, triggers);
                }
            }
            MessageFilter.Revoke();
            Console.WriteLine("Finished!");
            Console.Read();
        }
Esempio n. 6
0
        private void CreateModuleCode()
        {
            String eventManagerName;

            //-----------------------------------------------------------------------------------------------------------------------
            //---------------------------------Create module In-Out Structs  --------------------------------------------------------
            //-----------------------------------------------------------------------------------------------------------------------

            moduleConditionsToFire = dut.CreateChild(
                module.getName + "conditionsToFire",
                606,
                "",
                Assigner.ReplaceBlueprintValues(
                    AssignedConfigFileData.blueprintModuleOutStruct,
                    new string[] { "@moduleName@" },
                    new string[] { module.getName }
                    )
                );

            //Structure that defines the Event-Triggers that will be used as inputs in the Eventmanager
            moduleEventTriggers = dut.CreateChild(
                module.getName + "EventTriggers",
                606,
                "",
                Assigner.ReplaceBlueprintValues(
                    AssignedConfigFileData.blueprintModuleInStruct,
                    new string[] { "@moduleName@" },
                    new string[] { module.getName }
                    )
                );


            //-----------------------------------------------------------------------------------------------------------------------
            //--------------------------------- Fill the  ModulesGVL ----------------------------------------------------------------
            //-----------------------------------------------------------------------------------------------------------------------

            modulesGvlImplementation = "\t" + module.getName + ": " + module.getName + ";" + "\n";
            decl  = (ITcPlcDeclaration)modules;
            index = decl.DeclarationText.IndexOf(keyVarGlobal);
            decl.DeclarationText =
                decl.DeclarationText.Insert(
                    index + (keyVarGlobal.Length + 1),
                    modulesGvlImplementation
                    );

            //-----------------------------------------------------------------------------------------------------------------------
            //------------------------------------------------Create the FB_TargetModule---------------------------------------------
            //-----------------------------------------------------------------------------------------------------------------------

            //604   TREEITEMTYPE_PLCPOUFB   POU Function Block
            ITcSmTreeItem targetModule = pou.CreateChild(module.getName, 604, "1");

            //-----------------------------------------------------------------------------------------------------------------------
            //--------------------------- Create the FB_TargetModule Methods --------------------------------------------------------
            //-----------------------------------------------------------------------------------------------------------------------
            moduleEventManagerDeclaration = null;
            eventNamesLists.Clear();

            foreach (EventManager eventManager in module.content)
            {
                eventNamesLists.Add(eventManager.content.eventNames);
                eventManagerNames.Add(eventManager.getName);
                moduleEventManagerDeclaration += Assigner.ReplaceBlueprintValues(
                    "\t" + AssignedConfigFileData.blueprintModuleEventManagerDeclaration + "\n",
                    new string[] { "@eventManagerName@" },
                    new string[] { eventManager.getName }
                    );

                moduleEventManagerImplementation += Assigner.ReplaceBlueprintValues(
                    AssignedConfigFileData.blueprintModuleEventManagerImplementation + "\n",
                    new string[] { "@eventManagerName@" },
                    new string[] { eventManager.getName }
                    );
            }

            foreach (String[] eventNamesGroup in eventNamesLists)
            {
                eventManagerName = eventManagerNames.First();
                eventManagerNames.RemoveAt(0);

                foreach (String eventName in eventNamesGroup)
                {
                    //Create EventMethods
                    currentMethod = targetModule.CreateChild(eventName + "Event", 609, "", methodDescription);

                    decl = (ITcPlcDeclaration)currentMethod;
                    decl.DeclarationText = Assigner.ReplaceBlueprintValues(
                        AssignedConfigFileData.blueprintEventMethodDeclaration,
                        new string[] { "@eventName@" },
                        new string[] { eventName }
                        );

                    //Create SenderMethods
                    currentMethod = targetModule.CreateChild("fire" + Functions.UppercaseFirst(eventName) + "Event", 609, "", methodDescription);

                    decl = (ITcPlcDeclaration)currentMethod;

                    decl.DeclarationText = Assigner.ReplaceBlueprintValues(
                        AssignedConfigFileData.blueprintSenderMethodDeclaration,
                        new string[] { "@eventName@" },
                        new string[] { eventName }
                        );

                    impl = (ITcPlcImplementation)currentMethod;
                    impl.ImplementationText = Assigner.ReplaceBlueprintValues(
                        AssignedConfigFileData.blueprintSenderMethodImplementation,
                        new string[] { "@eventName@", "@eventManagerName@" },
                        new string[] { eventName, eventManagerName }
                        );

                    outConditionsToFire += "\t" + eventName + "Event : BOOL;\n";

                    eventRaiserImplementation += Assigner.ReplaceBlueprintValues(
                        AssignedConfigFileData.blueprintEventRaiserImplementation + "\n",
                        new string[] { "@eventName@" },
                        new string[] { eventName }
                        );

                    moduleTriggerEventDeclaration += Assigner.ReplaceBlueprintValues(
                        "\t" + AssignedConfigFileData.blueprintModuleTriggerEventsDeclaration + "\n",
                        new string[] { "@eventName@" },
                        new string[] { Functions.UppercaseFirst(eventName) }
                        );
                }
            }

            //Fill the module structures with the relevant data
            //--------------------------------------------------------------------------------
            decl = (ITcPlcDeclaration)moduleEventTriggers;

            index = decl.DeclarationText.IndexOf(keyVarStruct);
            decl.DeclarationText = decl.DeclarationText.Insert(
                index + (keyVarStruct.Length + 1),
                moduleTriggerEventDeclaration
                );

            decl = (ITcPlcDeclaration)moduleConditionsToFire;

            index = decl.DeclarationText.IndexOf(keyVarStruct);
            decl.DeclarationText = decl.DeclarationText.Insert(
                index + (keyVarStruct.Length + 1),
                outConditionsToFire
                );
            //--------------------------------------------------------------------------------

            //eventRaiser method
            currentMethod = targetModule.CreateChild("eventRaiser", 609, "", methodDescription);


            decl = (ITcPlcDeclaration)currentMethod;
            decl.DeclarationText = AssignedConfigFileData.blueprintEventRaiserDeclaration;

            impl = (ITcPlcImplementation)currentMethod;
            impl.ImplementationText = eventRaiserImplementation;

            //callComponents method
            currentMethod = targetModule.CreateChild("callComponents", 609, "", methodDescription);


            decl = (ITcPlcDeclaration)currentMethod;
            decl.DeclarationText = AssignedConfigFileData.blueprintCallComponentsDeclaration;

            //registerSequence method
            currentMethod = targetModule.CreateChild("registerSequence", 609, "", methodDescription);


            decl = (ITcPlcDeclaration)currentMethod;
            decl.DeclarationText = AssignedConfigFileData.blueprintRegisterSequenceDeclarationText;

            impl = (ITcPlcImplementation)currentMethod;
            impl.ImplementationText = AssignedConfigFileData.blueprintRegisterSequenceImplementationText;

            //runSequence method
            currentMethod = targetModule.CreateChild("runSequence", 609, "", methodDescription);


            decl = (ITcPlcDeclaration)currentMethod;
            decl.DeclarationText = AssignedConfigFileData.blueprintRunSequenceDeclarationText;

            impl = (ITcPlcImplementation)currentMethod;
            impl.ImplementationText = AssignedConfigFileData.blueprintRunSequenceImplementationText;

            /*
             * currentMethod = targetModule.CreateChild("eventRaiser", 609, "", methodDescription);
             *
             * //M_EventRaiser
             * decl = (ITcPlcDeclaration)currentMethod;
             * decl.DeclarationText = AssignedConfigFileData.blueprintEventRaiserDeclaration;
             *
             * impl = (ITcPlcImplementation)currentMethod;
             * impl.ImplementationText = eventRaiserImplementation;
             *
             * currentMethod = targetModule.CreateChild("callComponents", 609, "", methodDescription);
             *
             * //M_CallComponents
             * decl = (ITcPlcDeclaration)currentMethod;
             * decl.DeclarationText = AssignedConfigFileData.blueprintCallComponentsDeclaration;
             */
            //-----------------------------------------------------------------------------------------------------------------------
            //-------------------------- Fill the declaration and implementation part of FB_TargetModule with code-------------------
            //-----------------------------------------------------------------------------------------------------------------------

            decl = (ITcPlcDeclaration)targetModule;
            impl = (ITcPlcImplementation)targetModule;

            decl.DeclarationText = Assigner.ReplaceBlueprintValues(
                AssignedConfigFileData.modulesDeclarations[targetIndex],
                new string[] { "@eventManagers", "@moduleName@" },
                new string[] { moduleEventManagerDeclaration, module.getName }
                );

            impl.ImplementationText = Assigner.ReplaceBlueprintValues(
                AssignedConfigFileData.modulesImplementations[targetIndex],
                new string[] { "@eventManagers" },
                new string[] { moduleEventManagerImplementation }
                );
        }
Esempio n. 7
0
        private void CreateEventManagerCode()
        {
            //-----------------------------------------------------------------------------------------------------------------------
            //------------------------------------------------Create the FB_EventManager---------------------------------------------
            //-----------------------------------------------------------------------------------------------------------------------
            foreach (EventManager eventManager in module.content)
            {
                ITcSmTreeItem fbEventManager = eventManagers.CreateChild(eventManager.getName + "EventManager", 604, "1");

                String[] eventNameGroup = eventManager.content.eventNames;

                outEventManagerEvents         = null;
                eventManagerEventsStrings     = null;
                eventDispatcherImplementation = null;
                handlerOperations             = null;
                enumEventDeclaration          = null;
                triggersImplementation        = null;
                foreach (String eventName in eventNameGroup)
                {
                    outEventManagerEvents += "\t" + eventName + "Event : BOOL;\n";

                    if (eventNameGroup.Last() == eventName)
                    {
                        eventManagerEventsStrings += "\t\t'" + eventName + "Event'\n";
                    }
                    else
                    {
                        eventManagerEventsStrings += "\t\t'" + eventName + "Event',\n";
                    }


                    eventDispatcherImplementation += Assigner.ReplaceBlueprintValues(
                        "\n" + AssignedConfigFileData.blueprintEventDispatcherImplementation,
                        new string[] { "@eventManagerName@", "@eventName@" },
                        new string[] { eventManager.getName, eventName }
                        );

                    handlerOperations += Assigner.ReplaceBlueprintValues(
                        AssignedConfigFileData.blueprintHandlerOperation + "\n",
                        new string[] { "@eventManagerName@", "@eventName@", "@moduleName@" },
                        new string[] { eventManager.getName, eventName, module.getName }
                        );

                    enumEventDeclaration += "\t" + eventName + "Event,\n";

                    triggersImplementation += "\t" + eventName + "RTrigger : R_TRIG;" + "\n";
                    //-----------------------------------------------------------------------------------------------------------------------
                    //--------------------------- Create the FB_EventManager eventReceivers -------------------------------------------------
                    //-----------------------------------------------------------------------------------------------------------------------

                    //Implement receivers
                    currentReceiver = fbEventManager.CreateChild(eventName + "Receiver", 611, "", propertyDescription);

                    decl = (ITcPlcDeclaration)currentReceiver;
                    decl.DeclarationText = Assigner.ReplaceBlueprintValues(
                        AssignedConfigFileData.blueprintReceiversDeclaration,
                        new string[] { "@eventName@" },
                        new string[] { eventName }
                        );

                    //Implement getters
                    currentReceiver = currentReceiver.CreateChild("", 613, "", "1");

                    impl = (ITcPlcImplementation)currentReceiver;
                    impl.ImplementationText = Assigner.ReplaceBlueprintValues(
                        AssignedConfigFileData.blueprintReceiversGetterImplementation,
                        new string[] { "@eventManagerName@", "@eventName@" },
                        new string[] { eventManager.getName, eventName }
                        );
                }

                //-----------------------------------------------------------------------------------------------------------------------
                //-------------------------- Create the  E_<X>Event Enumaration ---------------------------------------------------------
                //-----------------------------------------------------------------------------------------------------------------------

                //605   TREEITEMTYPE_PLCDUTENUM     DUT enum data type
                dut.CreateChild(
                    eventManager.getName + "Event",
                    605, "",
                    Assigner.ReplaceBlueprintValues(
                        AssignedConfigFileData.blueprintEnumEventDeclaration,
                        new string[] { "@eventManagerName@", "@eventNames" },
                        new string[] { eventManager.getName, enumEventDeclaration }
                        )
                    );

                //-----------------------------------------------------------------------------------------------------------------------
                //-------------------------- Create the  EventManager-Structures ----------------------------------------------------
                //-----------------------------------------------------------------------------------------------------------------------

                dut.CreateChild(
                    eventManager.getName + "EventRecord",
                    606,
                    "",
                    Assigner.ReplaceBlueprintValues(
                        AssignedConfigFileData.blueprintEventRecordDeclaration,
                        new string[] { "@eventManagerName@" },
                        new string[] { eventManager.getName }
                        )
                    );

                //Structure that defines the Event-Triggers that will be used as inputs in the Eventmanager
                eventManagerEventTriggers = dut.CreateChild(
                    eventManager.getName + "EventTriggers",
                    606,
                    "",
                    Assigner.ReplaceBlueprintValues(
                        AssignedConfigFileData.blueprintEventManagerInStruct,
                        new string[] { "@eventManagerName@" },
                        new string[] { eventManager.getName }
                        )
                    );

                decl = (ITcPlcDeclaration)eventManagerEventTriggers;

                index = decl.DeclarationText.IndexOf(keyVarStruct);
                decl.DeclarationText = decl.DeclarationText.Insert(
                    index + (keyVarStruct.Length + 1),
                    triggersImplementation
                    );

                eventManagerEventReceivers = dut.CreateChild(
                    eventManager.getName + "EventReceiver",
                    606,
                    "",
                    Assigner.ReplaceBlueprintValues(
                        AssignedConfigFileData.blueprintEventManagerOutStruct,
                        new string[] { "@eventManagerName@" },
                        new string[] { eventManager.getName }
                        )
                    );

                decl  = (ITcPlcDeclaration)eventManagerEventReceivers;
                index = decl.DeclarationText.IndexOf(keyVarStruct);
                decl.DeclarationText = decl.DeclarationText.Insert(
                    index + (keyVarStruct.Length + 1),
                    outEventManagerEvents
                    );
                //-----------------------------------------------------------------------------------------------------------------------
                //-------------------------- Fill the declaration and implementation part of FB_EventManager with code-------------------
                //-----------------------------------------------------------------------------------------------------------------------
                decl = (ITcPlcDeclaration)fbEventManager;
                impl = (ITcPlcImplementation)fbEventManager;

                decl.DeclarationText = Assigner.ReplaceBlueprintValues(
                    AssignedConfigFileData.blueprintEventManagerDeclaration,
                    new string[] { "@eventManagerName@", "@eventStrings", "@moduleName@" },
                    new string[] { eventManager.getName, eventManagerEventsStrings, module.getName }
                    );


                impl.ImplementationText = AssignedConfigFileData.blueprintEventManagerImplementation;

                //-----------------------------------------------------------------------------------------------------------------------
                //--------------------------- Create the FB_EventManager Methods --------------------------------------------------------
                //-----------------------------------------------------------------------------------------------------------------------

                //M_CheckForRaceCondition
                currentMethod = fbEventManager.CreateChild("checkForRaceCondition", 609, "", methodDescription);

                decl = (ITcPlcDeclaration)currentMethod;
                decl.DeclarationText = AssignedConfigFileData.blueprintRaceConditionDeclaration;

                impl = (ITcPlcImplementation)currentMethod;
                impl.ImplementationText = Assigner.ReplaceBlueprintValues(
                    AssignedConfigFileData.blueprintRaceConditionImplementation,
                    new string[] { "@eventManagerName@" },
                    new string[] { eventManager.getName }
                    );

                //M_EventDispatcher
                currentMethod = fbEventManager.CreateChild("eventDispatcher", 609, "", methodDescription);

                decl = (ITcPlcDeclaration)currentMethod;
                decl.DeclarationText = AssignedConfigFileData.blueprintEventDispatcherDeclaration;

                impl = (ITcPlcImplementation)currentMethod;
                impl.ImplementationText = eventDispatcherImplementation;

                //M_ExecuteHandler
                currentMethod = fbEventManager.CreateChild("executeHandler", 609, "", methodDescription);

                decl = (ITcPlcDeclaration)currentMethod;
                decl.DeclarationText = AssignedConfigFileData.blueprintExecuteHandlerDeclaration;

                impl = (ITcPlcImplementation)currentMethod;
                impl.ImplementationText = Assigner.ReplaceBlueprintValues(
                    AssignedConfigFileData.blueprintExecuteHandlerImplementation,
                    new string[] { "@handlerOperations" },
                    new string[] { handlerOperations }
                    );

                //M_UpdateEventHistory
                currentMethod = fbEventManager.CreateChild("updateEventHistory", 609, "", methodDescription);

                decl = (ITcPlcDeclaration)currentMethod;
                decl.DeclarationText = AssignedConfigFileData.blueprintUpdateEventHistoryDeclaration;


                impl = (ITcPlcImplementation)currentMethod;

                impl.ImplementationText = AssignedConfigFileData.blueprintUpdateEventHistoryImplementation;

                //M_UpdateEventRecord
                currentMethod = fbEventManager.CreateChild("updateEventRecord", 609, "", methodDescription);

                decl = (ITcPlcDeclaration)currentMethod;
                decl.DeclarationText = AssignedConfigFileData.blueprintUpdateEventRecordDeclaration;

                impl = (ITcPlcImplementation)currentMethod;
                impl.ImplementationText = Assigner.ReplaceBlueprintValues(
                    AssignedConfigFileData.blueprintUpdateEventRecordImplementation,
                    new string[] { "@unequal" },
                    new string[] { "<>" }
                    );
                //FB_Init
                currentMethod        = fbEventManager.CreateChild("FB_init", 609, "", methodDescription);
                decl                 = (ITcPlcDeclaration)currentMethod;
                decl.DeclarationText = Assigner.ReplaceBlueprintValues(
                    AssignedConfigFileData.blueprintEventManagerFBInitDeclarationText,
                    new string[] { "@moduleName@" },
                    new string[] { module.getName }
                    );
                impl = (ITcPlcImplementation)currentMethod;
                impl.ImplementationText = Assigner.ReplaceBlueprintValues(
                    AssignedConfigFileData.blueprintEventManagerFBInitImplementationText,
                    new string[] { "@moduleName@" },
                    new string[] { module.getName }
                    );
                //-----------------------------------------------------------------------------------------------------------------------
                //--------------------------- Create the FB_EventManager disable signal -------------------------------------------------
                //-----------------------------------------------------------------------------------------------------------------------
                disableSignal =
                    fbEventManager.
                    CreateChild("disableEventManagerSignal", 611, "", propertyDescription);

                decl = (ITcPlcDeclaration)disableSignal;
                decl.DeclarationText = AssignedConfigFileData.blueprintDisableEventManagerSignalDeclaration;

                //Implement getter
                currentSignal           = disableSignal.CreateChild("", 613, "", "1");
                impl                    = (ITcPlcImplementation)currentSignal;
                impl.ImplementationText = AssignedConfigFileData.blueprintDisableEventManagerSignalGetterImplementation;

                //Implement setter
                currentSignal           = disableSignal.CreateChild("", 614, "", "1");
                impl                    = (ITcPlcImplementation)currentSignal;
                impl.ImplementationText = AssignedConfigFileData.blueprintDisableEventManagerSignalSetterImplementation;

                Console.WriteLine("Code for " + eventManager.getName + "EventManager" + " created.");
            }
        }