Search Results for

    Show / Hide Table of Contents

    Compose Modules

    The hardware and software modules are composed to a module tree.

    Example

    This example shows the module tree for a station that contains two cavities in order to test two workpieces at the same time. It also contains a script module (Script) in which the user can define the test program. The type data module (TypeData) contains the parameters and characteristics of the current type. The results are saved in a database (ResultsDatabase).

    LisRT Module Tree

    This example is generated by this source code:

    internal class StationModule : InitializableCompositeModule
    {
        private StationModule(string name) : base(name)
        {
            WorkPieceModule = new WorkPieceModule(
                TypeDataModule,
                "WorkPiece",
                new Loehnert.TypeAndResult.Station("Station"));
    
            SubModules.Add(new Cavity("Cavity1", TypeDataModule));
            SubModules.Add(new Cavity("Cavity2", TypeDataModule));
    
            SubModules.Add(ScriptModule);
            SubModules.Add(TypeDataModule);
            SubModules.Add(ResultsDatabase);
        }
    
        [Export(ModulesService.RootModuleName, typeof(ILisrtModule))]
        public static StationModule Instance { get; } = new StationModule("Station");
    
        public ScriptModule ScriptModule { get; } = new ScriptModule("Script");
        public TypeDataModule TypeDataModule { get; } = new TypeDataModule("TypeData");
        public ResultsDatabaseModule ResultsDatabase { get; } 
            = new ResultsDatabaseModule("ResultsDatabase");
    
        public override void Initialize() { ... }
    }
    
    internal class Cavity : CompositeModule
    {
        public Cavity(string name, TypeDataModule typeDataModule) : base(name)
        {
            WorkPieceModule = new WorkPieceModule(
                typeDataModule,
                "WorkPiece",
                new Loehnert.TypeAndResult.Station("Station"));
            SubModules.Add(WorkPieceModule);
            SubModules.Add(PowerSupply);
            SubModules.Add(Multimeter);
        }
    
        public WorkPieceModule WorkPieceModule { get; }
        public PowerSupplyModule PowerSupply { get; } = new DummyPowerSupplyModule("PowerSupply");
        public MultimeterModule Multimeter { get; } = new DummyMultimeterModule("Multimeter");
    }
    

    Export a Root Module

    As you can see in the example, an instance of your root module needs to be exported. Add this export statement:

    [Export(ModulesService.RootModuleName, typeof(Loehnert.Lisrt.Contracts.ILisrtModule))]
    

    You can also export multiple root modules. The priority is defined by the RootModuleMetadata attribute.

    [RootModuleMetadata(5)] // The priorty is 5
    [Export(ModulesService.RootModuleName, typeof(Loehnert.Lisrt.Contracts.ILisrtModule))]
    

    See Also

    • Create a module
    • Module Configuration
    • ScriptModule
    • TypeDataModule
    • WorkPieceModule
    In This Article
    Back to top Copyright © Löhnert Elektronik GmbHlisrt.deImprint and Privacy Policy