Ejemplo n.º 1
0
        public void Start()
        {
            this.portMonitor = new PortMonitor();

            IpcHandler ipcHandler = new IpcHandler();
            ipcHandler.AddMonitorPort += new IpcHandler.AddMonitorPortEventHandler(portMonitor.AddPort);
            ipcHandler.DeleteMonitorPort += new IpcHandler.DeleteMonitorPortEventHandler(portMonitor.DeletePort);
            ipcHandler.OpenMonitorPort += new IpcHandler.OpenMonitorPortEventHandler(portMonitor.OpenPort);
            ipcHandler.CloseMonitorPort += new IpcHandler.CloseMonitorPortEventHandler(portMonitor.ClosePort);
            ipcHandler.StartDocMonitorPort += new IpcHandler.StartDocMonitorPortEventHandler(portMonitor.StartDoc);
            ipcHandler.EndDocMonitorPort += new IpcHandler.EndDocMonitorPortEventHandler(portMonitor.EndDoc);
            ipcHandler.WriteMonitorPort +=new IpcHandler.WriteMonitorPortEventHandler(portMonitor.Write);

            this.pipeServer = new PipeServer(ipcHandler);
            //this.pipeServer.ClientConnected += new PipeServer.ClientConnectedEventHandler(this.ClientConnected);
            //this.pipeServer.ReadCompleted += new PipeServer.ReadCompletedEventHandler(this.ReadCompleted);
            //this.pipeServer.WriteCompleted += new PipeServer.WriteCompletedEventHandler(this.WriteCompleted);

            this.pipeServer.Start();

            while (this.pipeServer.Step())
            {
            // could do some other work here
            }

            // fixme: dispose pipeServer?
        }
Ejemplo n.º 2
0
        public void Transmit(byte[] frame)
        {
            if (PortMonitor.Enabled)
            {
                PortMonitor.Add(rx: false, data: frame);
            }

            DoTransmit(frame);
        }
Ejemplo n.º 3
0
        public void Uninstall_Ignore()
        {
            var src = new PortMonitor("Dummy Monitor", true);

            Assert.That(src.Exists, Is.False);

            src.FileName = "DummyMon.dll";
            src.Config   = "DummyMonUi.dll";
            Assert.DoesNotThrow(() => src.Uninstall());
        }
Ejemplo n.º 4
0
 public bool Create(string name, string filename) => Invoke(() =>
 {
     var src = new PortMonitor(name);
     Assert.That(src.Name.Unify(), Is.EqualTo(name));
     Assert.That(src.FileName.Unify(), Is.EqualTo(filename));
     Assert.That(src.Config.HasValue(), Is.False, nameof(src.Config));
     Assert.That(src.Environment.HasValue(), Is.True, nameof(src.Environment));
     Assert.That(src.DirectoryName.HasValue(), Is.True, nameof(src.DirectoryName));
     return(src.Exists);
 });
Ejemplo n.º 5
0
 /* ----------------------------------------------------------------- */
 ///
 /// Log
 ///
 /// <summary>
 /// Puts debug information to the log file.
 /// </summary>
 ///
 /// <param name="src">Port monitor object.</param>
 /// <param name="method">Method name.</param>
 ///
 /* ----------------------------------------------------------------- */
 public static void Log(this PortMonitor src,
                        [CallerMemberName] string method = null) => src.Put(
     $"[{method}]",
     $"{nameof(src.Name)}:{src.Name.Quote()}",
     $"{nameof(src.Exists)}:{src.Exists}",
     $"{nameof(src.CanInstall)}:{src.CanInstall()}",
     $"{nameof(src.Environment)}:{src.Environment.Quote()}",
     $"{nameof(src.FileName)}:{src.FileName.Quote()}",
     $"{nameof(src.Config)}:{src.Config.Quote()}",
     $"{nameof(src.TargetDirectory)}:{src.TargetDirectory.Quote()}"
     );
Ejemplo n.º 6
0
        public void CreateForce()
        {
            var name = "Dummy Port";
            var src  = new PortMonitor(name, true);

            Assert.That(src.Name, Is.EqualTo(name));
            Assert.That(src.Exists, Is.False, nameof(src.Exists));
            Assert.That(src.FileName.HasValue(), Is.False, nameof(src.FileName));
            Assert.That(src.Config.HasValue(), Is.False, nameof(src.Config));
            Assert.That(src.Environment.HasValue(), Is.True, nameof(src.Environment));
            Assert.That(src.DirectoryName.HasValue(), Is.True, nameof(src.DirectoryName));
        }
Ejemplo n.º 7
0
        public void Install_Throws()
        {
            var src = new PortMonitor("Dummy Monitor");

            Assert.That(src.Exists, Is.False);
            Assert.That(src.CanInstall(), Is.False);

            src.FileName = "DummyMon.dll";
            Assert.That(src.CanInstall(), Is.True);

            src.Config = "DummyMonUi.dll";
            Assert.That(src.CanInstall(), Is.True);
            Assert.That(() => src.Install(), Throws.InstanceOf <Exception>());
        }
Ejemplo n.º 8
0
        public void GetElements()
        {
            var src = PortMonitor.GetElements();

            Assert.That(src.Count(), Is.AtLeast(2));

            foreach (var e in src)
            {
                e.Log();
                Assert.That(e.Name.HasValue(), Is.True, nameof(e.Name));
                Assert.That(e.FileName.HasValue(), Is.True, nameof(e.FileName));
                Assert.That(e.Environment.HasValue(), Is.True, nameof(e.Environment));
            }
        }
Ejemplo n.º 9
0
        private void Discard()
        {
            if (buffer.Count > 0)
            {
                buffer.Clear();
            }

            if (raw.Count > 0)
            {
                if (PortMonitor.Enabled)
                {
                    PortMonitor.Add(rx: true, raw.ToArray());
                }

                raw.Clear();
            }
        }
Ejemplo n.º 10
0
        public MainWindow()
        {
            InitializeComponent();
            SetupLogging();
            UpdateAppStates(AppState.APP_STATE_UNINITIALIZED);
            UpdateStatus();
            SetTitle();
            UpdateProfiling();
            SetLoggingLevel(Settings.Level);

            profilerWindow = new ProfilerWindow();
            profilerWindow.OnProfilerClosed += ProfilerWindow_OnClosed;
            monitorWindow = new MonitorWindow();
            monitorWindow.OnMonitorClosed += PortMonitorWindow_OnClosed;
            PortMonitor.SetMonitor(monitorWindow);

            commTester = new CommTester();
        }
Ejemplo n.º 11
0
        public void GetElements() => Invoke(() =>
        {
            var src = PortMonitor.GetElements();
            Assert.That(src.Count(), Is.AtLeast(2));

            foreach (var e in src)
            {
                this.LogDebug(string.Join("\t",
                                          e.Name.Quote(),
                                          e.FileName.Quote(),
                                          e.Environment.Quote()
                                          ));

                Assert.That(e.Name.HasValue(), Is.True, nameof(e.Name));
                Assert.That(e.FileName.HasValue(), Is.True, nameof(e.FileName));
                Assert.That(e.Environment.HasValue(), Is.True, nameof(e.Environment));
            }
        });