Example #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;

            distributor.RegisterClient(ref distClient);
            //distClient.Subscribe("NewObject");
            //distClient.Subscribe("RevealObject");
            //distClient.Subscribe("TimeTick");
            //distClient.Subscribe("StateChange");
            //distClient.Subscribe("ResetSimulation");

            blackboard.RegisterClient(ref bbClient);
            bbClient.Subscribe("PhysicalObject", "ID", true, false);
            bbClient.Subscribe("PhysicalObject", "StateTable", true, false);
            bbClient.Subscribe("PhysicalObject", "Throttle", true, false);
            bbClient.Subscribe("PhysicalObject", "FuelCapacity", true, true);
            bbClient.Subscribe("PhysicalObject", "FuelAmount", true, true);
            bbClient.Subscribe("PhysicalObject", "FuelConsumptionRate", true, true);
            bbClient.Subscribe("PhysicalObject", "FuelDepletionState", true, true);
            bbClient.Subscribe("PhysicalObject", "DockedToParent", true, false);

            objectProxies = new Dictionary<string, SimulationObjectProxy>();
        }
Example #2
0
 //private static Thread textChatServerThread;
 //private static Thread handshakeManagerThread;
 /// <summary>
 /// 
 /// </summary>
 /// <param name="scenarioFile"></param>
 /// <param name="schemaFile"></param>
 /// <param name="hostname"></param>
 /// <param name="portString"></param>
 /// <param name="simModelName"></param>
 /// <param name="contextControl"></param>
 /// <param name="updateIncr"></param>
 /// <param name="lowerLevel"></param>
 /// <param name="outputType">Arg0 = Debug, Arg1 = Test</param>
 public Coordinator(
     string scenarioFile,
     string schemaFile,
     string replayFile,
     ref SimulationEventDistributor distributor,
     //string hostname,
     //string portString,
     string simModelName,
     string contextControl,//*NETWORK"
     string updateIncr,
     string lowerLevel,
     List<string> logTypes,
     string debugFile
     )// Needed(?) only so can start a thread
 {
     SetError(false);
     coordinatorThread = null;
     eCommReceiver = null;
     //textChatServerThread = null;
     //handshakeManagerThread = null;
     Coordinator.scenarioFile = scenarioFile;
     Coordinator.schemaFile = schemaFile;
     Coordinator.replayFile = replayFile;
     //Coordinator.hostname = hostname;
     //Coordinator.portString = portString;
     Coordinator.distributor = distributor;
     Coordinator.simModelName = simModelName;
     Coordinator.contextControl = contextControl;//*NETWORK"
     Coordinator.updateIncr = updateIncr;
     Coordinator.lowerLevel = lowerLevel;//GUI
     Coordinator.loggingTypes = logTypes;
     Coordinator.debugFile = debugFile;
 }
Example #3
0
 public SimulationEventDistributorClient()
 {
     queueLock = new object();
     queue     = new List <SimulationEvent>();
     id        = -1;
     dist      = null;
 }
Example #4
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;

            distributor.RegisterClient(ref distClient);
            //distClient.Subscribe("NewObject");
            //distClient.Subscribe("MoveObject");
            //distClient.Subscribe("TimeTick");
            //distClient.Subscribe("ResetSimulation");

            blackboard.RegisterClient(ref bbClient);
            bbClient.Subscribe("PhysicalObject", "ID", true, false);
            bbClient.Subscribe("PhysicalObject", "Location", true, false);
            bbClient.Subscribe("PhysicalObject", "Velocity", true, false);
            bbClient.Subscribe("PhysicalObject", "Size", true, false);
            bbClient.Subscribe("PhysicalObject", "DockedToParent", true, false);
            bbClient.Subscribe("PhysicalObject", "Capability", true, false);
            bbClient.Subscribe("PhysicalObject", "Vulnerability", true, false);
            bbClient.Subscribe("PhysicalObject", "TargetsInRange", true, true);
            bbClient.Subscribe("PhysicalObject", "State", true, false);
            //bbClient.Subscribe("PhysicalObject", "MaximumSpeed", true, false);
            //bbClient.Subscribe("PhysicalObject", "Throttle", true, false);
            //bbClient.Subscribe("PhysicalObject", "DestinationLocation", true, false);
            objectProxies = new Dictionary<string, SimulationObjectProxy>();
        }
