Esempio n. 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("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>();
        }
Esempio n. 2
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>();
        }
Esempio n. 3
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>();
        }
Esempio n. 4
0
        public void Start(SimulationModelInfo simModel, ref SimulationEventDistributor distributor, string logName, bool loop)
        {
            try
            {
                playerThread = new Thread(new ThreadStart(EventLoop));
                //nc = new NetworkClient();
                //nc.Connect(hostname, port);
                distClient = new SimulationEventDistributorClient();
                distributor.RegisterClient(ref distClient);
                this.simModel   = simModel;
                time            = 0;
                this.loop       = loop;
                this.logname    = logName;
                updateFrequency = simModel.simulationExecutionModel.updateFrequency;

                SimulationEvent ev = SimulationEventFactory.BuildEvent(ref simModel, "ResetSimulation");
                distClient.PutEvent(ev);
                LoadEvents(logName);

                playerThread.Start();
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Esempio n. 5
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);
 }
Esempio n. 6
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);
 }
Esempio n. 7
0
        public EventCommunicator(NetworkClient s)
        {
            server = s;
            //Dennis: This needs to be updated to your directory
            simModelInfo = smr.readModel(@"C:\SVN\NewDDD\src\DataFiles\SimulationModel.xml");
//simModelInfo = smr.readModel("SimulationModel.xml");
            SimulationEventDistributor dist = new SimulationEventDistributor(ref simModelInfo);
            SimulationEventDistributorClient cc = new SimulationEventDistributorClient();

            dist.RegisterClient(ref cc);
            server.Subscribe("MoveDone");
        }
Esempio n. 8
0
        public EventCommunicator(NetworkClient s)
        {
            server = s;
            //Dennis: This needs to be updated to your directory
            simModelInfo = smr.readModel(@"C:\SVN\NewDDD\src\DataFiles\SimulationModel.xml");
//simModelInfo = smr.readModel("SimulationModel.xml");
            SimulationEventDistributor       dist = new SimulationEventDistributor(ref simModelInfo);
            SimulationEventDistributorClient cc   = new SimulationEventDistributorClient();

            dist.RegisterClient(ref cc);
            server.Subscribe("MoveDone");
        }
Esempio n. 9
0
        /// <summary>
        /// Constructs a watcher
        /// </summary>
        /// <param name="inputDelta">Time to sleep between checking ticks</param>
        public TickWatcher(NetworkClient s, string simModel)
        {
            string simModelName = simModel;

            simModelInfo = smr.readModel(simModelName);
            server       = s;
            SimulationEventDistributor       dist = new SimulationEventDistributor(ref simModelInfo);
            SimulationEventDistributorClient cc   = new SimulationEventDistributorClient();

            dist.RegisterClient(ref cc);/////////////////
            server.Subscribe("TimeTick");
        }
Esempio n. 10
0
        protected EventListener(NetworkClient server)
        {
            myQM = QueueManager.UniqueInstance();

            SimulationModelReader smr          = new SimulationModelReader();
            SimulationModelInfo   simModelInfo = smr.readModel("SimulationModel.xml");

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

            dist.RegisterClient(ref cc);
            server.Subscribe("MoveDone");
        }
Esempio n. 11
0
        public void AddNetworkClient(NetworkClient s)
        {
            server = s;

            simModelInfo = smr.readModel("SimulationModel.xml");

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

            dist.RegisterClient(ref cc);
            server.Subscribe("MoveDone");
            server.Subscribe("MoveObjectRequest");
            server.Subscribe("AttackObjectRequest");
        }
Esempio n. 12
0
        protected EventListener(NetworkClient server)
        {
            myQM = QueueManager.UniqueInstance();

            SimulationModelReader smr = new SimulationModelReader();
            SimulationModelInfo simModelInfo = smr.readModel("SimulationModel.xml");

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

            dist.RegisterClient(ref cc);
            server.Subscribe("MoveDone");

        }
Esempio n. 13
0
        public void AddNetworkClient(NetworkClient s)
        {
            server = s;

            simModelInfo = smr.readModel("SimulationModel.xml");

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

            dist.RegisterClient(ref cc);
            server.Subscribe("MoveDone");
            server.Subscribe("MoveObjectRequest");
            server.Subscribe("AttackObjectRequest");
        }
