coreDS™ C# – Implementation sample

Here are two samples Python Federates that send and receive information from the HLA Federation. A DIS simulator would work using exactly the same code, the data mapping being done via the GUIs.

A more information about the configuration GUIs can be found here.

Curious about using the LUA scripting engine? Take a look here.

Receiving data

t is important to notice the C# programmer NEVER has to know what is the real object type it’s updating. The programmer ALWAYS use local name representation.

See the code
//This object manage generic parameters for coreDS
            cCoreDSData configData = new cCoreDSData();

            //This object manage the distributed simulation connect (HLA or DIS)s
            cCoreDS lDSConnection = new cCoreDS();

            //This will be used in the UI only
            //List your INCOMING (object that your simulation will display)
            cCoreDSMapping lInputObjectMapping = new cCoreDSMapping();
            lInputObjectMapping.add("InputAircraft", "x");
            lInputObjectMapping.add("InputAircraft", "y");
            lInputObjectMapping.add("InputAircraft", "z");
            /*
            lInputObjectMapping.add("InputBomb", "x");
            lInputObjectMapping.add("InputBomb", "y");
            lInputObjectMapping.add("InputBomb", "z");
            //etc
            */

            //This will be used in the UI only
            //List your INCOMING objects(object that your simulation will send to the simulation framework)
            cCoreDSMapping lOutputObjectMapping = new cCoreDSMapping();
            lOutputObjectMapping.add("OutputAircraft", "x");
            lOutputObjectMapping.add("OutputAircraft", "y");
            lOutputObjectMapping.add("OutputAircraft", "z");
            
            //This will be used in the UI only
            //List your INCOMING objects (object that your simulation will send to the simulation framework)
            cCoreDSMapping lInputMessageMapping = new cCoreDSMapping();
            lInputMessageMapping.add("MessageInputDetotation", "x");
            lInputMessageMapping.add("MessageInputDetotation", "y");
            lInputMessageMapping.add("MessageInputDetotation", "z");

            //This will be used in the UI only
            //List your INCOMING message(object that your simulation will send to the simulation framework)
            cCoreDSMapping lOutputMessageMapping = new cCoreDSMapping();
            lOutputMessageMapping.add("MessageOutputWeaponFire", "x");
            lOutputMessageMapping.add("MessageOutputWeaponFire", "y");
            lOutputMessageMapping.add("MessageOutputWeaponFire", "z");

            // no config file at this point, the UI will take care of it
            //configData.set("ConfigFile", "configname.json); 
            //If this value doesn't exists, [pwd / config] will be used
            //configData.set("ConfigLocation", "c://path to config");
            configData.set("EnableScripting", "1");
            configData.set("SelectedLUAEditor", "");
            configData.set("DisableWord", "1");
            configData.set("EnableDebugging", "1" );
            configData.set("ReloadScript", "1");
            configData.set("LogErrorWindow", "1");
            configData.set("LogToFile", "1");
            configData.set("LogErrorPath", "c://temp/coreDSLog.log");

            lDSConnection.showConfigHelper(configData, lInputObjectMapping, lOutputObjectMapping,
                                                        lInputMessageMapping, lOutputMessageMapping);


            lDSConnection.init(configData);
            //Before we initialize the connection, we need to register our callbacks
            lDSConnection.registerNewObjectFoundHandler("InputAircraft", new cbAircraftFound());
            lDSConnection.registerObjectUpdateHandler("InputAircraft", new cbAircraftUpdated());

            if (lDSConnection.isConnected() == true)
            {
                isRunning = true;
                while (isRunning)
                {
                    lDSConnection.step();
                }
            }

 

We are using cookies on our website

We use cookies on this website to improve our product offering.