Example #5
0
 public BlackboardManagerSim()
 {
     blackboard = null;
     bbClient = null;
     distributor = null;
     distClient = null;
     simModel = null;
 }
Example #6
0
 public StaticAttributeSim()
 {
     blackboard = null;
     bbClient = null;
     distributor = null;
     distClient = null;
     simModel = null;
     objectProxies = null;
 }
Example #7
0
 public FuelHandlingSim()
 {
     time = 0;
     blackboard = null;
     bbClient = null;
     distributor = null;
     distClient = null;
     simModel = null;
     objectProxies = null;
 }
Example #8
0
 public TextChatServer(string simModelPath, ref SimulationEventDistributor distributor)
 {
     simModelName = simModelPath;
     simModelInfo = smr.readModel(simModelName);
     isRunning = false;
     roomMembership = new Dictionary<string, List<string>>();
     server = new SimulationEventDistributorClient();
     distributor.RegisterClient(ref server);
     
 }
Example #9
0
 public CollisionDetectionSim()
 {
     time = 0;
     blackboard = null;
     bbClient = null;
     distributor = null;
     distClient = null;
     simModel = null;
     objectProxies = null;
 }
Example #10
0
 public ExternalCommunicationSim()
 {
     blackboard = null;
     bbClient = null;
     distributor = null;
     distClient = null;
     simModel = null;
     objectProxies = null;
     v3 = null;
 }
Example #11
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>();
        }
Example #12
0
        public DynamicRegionSim()
        {
            time = 0;
            blackboard = null;
            bbClient = null;
            distributor = null;
            distClient = null;
            simModel = null;
            objectProxies = null;

        }
Example #13
0
 public ViewProSim()
 {
     blackboard = null;
     bbClient = null;
     distributor = null;
     distClient = null;
     simModel = null;
     objectProxies = null;
     randomSeed = 8675309;
     ZInverse.InitializeInvZTable();
     currentTick = 0;
 }
Example #14
0
 public ReplayLogger(string logsPath, string simModelPath, ref SimulationEventDistributor distributor, string mode)
 {
     logPath = logsPath;
     simModelName = simModelPath;
     simModelInfo = smr.readModel(simModelName);
     isRunning = false;
     logMode = mode;
     //server = new NetworkClient();
     //server.Connect(hostName, Convert.ToInt32(portNumber));
     cc = new SimulationEventDistributorClient();
     distributor.RegisterClient(ref cc);
 }
Example #15
0
        public AttackProcessorSim()
        {
            time = 0;
            blackboard = null;
            bbClient = null;
            distributor = null;
            distClient = null;
            simModel = null;
            objectProxies = null;
            randomSeed = 0;
            random = new Random(randomSeed);

        }
Example #16
0
        public ScoringSim()
        {
            time = 0;
            blackboard = null;
            bbClient = null;
            distributor = null;
            distClient = null;
            simModel = null;
            objectProxies = null;

            lastScore = new Dictionary<string, double>();
            //regions = new Dictionary<string, BlockingRegion>();
        }
Example #17
0
 /// <summary>
 /// The NetworkServer will be instantiated once in the DDD Server.
 /// External applications such as agents and custom GUIs should ignore this class.
 /// </summary>
 /// <param name="port"></param>
 /// <param name="dist"></param>
 public NetworkServer(int port, ref SimulationEventDistributor dist)
 {
     server = null;
     state = ServerState.STOPPING;
     eventDist = dist;
     m_serverIP = null;
     this.port = port;
     connectionListenerThread = null;
     //eventCheckerThread = null;
     clientHandlers = new List<NetworkServerConnectionHandler>();
     clientHandlersLock = new object();
     //clientCount = 0;
 }