Esempio n. 14
0
        private void InitializeDistributor()
        {
            distributor = new SimulationEventDistributor(ref simModelInfo);
            distClient  = new SimulationEventDistributorClient();
            distributor.RegisterClient(ref distClient);


            foreach (Aptima.Asim.DDD.CommonComponents.SimulationModelTools.EventInfo e in simModelInfo.eventModel.events.Values)
            {
                if (e.simCoreSubscribe)
                {
                    distClient.Subscribe(e.name);
                }
            }
        }
Esempio n. 15
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);
        }
Esempio n. 16
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>();
        }
Esempio n. 17
0
        static void Main(string[] args)
        {
            string scenarioFile = args[0];

            new ScenarioToQueues(scenarioFile);
            //           string hostname = "dgeller";
            string hostname = args[1];
//            int port = 9999;
            int port = int.Parse(args[2]);
            //           string simModelName = "SimulationModel.xml";
            string        simModelName = args[3];
            NetworkClient c            = new NetworkClient();

            c.Connect(hostname, port);
            EventCommunicator eventCommunicator = new EventCommunicator(c);

            SimulationModelReader smr          = new SimulationModelReader();
            SimulationModelInfo   simModelInfo = smr.readModel(simModelName);

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

            dist.RegisterClient(ref cc);



            sink = new Watcher(400);
            ThreadStart stub       = new ThreadStart(sink.WatcherThread);
            Thread      stubThread = new Thread(stub);

            stubThread.Start();


            for (int i = 0; i < 5; i++) // in test the move happens at time 2
            {
                TimerTicker.NextTick();
            }
            IncomingList.Add(new MoveComplete_Event("UNIT0"));
            for (int i = 0; i < 2; i++)
            {
                TimerTicker.NextTick();
            }

            Console.WriteLine("The end");
        }
Esempio n. 18
0
        static void Main(string[] args)
        {
            string scenarioFile = args[0];
            new ScenarioToQueues(scenarioFile);
 //           string hostname = "dgeller";
            string hostname=args[1];
//            int port = 9999;
            int port = int.Parse(args[2]);
 //           string simModelName = "SimulationModel.xml";
            string simModelName = args[3];
            NetworkClient c = new NetworkClient();
            c.Connect(hostname, port);
            EventCommunicator eventCommunicator = new EventCommunicator(c);

            SimulationModelReader smr = new SimulationModelReader();
            SimulationModelInfo simModelInfo = smr.readModel(simModelName);

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

            dist.RegisterClient(ref cc);



            sink = new Watcher(400);
            ThreadStart stub = new ThreadStart(sink.WatcherThread);
            Thread stubThread = new Thread(stub);
            stubThread.Start();


            for (int i = 0; i < 5; i++) // in test the move happens at time 2
            {
                TimerTicker.NextTick();
            }
            IncomingList.Add(new MoveComplete_Event("UNIT0"));
            for (int i = 0; i < 2; i++)
            {
                TimerTicker.NextTick();
            }
 
            Console.WriteLine("The end");


        }
Esempio n. 19
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>();
        }
Esempio n. 20
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();
        }
Esempio n. 21
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>();
        }
Esempio n. 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);
            //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>();
        }
Esempio n. 23
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;
        }
Esempio n. 24
0
        //[STAThread]
        static void Main(string[] args)
        {
            string hostname     = args[0];
            int    port         = Int32.Parse(args[1]);
            string simModelName = args[2];

            SimulationModelReader smr          = new SimulationModelReader();
            SimulationModelInfo   simModelInfo = smr.readModel(simModelName);

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

            dist.RegisterClient(ref cc);
            cc.Subscribe("ALL");

            ScenarioReader scenarioReader = new ScenarioReader();
            QueueManager   queueManager   = QueueManager.UniqueInstance();



            c = new NetworkClient();
            c.Connect(hostname, port);
            EventListener myEL = EventListener.UniqueInstance(c);
            int           t    = 0;
            int           dt   = simModelInfo.simulationExecutionModel.updateFrequency;

            SimulationEvent tick = SimulationEventFactory.BuildEvent(ref simModelInfo, "TimeTick");

            ((IntegerValue)tick["Time"]).value = t;

            ConsoleKeyInfo cki;

            //Console.TreatControlCAsInput = false;  //This explodes my code for some reason, but is in Gabe's client code and works fine, what does it do?
            Console.CancelKeyPress += new ConsoleCancelEventHandler(MyExitHandler);

            List <SimulationEvent> events = null;

            while (c.IsConnected() && queueManager.count() > 0)
            {
                //Read incoming events queue
                //if any events deal with a conditional event, remove the conditional
                //event from the conditional list, and place it onto the event queue
                //if a unit dies, remove them from the event queue and condition list

                while (c.IsConnected() && !(queueManager.eventsAtTime(t)))
                {
                    events = c.GetEvents();
                    foreach (SimulationEvent e in events)
                    {
                        if (e.eventType == "MoveDone")
                        {
                            c.PutEvent(myEL.MoveDoneReceived(e, simModelInfo, tick));
                        }

                        System.Console.WriteLine(SimulationEventFactory.XMLSerialize(e));
                    }



                    ((IntegerValue)tick["Time"]).value = t;
                    c.PutEvent(tick);
                    //Console.WriteLine("Sending...");
                    //Console.WriteLine(SimulationEventFactory.XMLSerialize(tick));
                    Thread.Sleep(dt);

                    t += dt;
                }

                if (c.IsConnected())
                {
                    QueueManager.sendEventsAtTime(t, c);
                    ((IntegerValue)tick["Time"]).value = t;
                    c.PutEvent(tick);
                    //Console.WriteLine("Sending...");
                    //Console.WriteLine(SimulationEventFactory.XMLSerialize(e));
                    t += dt;
                }
            }

            while (c.IsConnected())
            {
                ((IntegerValue)tick["Time"]).value = t;
                c.PutEvent(tick);
                //Console.WriteLine("Sending...");
                //Console.WriteLine(SimulationEventFactory.XMLSerialize(tick));
                Thread.Sleep(dt);

                t += dt;
            }
        }
