예제 #1
0
 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);
 }
예제 #2
0
        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();
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
        public DeleteMessageCommand
        (
            ILogger <IMessageBoard> logger,
            IMessageBoard state
        )
        {
            _logger = logger
                      ?? throw new ArgumentNullException(nameof(logger));

            _state = state
                     ?? throw new ArgumentNullException(nameof(state));
        }
예제 #6
0
        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();
        }
예제 #8
0
        /// <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);
        }
예제 #9
0
파일: Program.cs 프로젝트: EkardNT/CS143B
        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);
        }
예제 #10
0
 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();
     }
 }
예제 #13
0
파일: Simulator.cs 프로젝트: EkardNT/CS143B
        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());
        }
예제 #14
0
 public TransactionExecuter(IMessageBoard messageBoard) : base(messageBoard)
 {
 }
예제 #15
0
 public DetailsViewModelUpdater(IMessageBoard messageBoard)
     : base(messageBoard)
 {
     collector = new MessageCollector <DetailsViewModelCreated, SelectedTreeViewItemChanged>(OnMessagesCollected);
 }
예제 #16
0
 public TestAgent(IMessageBoard messageBoard) : base(messageBoard)
 {
 }
예제 #17
0
 public void Setup()
 {
     messageBoard = Substitute.For <IMessageBoard>();
     testAgent    = new TestAgent(messageBoard);
 }
예제 #18
0
 public MakePostCommandHandler(IMessageBoard messageBoard)
 {
     this._messageBoard = messageBoard;
 }
예제 #19
0
 public WorkloadExecuter(IMessageBoard messageBoard) : base(messageBoard)
 {
 }
예제 #20
0
 public InformationCollector(IMessageBoard messageBoard, ScenarioContext scenarioContext, string name = null)
     : base(messageBoard, name)
 {
     this.scenarioContext = scenarioContext;
 }
예제 #21
0
 public FilePathCreator(IMessageBoard messageBoard) : base(messageBoard)
 {
 }
예제 #22
0
 public InformationDecorator(IMessageBoard messageBoard) : base(messageBoard)
 {
 }
예제 #23
0
 public InformationBroker(IMessageBoard messageBoard, CommandLineArgs args) : base(messageBoard)
 {
     this.args = args;
 }
예제 #24
0
 public JsonModelSerializer(IMessageBoard messageBoard) : base(messageBoard)
 {
 }
예제 #25
0
 public TreeItemSelector(IMessageBoard messageBoard)
     : base(messageBoard)
 {
     collector = new MessageCollector <TreeViewModelCreated, SelectedModelObjectChanged>(OnMessagesCollected);
 }
예제 #26
0
 public SelectionDirectionDecorator(IMessageBoard messageBoard)
     : base(messageBoard)
 {
 }
예제 #27
0
 public Dispatcher(ICommandRegistry commandRegistry, IOutput output, IMessageBoard messageBoard)
 {
     this.commandRegistry = commandRegistry;
     this.output = output;
     this.messageBoard = messageBoard;
 }
예제 #28
0
 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);
 }
예제 #30
0
 public ResultReporter(IMessageBoard messageBoard, IConsole console, Action terminateAction) : base(messageBoard)
 {
     this.console         = console;
     this.terminateAction = terminateAction;
 }
 public AgentModelObjectParser(IMessageBoard messageBoard) : base(messageBoard)
 {
 }
예제 #32
0
 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);
 }