public ModelCommandExecuter(IMessageBoard messageBoard) : base(messageBoard) { addAgentCollector = new MessageCollector <AddAgentRequested, ModelVersionCreated>(OnMessagesCollected); addMessageCollector = new MessageCollector <AddMessageRequested, ModelVersionCreated>(OnMessagesCollected); addInterceptorCollector = new MessageCollector <AddInterceptorAgentRequested, ModelVersionCreated>(OnMessagesCollected); addDecoratorCollector = new MessageCollector <AddMessageDecoratorRequested, ModelVersionCreated>(OnMessagesCollected); }
private void Start <T>() where T : TestBaseModule, new () { //Create container using ManualResetEventSlim initializedTrigger = new(false); scenarioContext.Set(initializedTrigger, StringConstants.InitializedMessageReceived); ContainerBuilder builder = new(); builder.RegisterModule <T>(); builder.RegisterInstance(scenarioContext); IContainer container = builder.Build(); //Start agent community Action startAction = () => { IMessageBoard messageBoard = container.Resolve <IMessageBoard>(); Agent[] agents = container.Resolve <IEnumerable <Agent> >().ToArray(); messageBoard.Register(agents); messageBoard.Start(); scenarioContext.Set(container); scenarioContext.Set(messageBoard); scenarioContext.Set(container.Resolve <FileSystemSimulator>()); }; startAction.Should().NotThrow <Exception>("agent community was not created."); initializedTrigger.Wait(); }
public void Create(string name, string password) { isCreated = true; messageTypeDescriptor = new MessageTypeDescriptor(); var xmlMessage = string.Format(Messages.MessageTypeDescriptor, name, password); messageTypeDescriptor.Xml = xmlMessage; messageBoard = MessageBoardFactory.CreateMessageBoardFromDefaultCatalogFile(); messageBoard.RoutingCatalogPersist.LoadFrom(CatalogPath); }
public NotifyComResponse Invoke(INotifyObject notifyObject) { while (!IsProcessCompleted) { System.Threading.Thread.Sleep(200); } lock (LockObj) { IsProcessCompleted = false; NotifyComResponse response = null; response = new NotifyComResponse(); try { LogBook.Write("Executing Invoke Method for Sensor: " + notifyObject.NotifierSettings["SensorAlarmID"].ToStr()); //get the message board instance IMessageBoard messageBoard = GetMessageBoard(notifyObject); //invoke display message method messageBoard.DisplayMessage(notifyObject.NotificationData.ToStr()); response.IsSucceeded = true; response.IsError = false; if (notifyObject.NotifierSettings["ClearMessage"].ToBoolean() || notifyObject.NotifierSettings["IsDynamicNotificationCleared"].ToBoolean()) { response.ResponseContent = "Clearing message from message board: [" + notifyObject.NotifierSettings["Name"].ToStr() + "] " + (notifyObject.NotifierSettings["IsNetworkConnected"].ToBoolean() == true ? "IP:" : "COM") + notifyObject.NotifierSettings["IpAddress"].ToStr() + ":" + notifyObject.NotifierSettings["Port"] + "."; } else { response.ResponseContent = "Message to: [" + notifyObject.NotifierSettings["Name"].ToStr() + "] " + (notifyObject.NotifierSettings["IsNetworkConnected"].ToBoolean() == true ? "IP:" : "COM") + notifyObject.NotifierSettings["IpAddress"].ToStr() + ":" + notifyObject.NotifierSettings["Port"] + " sent successfully."; } IsProcessCompleted = true; } catch (Exception ex) { IsProcessCompleted = true; response.IsSucceeded = false; response.IsError = true; if (notifyObject.NotifierSettings["ClearMessage"].ToBoolean() || notifyObject.NotifierSettings["IsDynamicNotificationCleared"].ToBoolean()) { response.ResponseContent = "Clearing message from message board: [" + notifyObject.NotifierSettings["Name"].ToStr() + "] " + (notifyObject.NotifierSettings["IsNetworkConnected"].ToBoolean() == true ? "IP:" : "COM") + notifyObject.NotifierSettings["IpAddress"].ToStr() + ":" + notifyObject.NotifierSettings["Port"] + " failed."; } else { response.ResponseContent = "Message to: [" + notifyObject.NotifierSettings["Name"].ToStr() + "] " + (notifyObject.NotifierSettings["IsNetworkConnected"].ToBoolean() == true ? "IP:" : "COM") + notifyObject.NotifierSettings["IpAddress"].ToStr() + ":" + notifyObject.NotifierSettings["Port"] + " Failed."; } LogBook.Write(ex, "CooperAtkins.NotificationServer.NotifyEngine.MessageBoardNotifyCom"); } return(response); } }
public DeleteMessageCommand ( ILogger <IMessageBoard> logger, IMessageBoard state ) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _state = state ?? throw new ArgumentNullException(nameof(state)); }
public void Setup() { messageBoard = new MessageBoard(); SpinWaiter waiter = new SpinWaiter(messageBoard, () => finishedEvent.Set(), false); messageBoard.Register(waiter); messageBoard.Start(); File.Delete("log.json"); Log.Logger = new LoggerConfiguration() .MinimumLevel.Verbose() .WriteTo.Async(l => l.File(new CompactJsonFormatter(), "log.json")) .CreateLogger(); }
public void Setup() { ContainerBuilder builder = new ContainerBuilder(); builder.RegisterModule(new ParallelThreadSleepModule(() => { finishedEvent.Set(); })); container = builder.Build(); messageBoard = container.Resolve <IMessageBoard>(); Agent[] agents = container.Resolve <IEnumerable <Agent> >().ToArray(); messageBoard.Register(agents); messageBoard.Start(); }
/// <summary> /// Get the message board instance based on the boardtype /// </summary> /// <param name="boardType"></param> /// <returns></returns> private IMessageBoard GetMessageBoard(INotifyObject notifyObject) { IMessageBoard msgBoard = null; int boardType = notifyObject.NotifierSettings["BoardType"].ToInt(); switch (((MessageBoardType)boardType).ToStr()) { case "MB_Unknown": break; case "MB_215C": msgBoard = new MsgBrd215C(); msgBoard.BoardType = MessageBoardType.MB_215C; break; case "MB_BetaBrite": msgBoard = new MsgBrdBetaBrite(); msgBoard.BoardType = MessageBoardType.MB_BetaBrite; break; } msgBoard.COMMSettings = notifyObject.NotifierSettings["COMSettings"].ToStr().Replace('8', '7'); msgBoard.Name = notifyObject.NotifierSettings["Name"].ToStr(); msgBoard.IPAddress = notifyObject.NotifierSettings["IpAddress"].ToStr(); msgBoard.Port = notifyObject.NotifierSettings["Port"].ToInt(); msgBoard.IsNetworkAttached = notifyObject.NotifierSettings["IsNetworkConnected"].ToBoolean(); msgBoard.IsGroup = notifyObject.NotifierSettings["IsGroup"].ToBoolean(); msgBoard.IsEnabled = notifyObject.NotifierSettings["IsEnabled"].ToBoolean(); msgBoard.SensorAlarmID = notifyObject.NotifierSettings["SensorAlarmID"].ToStr(); msgBoard.SensorFactoryID = (notifyObject.NotifierSettings["SensorFactoryID"] != null) ? notifyObject.NotifierSettings["SensorFactoryID"].ToStr() : ""; /* added on 02/28/2011 to server time for the first time. */ if (notifyObject.NotifierSettings.ContainsKey("SetServerTime")) { msgBoard.SetServerTime = notifyObject.NotifierSettings["SetServerTime"].ToBoolean(); } //add new for multiple message board issue on 02/16/2011 msgBoard.ID = notifyObject.NotifierSettings["NotifyID"].ToInt(); if (notifyObject.NotifierSettings["IsDynamicNotificationCleared"] != null) { msgBoard.IsDynamicNotificationCleared = notifyObject.NotifierSettings["IsDynamicNotificationCleared"].ToBoolean(); } else { msgBoard.IsDynamicNotificationCleared = null; } return(msgBoard); }
public Program( IInput input, IOutput output, IMessageBoard messageBoard, IDispatcher dispatcher, ISimulator simulator) { this.input = input; this.output = output; this.dispatcher = dispatcher; this.simulator = simulator; messageBoard.Receive<QuitCommand>(OnQuit); }
public void Setup() { { messageBoard = new MessageBoard(); SpinWaiter waiter = new SpinWaiter(messageBoard, () => finishedEvent.Set(), false); messageBoard.Register(waiter); messageBoard.Start(); } { messageBoardReuse = new MessageBoard(); SpinWaiter waiter = new SpinWaiter(messageBoardReuse, () => finishedEventReuse.Set(), true); messageBoardReuse.Register(waiter); messageBoardReuse.Start(); } }
public UpdateMessageCommand ( IClock clock, ILogger <IMessageBoard> logger, IMessageBoard state ) { _clock = clock ?? throw new ArgumentNullException(nameof(clock)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _state = state ?? throw new ArgumentNullException(nameof(state)); }
private void SetupCommunities() { { ContainerBuilder builder = new ContainerBuilder(); builder.RegisterModule(new FileManipulationModule(() => { finishedEvent.Set(); })); container = builder.Build(); messageBoard = container.Resolve <IMessageBoard>(); Agent[] agents = container.Resolve <IEnumerable <Agent> >().ToArray(); messageBoard.Register(agents); messageBoard.Start(); } { ContainerBuilder builder = new ContainerBuilder(); builder.RegisterModule(new ParallelForEachModule(() => { parallelForEachFinishedEvent.Set(); })); parallelForEachContainer = builder.Build(); parallelForEachMessageBoard = parallelForEachContainer.Resolve <IMessageBoard>(); Agent[] agents = parallelForEachContainer.Resolve <IEnumerable <Agent> >().ToArray(); parallelForEachMessageBoard.Register(agents); parallelForEachMessageBoard.Start(); } }
public Simulator(IOutput output, IMessageBoard messageBoard) { this.output = output; messageBoard.Receive<InitCommand>(OnInit); messageBoard.Receive<CreateCommand>(OnCreate); messageBoard.Receive<DestroyCommand>(OnDestroy); messageBoard.Receive<RequestCommand>(OnRequest); messageBoard.Receive<ReleaseCommand>(OnRelease); messageBoard.Receive<TimeoutCommand>(OnTimeout); messageBoard.Receive<RequestIOCommand>(OnRequestIO); messageBoard.Receive<CompleteIOCommand>(OnCompleteIO); messageBoard.Receive<ShowProcessCommand>(OnShowProcess); messageBoard.Receive<ShowResourceCommand>(OnShowResource); messageBoard.Receive<DebugCommand>(OnDebug); // Create simulation state. readyQueue = new Node<Process>[3]; resources = new Dictionary<string, Resource>(); processes = new Dictionary<string, Process>(); // Initialize simulation to default state. messageBoard.Send(new InitCommand()); }
public TransactionExecuter(IMessageBoard messageBoard) : base(messageBoard) { }
public DetailsViewModelUpdater(IMessageBoard messageBoard) : base(messageBoard) { collector = new MessageCollector <DetailsViewModelCreated, SelectedTreeViewItemChanged>(OnMessagesCollected); }
public TestAgent(IMessageBoard messageBoard) : base(messageBoard) { }
public void Setup() { messageBoard = Substitute.For <IMessageBoard>(); testAgent = new TestAgent(messageBoard); }
public MakePostCommandHandler(IMessageBoard messageBoard) { this._messageBoard = messageBoard; }
public WorkloadExecuter(IMessageBoard messageBoard) : base(messageBoard) { }
public InformationCollector(IMessageBoard messageBoard, ScenarioContext scenarioContext, string name = null) : base(messageBoard, name) { this.scenarioContext = scenarioContext; }
public FilePathCreator(IMessageBoard messageBoard) : base(messageBoard) { }
public InformationDecorator(IMessageBoard messageBoard) : base(messageBoard) { }
public InformationBroker(IMessageBoard messageBoard, CommandLineArgs args) : base(messageBoard) { this.args = args; }
public JsonModelSerializer(IMessageBoard messageBoard) : base(messageBoard) { }
public TreeItemSelector(IMessageBoard messageBoard) : base(messageBoard) { collector = new MessageCollector <TreeViewModelCreated, SelectedModelObjectChanged>(OnMessagesCollected); }
public SelectionDirectionDecorator(IMessageBoard messageBoard) : base(messageBoard) { }
public Dispatcher(ICommandRegistry commandRegistry, IOutput output, IMessageBoard messageBoard) { this.commandRegistry = commandRegistry; this.output = output; this.messageBoard = messageBoard; }
public ExceptionConsoleWriter(IMessageBoard messageBoard, IConsole console, Action terminateAction) : base(messageBoard) { this.console = console; this.terminateAction = terminateAction; }
public ModelAnalyser(IMessageBoard messageBoard) : base(messageBoard) { collector = new MessageCollector <GenerateFilesRequested, ModelVersionCreated>(OnMessagesCollected); }
public ResultReporter(IMessageBoard messageBoard, IConsole console, Action terminateAction) : base(messageBoard) { this.console = console; this.terminateAction = terminateAction; }
public AgentModelObjectParser(IMessageBoard messageBoard) : base(messageBoard) { }
public MainWindowDataContextProvider(IMessageBoard messageBoard) : base(messageBoard) { collector = new MessageCollector <GraphViewModelCreated, MainWindowCreated, TreeViewModelCreated, DetailsViewModelCreated, SearchViewModelCreated>(OnMessagesCollected); }
public MessageViewModelUpdater(IMessageBoard messageBoard) : base(messageBoard) { collector = new MessageCollector <TreeViewModelCreated, ModifyModel>(OnMessagesCollected); }