Esempio n. 25
0
        public void Initialize(ref CommonComponents.SimulationModelTools.SimulationModelInfo simModel, ref CommonComponents.SimulationObjectTools.Blackboard blackboard, ref CommonComponents.SimulationEventTools.SimulationEventDistributor distributor)
        {
            IndividualDMIsLoggedIn = false;
            this.blackboard        = blackboard;
            this.bbClient          = new BlackboardClient();
            this.distributor       = distributor;
            this.distClient        = new SimulationEventDistributorClient();
            this.simModel          = simModel;
            scoreRulesExist        = new Dictionary <string, bool>();
            handledAttacks         = new List <string>();
            classifications        = new Dictionary <string, string>();
            _terminalToDMMap       = new Dictionary <string, string>();
            dms = new List <string>();
            objectAssignmentList          = new Dictionary <string, string>();
            mostRecentItemsForStimulators = new Dictionary <string, ItemInfo>();
            _attackTargetHashes           = new List <string>();
            dms.Add("BAMS DM");
            dms.Add("Firescout DM");
            dms.Add("Individual DM");
            distributor.RegisterClient(ref distClient);

            blackboard.RegisterClient(ref bbClient);
            //only need to register for attributes we're concerned with: ID, OwnerID, Location, DefaultClassification
            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", "ClassName", true, false);

            bbClient.Subscribe("PhysicalObject", "DefaultClassification", true, false);
            bbClient.Subscribe("PhysicalObject", "CurrentClassification", true, false); //this might not be sent to simulators, only DDD Clients
            bbClient.Subscribe("PhysicalObject", "InActiveRegions", true, false);
            bbClient.Subscribe("PhysicalObject", "DestinationLocation", true, false);
            bbClient.Subscribe("PhysicalObject", "Intent", true, true);


            #region Attributes Specifically For SEAMATE
            bbClient.Subscribe("PhysicalObject", "RevealTime", true, true);    //int
            bbClient.Subscribe("PhysicalObject", "DetectTime", true, true);    //int
            bbClient.Subscribe("PhysicalObject", "IdentifyTime", true, true);  //int
            bbClient.Subscribe("PhysicalObject", "TrackingTime", true, true);  //int, not sure how this will be changed yet.
            bbClient.Subscribe("PhysicalObject", "DestroyedTime", true, true); //int
            bbClient.Subscribe("PhysicalObject", "TrackedBy", true, true);
            bbClient.Subscribe("PhysicalObject", "DestroyedBy", true, true);
            bbClient.Subscribe("PhysicalObject", "IdentifiedBy", true, true);
            bbClient.Subscribe("PhysicalObject", "ClassifiedBy", true, true);
            bbClient.Subscribe("PhysicalObject", "DetectedBy", true, true);

            /*
             * GroundTruthIFF is either "Hostile", "Unknown", or "Friendly".  On reveal, everything should be set to Unknown.
             * If this object attacks any sea vessel, it should be set to "Hostile".
             * UserClassifiedIFF is either "Hostile", "Unknown", or "Friendly", and is set when a user classifies an object.
             * This is their PERCEIVED friendliness of an object.
             */
            bbClient.Subscribe("PhysicalObject", "GroundTruthIFF", true, true);     //string
            bbClient.Subscribe("PhysicalObject", "UserClassifiedIFF", true, true);  //string
            bbClient.Subscribe("PhysicalObject", "HostileActionTime", true, true);  //int
            bbClient.Subscribe("PhysicalObject", "IsInSeaLane", true, true);        //bool
            bbClient.Subscribe("PhysicalObject", "IsGoingTowardsPort", true, true); //bool

            #endregion

            objectProxies = new Dictionary <string, SimulationObjectProxy>();
        }