Example #18
0
 public WhiteboardServer(string simModelPath, ref SimulationEventDistributor distributor)
 {
     simModelName = simModelPath;
     simModelInfo = smr.readModel(simModelName);
     lock (isRunningLock)
     {
         isRunning = false;
     }
     roomMembership = new Dictionary<string, List<string>>();
     roomNextObjectIndex = new Dictionary<string, int>();
     server = new SimulationEventDistributorClient();
     distributor.RegisterClient(ref server);
     
 }
Example #19
0
        public MotionSim()
        {
            time = 0;
            blackboard = null;
            bbClient = null;
            distributor = null;
            distClient = null;
            simModel = null;
            objectProxies = null;
            collisionShapes = new Dictionary<string, Polygon3D>();

            //landRegions = new Dictionary<string, LandRegion>();
            //activeRegions = new Dictionary<string, ActiveRegion>();
        }
Example #20
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;

            distributor.RegisterClient(ref distClient);
            //distClient.Subscribe("NewObject");
            //distClient.Subscribe("RevealObject");
            //distClient.Subscribe("MoveObject");
            //distClient.Subscribe("SubplatformLaunch");
            //distClient.Subscribe("WeaponLaunch");
            //distClient.Subscribe("StateChange");
            //distClient.Subscribe("ObjectCollision");
            //distClient.Subscribe("TimeTick");
            //distClient.Subscribe("SubplatformDock");
            //distClient.Subscribe("ResetSimulation");


            blackboard.RegisterClient(ref bbClient);
            bbClient.Subscribe("PhysicalObject", "ID", true, false);
            bbClient.Subscribe("PhysicalObject", "StateTable", true, false);
            bbClient.Subscribe("PhysicalObject", "State", true, false);
            bbClient.Subscribe("PhysicalObject", "OwnerID", true, false);
            bbClient.Subscribe("PhysicalObject", "Location", true, true);
            bbClient.Subscribe("PhysicalObject", "Size", true, false);
            bbClient.Subscribe("PhysicalObject", "Velocity", true, true);
            bbClient.Subscribe("PhysicalObject", "MaximumSpeed", true, false);
            bbClient.Subscribe("PhysicalObject", "Throttle", true, true);
            bbClient.Subscribe("PhysicalObject", "DestinationLocation", true, true);
            bbClient.Subscribe("PhysicalObject", "DockedToParent", true, false);
            bbClient.Subscribe("PhysicalObject", "LaunchStarted", true, false);
            bbClient.Subscribe("PhysicalObject", "LaunchEndTime", true, false);
            bbClient.Subscribe("PhysicalObject", "LaunchDone", true, true);
            bbClient.Subscribe("PhysicalObject", "LinkedRegion", true, true);
            bbClient.Subscribe("PhysicalObject", "PursueStarted", true, true);
            bbClient.Subscribe("PhysicalObject", "PursueTargetID", true, true);
            bbClient.Subscribe("PhysicalObject", "ParentObjectID", true, false);
            bbClient.Subscribe("PhysicalObject", "LaunchIsWeapon", true, false);
            bbClient.Subscribe("PhysicalObject", "LaunchWeaponTargetID", true, false);
            bbClient.Subscribe("PhysicalObject", "LaunchDestinationLocation", true, false);
            bbClient.Subscribe("PhysicalObject", "InActiveRegions", true, true);
            bbClient.Subscribe("PhysicalObject", "ActiveRegionSpeedMultiplier", true, true);

           // bbClient.Subscribe("Region", "LinkedObject", true, true);
            objectProxies = new Dictionary<string, SimulationObjectProxy>();
        }
Example #21
0
        //private Dictionary<string, Team> teams;
        //private Dictionary<string, DecisionMaker> decisionMakers;

        public SelfDefenseSim()
        {
            time = 0;
            blackboard = null;
            bbClient = null;
            distributor = null;
            distClient = null;
            simModel = null;
            objectProxies = null;
            randomSeed = 0;
            random = new Random(randomSeed);

            //teams = new Dictionary<string, Team>();
            //decisionMakers = new Dictionary<string, DecisionMaker>();
        }
