예제 #1
0
        public void Initialize(ref SimulationModelInfo simModel, ref Blackboard blackboard, ref SimulationEventDistributor distributor)
        {
            this.blackboard = blackboard;
            this.bbClient = new BlackboardClient();
            this.distributor = distributor;
            this.distClient = new SimulationEventDistributorClient();
            this.simModel = simModel;
            this.dmColorMapping = new Dictionary<string, int>();
            this.teamDefinitions = new Dictionary<string, List<string>>();
            this.networkRosters = new Dictionary<string, List<string>>();
            this.dmTeamsMap = new Dictionary<string, string>();
            this.networkObjects = new Dictionary<string, List<string>>();
            this.listOfObstructionIDs = new List<string>();
            this.obstructions = new Dictionary<string, StateDB.ActiveRegion>();
            this.listOfObjectIDs = new List<string>();
            this.dmOwnedObjects = new Dictionary<string, List<string>>();
            objectViews = new Dictionary<string, ObjectsAttributeCollection>();
            teamClassifications = new Dictionary<string, Dictionary<string, string>>();
            teamClassificationChanges = new Dictionary<string, Dictionary<string, string>>();
            dmViews = new Dictionary<string, ObjectsAttributeCollection>();
            activeDMs = new List<string>();
            activeSensorNetworks = new Dictionary<string, bool>();
            //singletonDMs = new List<string>();
            currentAttacks = new List<Attack>();
            ClassificationsEnum = new List<String>();
            movingObjects = new List<string>();
            randomGenerator = new Random(randomSeed);
            this.dTimeSec = ((double)simModel.GetUpdateFrequency()) / 1000;
            this.dTimeMSec = simModel.GetUpdateFrequency();
            currentTick = 0;
            distributor.RegisterClient(ref distClient);
            blackboard.RegisterClient(ref bbClient);

            // subscribe to events that aren't OwnerObservable

            bbClient.Subscribe("PhysicalObject", "Emitters", true, false);
            bbClient.Subscribe("PhysicalObject", "RemoveOnDestruction", true, false);
            bbClient.Subscribe("PhysicalObject", "ActiveRegionSpeedMultiplier", true, false);
            bbClient.Subscribe("PhysicalObject", "DefaultClassification", true, false);
            bbClient.Subscribe("PhysicalObject", "ClassificationDisplayRules", true, false);

            foreach (KeyValuePair<string, AttributeInfo> kvp in simModel.objectModel.objects["PhysicalObject"].attributes)
            {
                if (kvp.Value.ownerObservable == true)
                {
                    bbClient.Subscribe("PhysicalObject", kvp.Key, true, false);
                }
            }
            bbClient.Subscribe("DecisionMaker", "RoleName", true, false);

            bbClient.Subscribe("SensorNetwork", "DMMembers", true, false);
            bbClient.Subscribe("Region", "Polygon", true, false);
            bbClient.Subscribe("ActiveRegion", "BlocksSensorTypes", true, false);
            objectProxies = new Dictionary<string, SimulationObjectProxy>();
        }
예제 #2
0
파일: Form1.cs 프로젝트: wshanshan/DDD
 private void SetSimulationModel()
 {
     string name = simulationModelTextBox.Text;
     if (System.IO.File.Exists(name))
     {
         SimulationModelReader r = new SimulationModelReader();
         simModel = r.readModel(name);
         updateFrequency = simModel.GetUpdateFrequency();
         NetworkEnable();
         EventsEnable();
         SimulationModelDisable();
         
     }
     else
     {
         MessageBox.Show("Invalid simulation model file!");
     }
 }