Esempio n. 26
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");
        }
Esempio n. 27
0
        //[STAThread]
        static void Main(string[] args)
        {
            string hostname = args[0];
            int port = Int32.Parse(args[1]);
            string simModelName = args[2];

            SimulationModelReader smr = new SimulationModelReader();
            SimulationModelInfo simModelInfo = smr.readModel(simModelName);

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

            dist.RegisterClient(ref cc);
            cc.Subscribe("ALL");

            ScenarioReader scenarioReader = new ScenarioReader();
            QueueManager queueManager = QueueManager.UniqueInstance();

            

            c = new NetworkClient();
            c.Connect(hostname, port);
            EventListener myEL = EventListener.UniqueInstance(c);
            int t = 0;
            int dt = simModelInfo.simulationExecutionModel.updateFrequency;

            SimulationEvent tick = SimulationEventFactory.BuildEvent(ref simModelInfo, "TimeTick");
            ((IntegerValue)tick["Time"]).value = t;

            ConsoleKeyInfo cki;
            //Console.TreatControlCAsInput = false;  //This explodes my code for some reason, but is in Gabe's client code and works fine, what does it do?
            Console.CancelKeyPress += new ConsoleCancelEventHandler(MyExitHandler);

            List<SimulationEvent> events = null;

            while (c.IsConnected() && queueManager.count() > 0)
            {

                //Read incoming events queue
                //if any events deal with a conditional event, remove the conditional
                //event from the conditional list, and place it onto the event queue
                //if a unit dies, remove them from the event queue and condition list

                while (c.IsConnected() && !(queueManager.eventsAtTime(t)))
                {
                    events = c.GetEvents();
                    foreach (SimulationEvent e in events)
                    {
                        if (e.eventType == "MoveDone")
                            c.PutEvent(myEL.MoveDoneReceived(e, simModelInfo, tick));

                        System.Console.WriteLine(SimulationEventFactory.XMLSerialize(e));
                    }



                    ((IntegerValue)tick["Time"]).value = t;
                    c.PutEvent(tick);
                    //Console.WriteLine("Sending...");
                    //Console.WriteLine(SimulationEventFactory.XMLSerialize(tick));
                    Thread.Sleep(dt);

                    t += dt;
                }

                if (c.IsConnected())
                {
                    QueueManager.sendEventsAtTime(t, c);
                    ((IntegerValue)tick["Time"]).value = t;
                    c.PutEvent(tick);
                    //Console.WriteLine("Sending...");
                    //Console.WriteLine(SimulationEventFactory.XMLSerialize(e));
                    t += dt;
                }
                


            }

            while (c.IsConnected())
            {
                ((IntegerValue)tick["Time"]).value = t;
                c.PutEvent(tick);
                //Console.WriteLine("Sending...");
                //Console.WriteLine(SimulationEventFactory.XMLSerialize(tick));
                Thread.Sleep(dt);

                t += dt;
            }
        }