Example #22
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;

            distributor.RegisterClient(ref distClient);
            blackboard.RegisterClient(ref bbClient);
            bbClient.Subscribe("PhysicalObject", "ID", true, false);
            bbClient.Subscribe("PhysicalObject", "Location", true, false);

            objectProxies = new Dictionary<string, SimulationObjectProxy>();
        }
Example #23
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;

            distributor.RegisterClient(ref distClient);
            //distClient.Subscribe("NewObject");
            //distClient.Subscribe("ResetSimulation");

            blackboard.RegisterClient(ref bbClient);
            bbClient.Subscribe("BaseObject", "ID", true, true);
            
        }
Example #24
0
 public SeamateProcessorSim()
 {
     time = 0;
     blackboard = null;
     bbClient = null;
     distributor = null;
     distClient = null;
     simModel = null;
     objectProxies = null;
     scoreRulesExist = null;
     handledAttacks = null;
     dms = null;
     classifications = null;
     _terminalToDMMap = null;
     IndividualDMIsLoggedIn = false;
     objectAssignmentList = null;
     _attackTargetHashes = null;
     mostRecentItemsForStimulators = null;
 }
Example #25
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;

            distributor.RegisterClient(ref distClient);
            //distClient.Subscribe("NewObject");
            //distClient.Subscribe("RevealObject");
            //distClient.Subscribe("StateChange");
            //distClient.Subscribe("ResetSimulation");

            blackboard.RegisterClient(ref bbClient);
            bbClient.Subscribe("BaseObject", "ID", true, false);
            bbClient.Subscribe("DecisionMaker", "RoleName", true, true);
            bbClient.Subscribe("DecisionMaker", "TeamMember", true, true);
            bbClient.Subscribe("PhysicalObject", "ObjectName", true, true);
            bbClient.Subscribe("PhysicalObject", "OwnerID", true, true);
            bbClient.Subscribe("PhysicalObject", "ClassName", true, true);
            bbClient.Subscribe("PhysicalObject", "Size", true, true);
            bbClient.Subscribe("PhysicalObject", "MaximumSpeed", true, true);
            bbClient.Subscribe("PhysicalObject", "State", true, true);
            bbClient.Subscribe("PhysicalObject", "StateTable", true, true);
            bbClient.Subscribe("PhysicalObject", "Sensors", true, true);
            bbClient.Subscribe("PhysicalObject", "Emitters", true, true);
            bbClient.Subscribe("PhysicalObject", "LaunchDuration", true, true);
            bbClient.Subscribe("PhysicalObject", "AttackDuration", true, true);
            bbClient.Subscribe("PhysicalObject", "EngagementDuration", true, true);
            bbClient.Subscribe("PhysicalObject", "DockingDuration", true, true);
            bbClient.Subscribe("PhysicalObject", "IsWeapon", true, true);
            bbClient.Subscribe("PhysicalObject", "IconName", true, true);
            bbClient.Subscribe("PhysicalObject", "RemoveOnDestruction", true, true);
            bbClient.Subscribe("PhysicalObject", "CustomAttributes", true, true);
            bbClient.Subscribe("PhysicalObject", "CanOwn", true, true);
            bbClient.Subscribe("PhysicalObject", "SubplatformLimit", true, true);
            bbClient.Subscribe("PhysicalObject", "DefaultClassification", true, true);
            bbClient.Subscribe("PhysicalObject", "ClassificationDisplayRules", true, true);
            bbClient.Subscribe("PhysicalObject", "CurrentClassification", true, true);
            objectProxies = new Dictionary<string, SimulationObjectProxy>();
        }
Example #26
0
        public Form1(string simModel, string host, string port, string user)
        {
            InitializeComponent();
            userID = user;
            hostName = host;
            portNumber = port;
            simModelName = simModel;
            simModelInfo = smr.readModel(simModelName);
            AddToTextBoxText("Welcome " + userID + ".");
            server = new NetworkClient();
            server.Connect(hostName, Convert.ToInt32(portNumber));
            SimulationEventDistributor dist = new SimulationEventDistributor(ref simModelInfo);
            SimulationEventDistributorClient cc = new SimulationEventDistributorClient();

            dist.RegisterClient(ref cc);
            server.Subscribe("TextChat");
            isRunning = true;
            waitForEventsThread = new Thread(new ThreadStart(WaitForEvents));
            waitForEventsThread.Start();

        }
