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"); }
/// <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"); }
public DockingProcessorSim() { time = 0; blackboard = null; bbClient = null; distributor = null; distClient = null; simModel = null; objectProxies = null; randomSeed = 0; random = new Random(randomSeed); }
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); }
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"); }
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>(); }
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"); }
public Player() { playerThread = null; distClient = null; simModel = null; time = 0; paused = false; updateFrequency = 0; events = new List <SimulationEvent>(); loop = false; logname = null; isReady = false; replaySpeed = 1; }
//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>(); }
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>(); }
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); }
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); } } }
public void Stop() { if (playerThread != null) { playerThread.Abort(); playerThread = null; } if (distClient != null) { distClient.Disconnect(); distClient = null; } simModel = null; isReady = false; }
public HandshakeManager(ref SimulationEventDistributorClient netServ, ref SimulationModelInfo simModel) { //if server != null? dmToTerminalMap = new Dictionary <string, string>(); termToDMMap = new Dictionary <string, string>(); dmsIsReady = new Dictionary <string, bool>(); //server = new NetworkClient(); //availableDMs = new List<string>(); allDMs = new Dictionary <string, DecisionMaker>(); simModelInfo = simModel; server = netServ; listOfChatRoomCreates = new Dictionary <string, SimulationEvent>(); listOfWhiteboardRoomCreates = new Dictionary <string, SimulationEvent>(); listOfVoiceChannelCreates = new Dictionary <string, SimulationEvent>(); enableAssetTransfers = true; }
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"); }
public SimCoreServer() { ServerOptions.ReadFile(); WriteClientAppConfig(); simEngine.Initialize(ServerOptions.SimulationModelPath, ServerOptions.PortNumber); simEngine.StartSimCore(); simEngine.StartViewManager(); eventClient = new SimulationEventDistributorClient(); simEngine.simCore.distributor.RegisterClient(ref eventClient); eventClient.Subscribe("PauseScenarioRequest"); eventClient.Subscribe("ResumeScenarioRequest"); eventClient.Subscribe("LoadScenarioRequest"); eventClient.Subscribe("StopScenarioRequest"); eventClient.Subscribe("SimCoreReady"); eventClient.Subscribe("ForkReplayStarted"); eventClient.Subscribe("ForkReplayFinished"); eventClient.Subscribe("GameSpeedRequest"); //AD: UN-Removed for now }
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"); }
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; }
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>(); }
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(); }
public void StopServer() { if ((scenarioState == ScenarioState.STOPPED && replayState != ScenarioState.STOPPED) || (scenarioState != ScenarioState.STOPPED && replayState == ScenarioState.STOPPED)) { StopScenario(true); } serverState = ServerState.STOPPED; if (ServerOptions.EventLogType != "NOLOG") { simEngine.StopReplayLogger(); } simEngine.StopTextChatServer(); simEngine.StopWhiteboardServer(); simEngine.StopVoiceServer(); simEngine.StopViewManager(); simEngine.Stop(); eventClient = null; currentTime = 0; isReady = false; }
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>(); }
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>(); }
//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; }
//[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; } }
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"); }
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>(); }
private void ConnectionHandler() { NetMessage m = new NetMessage(); SimulationEvent e = null; while (true) { try { m.Receive(ref netStream); switch (m.type) { case NetMessageType.REGISTER: eventDistClient = new SimulationEventDistributorClient(); networkServer.eventDist.RegisterClient(ref eventDistClient); m_terminalID = m.TerminalID; m.type = NetMessageType.REGISTER_RESPONSE; //m.clientID = networkServer.RegisterClient(); m.clientID = eventDistClient.id; m.Send(ref netStream, m.TerminalID); break; case NetMessageType.SUBSCRIBE: eventDistClient.Subscribe(m.msg); break; case NetMessageType.EVENT: try { e = SimulationEventFactory.XMLDeserialize(m.msg); eventDistClient.PutEvent(e); } catch (Exception exc) { ErrorLog.Write(String.Format("NONFATAL Deserialize Error in NetworkServer: {0}", m.msg)); ErrorLog.Write(exc.ToString()); } //networkServer.EventFromClient(e); break; case NetMessageType.DISCONNECT: //netStream.Close(0); System.Console.WriteLine("NetworkServerConnectionHandler.ConnectionHandler:connection closed"); //netStream.Dispose(); //networkServer.RemoveClient(eventDistClient.id); sendThread.Abort(); ForceClose(); return; case NetMessageType.NONE: ErrorLog.Write(String.Format("NONFATAL Deserialize Error in NetworkServer: {0}", m.msg)); ErrorLog.Write(String.Format("TYPE: {0}; MSG: {1};", m.type, m.msg)); break; default: throw new Exception("connection handler got an invalid event"); } } catch (System.IO.IOException exc) { System.Console.WriteLine("NetworkServerConnectionHandler.ConnectionHandler:lost connection with client"); ForceClose(); return; } catch (System.ObjectDisposedException) { return; } catch (ThreadAbortException) { return; } catch (Exception exc) { MessageBox.Show("An error has occured in the Simulation Server.\nPlease email the C:\\DDDErrorLog.txt file to Aptima customer support with a description of what you were doing at the time of the error."); ErrorLog.Write(exc.ToString() + "\n"); throw new Exception(); } } }
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>(); }
//[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; } }
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("AttackSucceeded"); //distClient.Subscribe("AttackObject"); //distClient.Subscribe("WeaponLaunch"); //distClient.Subscribe("ExternalApp_SimStop"); blackboard.RegisterClient(ref bbClient); bbClient.Subscribe("PhysicalObject", "ID", true, false); bbClient.Subscribe("PhysicalObject", "Location", true, false); bbClient.Subscribe("PhysicalObject", "ParentObjectID", true, false); //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", "DockingDuration", true, true); bbClient.Subscribe("PhysicalObject", "IsWeapon", true, false); //bbClient.Subscribe("PhysicalObject", "IconName", true, true); //bbClient.Subscribe("PhysicalObject", "RemoveOnDestruction", true, true); //bbClient.Subscribe("PhysicalObject", "CustomAttributes", true, true); objectProxies = new Dictionary <string, SimulationObjectProxy>(); v3 = new V3DVTE_Publisher(); string errMsg = string.Empty; //v3.Initialize("Aptima_DDD_Test", // @"C:\svnroot\phoenix\DataFiles\v3_dvte.fed", // @"C:\svnroot\phoenix\DataFiles\v3_dvte.xml", // out errMsg); bool v3Result = v3.Initialize(ServerOptions.HLAFederationExecutionName, ServerOptions.HLAFederationFilePath, ServerOptions.HLAXMLFilePath, out errMsg); if (!v3Result) { ServerOptions.HLAExport = false; throw new Exception("Error initializing V3DVTE Publisher. " + errMsg); } List <string> interactions = new List <string>(); interactions.Add("DamageAssessment"); interactions.Add("DVTEVehicleEmbark.DVTEDisembarkResponse"); interactions.Add("WeaponFire"); interactions.Add("MunitionDetonation"); List <string> attributes = new List <string>(); attributes.Add("comment"); attributes.Add("WorldLocation"); bool bInteractions = v3.PublishInteractions(interactions); bool bObjects = v3.PublishObjectClass(_physicalEntity, attributes); bObjects = v3.PublishObjectClass(_aircraft, attributes); bObjects = v3.PublishObjectClass(_seaSurface, attributes); bObjects = v3.PublishObjectClass(_landUnit, attributes); bObjects = v3.PublishObjectClass(_munition, attributes); }