Esempio n. 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);

            blackboard.RegisterClient(ref bbClient);
            bbClient.Subscribe("PhysicalObject", "ID", true, false);
            bbClient.Subscribe("PhysicalObject", "State", true, false);
            bbClient.Subscribe("PhysicalObject", "OwnerID", true, false);
            bbClient.Subscribe("PhysicalObject", "Location", true, false);
            bbClient.Subscribe("PhysicalObject", "DockedToParent", true, false);

            ScoringDB.Score s = new ScoringDB.Score("DEFENSE", null, null, 1000);
            s.calculateDMs = new List <string>();
            s.calculateDMs.Add("BluePlayer01");
            s.calculateDMs.Add("BluePlayer02");
            s.displayDMs = s.calculateDMs;


            s.rules.Add(new ScoringDB.ScoringRule(new ScoringDB.ActorInfo(new ScoringDB.ActorInfo.OwnerInfo(ScoringDB.ActorInfo.OwnerInfo.OwnerType.HostileDM),
                                                                          new ScoringDB.ActorInfo.IdentifierInfo(ScoringDB.ActorInfo.IdentifierInfo.IdentifierType.Any, ""),
                                                                          new ScoringDB.ActorInfo.LocationInfo(ScoringDB.ActorInfo.LocationInfo.LocationType.Anywhere, "")),
                                                  new ScoringDB.ConditionInfo(ScoringDB.ConditionInfo.ConditionType.ObjectExists, "", ""),
                                                  null,
                                                  -1));

            /*
             * s.rules.Add(new ScoringDB.ScoringRule(new ScoringDB.ActorInfo(new ScoringDB.ActorInfo.OwnerInfo(ScoringDB.ActorInfo.OwnerInfo.OwnerType.Myself),
             *                                                            new ScoringDB.ActorInfo.IdentifierInfo(ScoringDB.ActorInfo.IdentifierInfo.IdentifierType.Any, ""),
             *                                                            new ScoringDB.ActorInfo.LocationInfo(ScoringDB.ActorInfo.LocationInfo.LocationType.Anywhere, "")),
             *                                    new ScoringDB.ConditionInfo(ScoringDB.ConditionInfo.ConditionType.StateChange, "Dead"),
             *                                    new ScoringDB.ActorInfo(new ScoringDB.ActorInfo.OwnerInfo(ScoringDB.ActorInfo.OwnerInfo.OwnerType.HostileDM),
             *                                                            new ScoringDB.ActorInfo.IdentifierInfo(ScoringDB.ActorInfo.IdentifierInfo.IdentifierType.Any, ""),
             *                                                            new ScoringDB.ActorInfo.LocationInfo(ScoringDB.ActorInfo.LocationInfo.LocationType.Anywhere, "")),
             *                                    200));
             * s.rules.Add(new ScoringDB.ScoringRule(new ScoringDB.ActorInfo(new ScoringDB.ActorInfo.OwnerInfo(ScoringDB.ActorInfo.OwnerInfo.OwnerType.Myself),
             *                                                            new ScoringDB.ActorInfo.IdentifierInfo(ScoringDB.ActorInfo.IdentifierInfo.IdentifierType.Any, ""),
             *                                                            new ScoringDB.ActorInfo.LocationInfo(ScoringDB.ActorInfo.LocationInfo.LocationType.Anywhere, "")),
             *                                    new ScoringDB.ConditionInfo(ScoringDB.ConditionInfo.ConditionType.StateChange, "PartlyFunctional"),
             *                                    new ScoringDB.ActorInfo(new ScoringDB.ActorInfo.OwnerInfo(ScoringDB.ActorInfo.OwnerInfo.OwnerType.FriendlyDM),
             *                                                            new ScoringDB.ActorInfo.IdentifierInfo(ScoringDB.ActorInfo.IdentifierInfo.IdentifierType.Any, ""),
             *                                                            new ScoringDB.ActorInfo.LocationInfo(ScoringDB.ActorInfo.LocationInfo.LocationType.Anywhere, "")),
             *                                    -300));
             * s.rules.Add(new ScoringDB.ScoringRule(new ScoringDB.ActorInfo(new ScoringDB.ActorInfo.OwnerInfo(ScoringDB.ActorInfo.OwnerInfo.OwnerType.HostileDM),
             *                                                            new ScoringDB.ActorInfo.IdentifierInfo(ScoringDB.ActorInfo.IdentifierInfo.IdentifierType.Any, ""),
             *                                                            new ScoringDB.ActorInfo.LocationInfo(ScoringDB.ActorInfo.LocationInfo.LocationType.Anywhere, "")),
             *                                    new ScoringDB.ConditionInfo(ScoringDB.ConditionInfo.ConditionType.StateChange, "Dead"),
             *                                    new ScoringDB.ActorInfo(new ScoringDB.ActorInfo.OwnerInfo(ScoringDB.ActorInfo.OwnerInfo.OwnerType.Myself),
             *                                                            new ScoringDB.ActorInfo.IdentifierInfo(ScoringDB.ActorInfo.IdentifierInfo.IdentifierType.Any, ""),
             *                                                            new ScoringDB.ActorInfo.LocationInfo(ScoringDB.ActorInfo.LocationInfo.LocationType.Anywhere, "")),
             *                                    -1000));
             */

            //ScoringDB.scores["DEFENSE"] = s;

            objectProxies = new Dictionary <string, SimulationObjectProxy>();
        }