Example #27
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;

            distributor.RegisterClient(ref distClient);
            //distClient.Subscribe("RevealObject");
            //distClient.Subscribe("SubplatformLaunch");
            //distClient.Subscribe("WeaponLaunch");
            //distClient.Subscribe("SubplatformDock");
            //distClient.Subscribe("TimeTick");
            //distClient.Subscribe("ResetSimulation");
            //distClient.Subscribe("StateChange");

            blackboard.RegisterClient(ref bbClient);
            bbClient.Subscribe("PhysicalObject", "ID", true, false);
            bbClient.Subscribe("PhysicalObject", "ParentObjectID", true, true);
            bbClient.Subscribe("PhysicalObject", "OwnerID", true, false);
            bbClient.Subscribe("PhysicalObject", "DockedToParent", true, true);
            bbClient.Subscribe("PhysicalObject", "ChildObjects", true, true);
            bbClient.Subscribe("PhysicalObject", "DockedObjects", true, true);
            bbClient.Subscribe("PhysicalObject", "DockedWeapons", true, true);
            bbClient.Subscribe("PhysicalObject", "LaunchStarted", true, true);
            bbClient.Subscribe("PhysicalObject", "LaunchEndTime", true, true);
            bbClient.Subscribe("PhysicalObject", "LaunchDestinationLocation", true, true);
            bbClient.Subscribe("PhysicalObject", "LaunchDone", true, false);
            bbClient.Subscribe("PhysicalObject", "LaunchDuration", true, false);
            bbClient.Subscribe("PhysicalObject", "DockingStarted", true, true);
            bbClient.Subscribe("PhysicalObject", "DockingEndTime", true, true);
            bbClient.Subscribe("PhysicalObject", "LaunchIsWeapon", true, true);
            bbClient.Subscribe("PhysicalObject", "LaunchWeaponTargetID", true, true);
            bbClient.Subscribe("PhysicalObject", "DockingDuration", true, false);
            bbClient.Subscribe("PhysicalObject", "IsWeapon", true, false);
            bbClient.Subscribe("PhysicalObject", "ClassName", true, false);

            objectProxies = new Dictionary<string, SimulationObjectProxy>();
        }
Example #28
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;

            distributor.RegisterClient(ref distClient);
            //distClient.Subscribe("NewObject");
            //distClient.Subscribe("RevealObject");
            //distClient.Subscribe("AttackObject");
            //distClient.Subscribe("RandomSeed");
            //distClient.Subscribe("TimeTick");
            //distClient.Subscribe("StateChange");
            //distClient.Subscribe("ResetSimulation");

            blackboard.RegisterClient(ref bbClient);
            bbClient.Subscribe("PhysicalObject", "ID", true, false);
            bbClient.Subscribe("PhysicalObject", "Location", true, false);
            bbClient.Subscribe("PhysicalObject", "OwnerID", true, false);
            bbClient.Subscribe("PhysicalObject", "State", true, false);
            bbClient.Subscribe("PhysicalObject", "StateTable", true, false);
            bbClient.Subscribe("PhysicalObject", "Capability", true, true);
            bbClient.Subscribe("PhysicalObject", "Vulnerability", true, true);
            bbClient.Subscribe("PhysicalObject", "AttackState", true, true);

            bbClient.Subscribe("PhysicalObject", "CurrentAttacks", true, true);
            bbClient.Subscribe("PhysicalObject", "AttackerList", true, true);
            bbClient.Subscribe("PhysicalObject", "SelfDefenseStartAttack", true, false);
            bbClient.Subscribe("PhysicalObject", "SelfDefenseCapability", true, false);
            bbClient.Subscribe("PhysicalObject", "SelfDefenseTargetID", true, false);
            bbClient.Subscribe("PhysicalObject", "IsWeapon", true, false);
            bbClient.Subscribe("PhysicalObject", "AttackDuration", true, false); //set in static att sim, true for all attacks per state per species
            bbClient.Subscribe("PhysicalObject", "EngagementDuration", true, false);
            objectProxies = new Dictionary<string, SimulationObjectProxy>();

        }
Example #29
0
        //private static List<string> listOfDMs = new List<string>();
        //public void SetListOfDMs(List<string> theList)
        //{
        //    foreach (string dm in theList)
        //    {
        //        if (!listOfDMs.Contains(dm))
        //        {
        //            listOfDMs.Add(dm);
        //        }
        //    }
        //    HandshakeManager.HandshakeManager.AvailableDMs = listOfDMs;
        //}
        //public List<string> GetListOfDMs()
        //{
        //    return listOfDMs;
        //}


        public ViewManager(string simModelPath, ref SimulationEventDistributor distributor, int numberOfSeats)
        {
            simModelName = simModelPath;
            simModelInfo = smr.readModel(simModelName);
            server = new SimulationEventDistributorClient();
            distributor.RegisterClient(ref server);

            //try
            //{
            //    server.Connect(hostName, Convert.ToInt32(portNumber));
            //}
            //catch
            //{
            //    throw new Exception("View Manager cannot connect to Network Server...");
            //}
            //networkConnectionViewer = new NetworkConnectionViewer();
            //eventStreamViewer = new EventStreamViewer();
            handshakeManager = new HandshakeManager.HandshakeManager(ref server, ref simModelInfo);
            authenticationManager = new AuthenticationManager.AuthenticationManager(ref server, ref simModelInfo, numberOfSeats);
            textChat = new TextChatStreamViewer();
            isRunning = true;
            Thread.Sleep(200);
            //HandshakeManager.HandshakeManager.AvailableDMs = listOfDMs;
        }
Example #30
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;

            distributor.RegisterClient(ref distClient);
            //distClient.Subscribe("NewObject");
            //distClient.Subscribe("RevealObject");
            //distClient.Subscribe("TimeTick");
            //distClient.Subscribe("HandshakeInitializeGUIDone");
            //distClient.Subscribe("ResetSimulation");

            blackboard.RegisterClient(ref bbClient);
            bbClient.Subscribe("PhysicalObject", "ID", true, false);
            bbClient.Subscribe("PhysicalObject", "OwnerID", true, false);
            bbClient.Subscribe("PhysicalObject", "ClassName", true, false);
            bbClient.Subscribe("PhysicalObject", "Location", true, false);
            bbClient.Subscribe("PhysicalObject", "Capability", true, false);
            bbClient.Subscribe("PhysicalObject", "Vulnerability", true, false);
            bbClient.Subscribe("PhysicalObject", "IsWeapon", true, false);
            bbClient.Subscribe("PhysicalObject", "PursueStarted", true, false);
            bbClient.Subscribe("PhysicalObject", "PursueTargetID", true, false);
            bbClient.Subscribe("PhysicalObject", "SelfDefenseStartAttack", true, true);
            bbClient.Subscribe("PhysicalObject", "SelfDefenseCapability", true, true);
            bbClient.Subscribe("PhysicalObject", "SelfDefenseTargetID", true, true);
            bbClient.Subscribe("PhysicalObject", "TargetsInRange", true, false);
            bbClient.Subscribe("PhysicalObject", "CurrentAttacks", true, false);
            bbClient.Subscribe("PhysicalObject", "AttackState", true, false);
            objectProxies = new Dictionary<string, SimulationObjectProxy>();
        }
Example #31
0
        public static void Coordinate(
            string scenarioFile,
            string schemaFile,
            ref SimulationEventDistributor distributor,
            //string hostname,
            //string portString,
            string simModelName,
            string contextControl,//*NETWORK"
            string updateIncr,
            string lowerLevel, //GUI
            List<string> logTypes,
            string debugFile
            )
        {
            /// <summary>


            debugLogger = new DebugLogger();
            //DateTime dt = DateTime.Now;
            if (!Directory.Exists(debugFile.Remove(debugFile.LastIndexOf("\\"))))
            {
                Directory.CreateDirectory(debugFile.Remove(debugFile.LastIndexOf("\\")));
            }

            DebugLogger.SetDebugStyleFile(debugFile);
            //DebugLogger.SetDebugStyle(DebugLogger.DebugStyleValues.FileReporting);
            DebugLogger.SetLoggingType("general", true);
            foreach (string s in logTypes)
            {
                DebugLogger.SetLoggingType(s, true);
                debugLogger.Writeline("Coordinator", s + " is being recorded.", "general");
            }

            // DebugLogger.SetLoggingType("all", false);


            debugLogger.Writeline("Coordinator", "Hello", "general");

            //int port = int.Parse(portString);
            SimulationModelReader smr = new SimulationModelReader();
            SimulationModelInfo simModelInfo = smr.readModel(simModelName);

            if (distributor == null)
            {
                distributor = new SimulationEventDistributor(ref simModelInfo);
            }

            //SimulationEventDistributor dist = new SimulationEventDistributor(ref simModelInfo);
            //SimulationEventDistributorClient cc = new SimulationEventDistributorClient();

            updateIncrement = simModelInfo.GetUpdateFrequency();
            int enteredIncrement = Int32.Parse(updateIncr);
            if (enteredIncrement > 0)
            {
                updateIncrement = enteredIncrement;
            }
            tickController.UpdateIncrement = updateIncrement;
            try
            {
                new ScenarioToQueues(scenarioFile, schemaFile);
                new ForkReplayToQueues(replayFile,simModelInfo);
            }
            catch (System.Exception f)
            {
                if (f.Message.StartsWith("User Cancelled"))
                {//This means a missing map or icon library, and the user wanted to stop the server.  Do not write to error log, just stop the server. 
                    throw f;
                }
                throw new ApplicationException("Failure in ScenarioToQueues: " + f.Message);
            }

            //NetworkClient c = new NetworkClient();
            SimulationEventDistributorClient distClient = new SimulationEventDistributorClient();
            distributor.RegisterClient(ref distClient);
            try
            {
                //c.Connect(hostname, port);

                EventCommunicator eventCommunicator = new EventCommunicator(ref distClient, simModelName);
                eCommReceiver = new Thread(new ThreadStart(eventCommunicator.WaitForEvents));
                eCommReceiver.CurrentCulture = new System.Globalization.CultureInfo("en-US", true);
                eCommReceiver.Start();


            }
            catch (System.Exception e)
            {
                //Coordinator.debugLogger.WriteLine("Unable to  connect");
                Coordinator.debugLogger.Writeline("Coordinator", "Error in startup: System message: "+e.Message, "general");
                MessageBox.Show("Startup error: " + e.Message);
                Application.Exit();
            }
            EventCommunicator.SendSimStartEvent();

            //dist.RegisterClient(ref cc);


            /*
             * Temporary event  watcher to allow for insertion of events from below
             */
            if (lowerLevel != "GUI")
            {
                //NetworkClient client = new NetworkClient();
                //client.Connect(hostname, port);
                /* 
                       // Tickwatcher is used only to simulate events from lower levels
                              TickWatcher sink = new TickWatcher(client, simModelName);
                              ThreadStart stub = new ThreadStart(sink.TickEventGetter);
                              Thread stubThread = new Thread(stub);
                              stubThread.Start();
                */
            }
            TimerQueueClass.SendImmediates();

            if ("NETWORK" == contextControl)
            {
                while (!readyToTick)
                {
                    Thread.Sleep(1000);
                }
                tickController.SetCallback(new Metronome.SendTimeTick(SendTimeTick));
                tickController.Start();
                while (true)
                {
                    while (pause)
                    {
                        Thread.Sleep(1000);
                    }
                    timeSlice = (timeSlice + 1) % TimeSliceIncrement;

                    //next tick will have 100ms between calls, will not handle sending time ticks, just recent incoming events.
                    //a callback will handle sending time ticks

                    TimerTicker.NextTimeSlice();
                    Thread.Sleep((int)((updateIncrement / TimeSliceIncrement) / speedFactor));
                }
            }

            Coordinator.debugLogger.Writeline("Coordinator", "The End", "general");

        }