Ejemplo n.º 1
0
        public DevicePresenter(IDeviceView view)
        {
            _view = view;
            _listener = new TcpListener(IPAddress.Any, _view.DevicePort);
            _listener.Start();

            AcceptConnections();
            VerifyConnections();
        }
Ejemplo n.º 2
0
 public byte AddDevice(IProcessor processor, IDevice device, IDeviceView view, byte slot)
 {
     if (devices.ContainsKey(slot)) { return AddDevice(processor, device, view); }
     else
     {
         devices[slot] = device;
         device.Attached(GetInterruptDelegate(processor), view);
         return slot;
     }
 }
Ejemplo n.º 3
0
        public DevicePresenter(IDeviceView view)
        {
            _view = view;
            _view.Devices = GetWebcamList();

            LoadPlugins();
            _view.Sensors = _sensors;

            FrameRate = 15;
            VideoWidth = 640;
            VideoHeight = 480;

            Listen();
        }
Ejemplo n.º 4
0
    protected virtual void Awake()
    {
        int    deviceId   = ImageTracking.deviceId;
        string deviceName = ImageTracking.deviceName;

        // set device model
        device = DeviceCollection.DeviceCollectionInstance.GetRegisteredDeviceByDeviceId(deviceId);

        if (device == null)
        {
            SetDevice(deviceName, deviceId);
        }

        // set device view
        View = deviceView;
    }
Ejemplo n.º 5
0
        public static DeviceUpdateEvent Update(DeviceUpdateEvent previousUpdate, IDeviceView update)
        {
            if (update.DeviceId != previousUpdate.View.DeviceId)
            {
                throw new InvalidOperationException("Device ids do not match (numskull exception).");
            }
            var view = (DeviceTotalView)previousUpdate.View.Clone();

            switch (update)
            {
            case DeviceVoltagesUpdateView x: {
                view.Voltage = x.Voltage;
                break;
            }

            case DeviceCurrentsUpdateView x: {
                view.Current = x.Current;
                break;
            }
            }
            return(new DeviceUpdateEvent {
                View = view, LastUpdate = update
            });
        }
Ejemplo n.º 6
0
        private void InitializeDevice(bool isLoRaOn)
        {
            IsLoRaOn = isLoRaOn;

            if (device != null)
                btnOpenDevice_Click(btnOpenDevice, EventArgs.Empty);

            if (isLoRaOn)
            {
                startuptimeToolStripMenuItem.Visible = false;
                tsBtnStartupTime.Visible = false;
                toolsToolStripMenuItem.Visible = false;
                deviceViewList[1].Visible = true;
                deviceViewList[0].Visible = false;
                device = deviceList[1];
                deviceViewControl = deviceViewList[1];
            }
            else
            {
                startuptimeToolStripMenuItem.Visible = true;
                tsBtnStartupTime.Visible = true;
                toolsToolStripMenuItem.Visible = true;
                deviceViewList[0].Visible = true;
                deviceViewList[1].Visible = false;
                device = deviceList[0];
                deviceViewControl = deviceViewList[0];
            }

            btnOpenDevice_Click(btnOpenDevice, EventArgs.Empty);
        }
Ejemplo n.º 7
0
        public MainForm(bool testMode)
        {
            appTestArg = testMode;

            InitializeComponent();

            deviceList[0].SetNotificationWindowHandle(Handle, false);
            deviceList[0].Test = AppTestArg;
            deviceList[0].Error += new SemtechLib.General.Events.ErrorEventHandler(device_Error);
            deviceList[0].Connected += new EventHandler(device_Connected);
            deviceList[0].Disconected += new EventHandler(device_Disconected);
            deviceList[0].PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(device_PropertyChanged);
            deviceList[0].PacketHandlerStarted += new EventHandler(device_PacketHandlerStarted);
            deviceList[0].PacketHandlerStoped += new EventHandler(device_PacketHandlerStoped);

            deviceList[1].SetNotificationWindowHandle(Handle, false);
            deviceList[1].Test = AppTestArg;
            deviceList[1].Error += new SemtechLib.General.Events.ErrorEventHandler(device_Error);
            deviceList[1].Connected += new EventHandler(device_Connected);
            deviceList[1].Disconected += new EventHandler(device_Disconected);
            deviceList[1].PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(device_PropertyChanged);
            deviceList[1].PacketHandlerStarted += new EventHandler(device_PacketHandlerStarted);
            deviceList[1].PacketHandlerStoped += new EventHandler(device_PacketHandlerStoped);

            toolStripContainer1.BottomToolStripPanel.SuspendLayout();
            toolStripContainer1.TopToolStripPanel.SuspendLayout();
            toolStripContainer1.SuspendLayout();

            deviceViewList[0].Name = "sx1276ViewControl";
            ((Control)deviceViewList[0]).Location = new Point(0, 0);
            ((Control)deviceViewList[0]).Size = new Size(1008, 525);
            deviceViewList[0].Device = deviceList[0];
            deviceViewList[0].Dock = DockStyle.Fill;
            deviceViewList[0].Enabled = false;
            deviceViewList[0].Visible = true;
            deviceViewList[0].TabIndex = 0;
            deviceViewList[0].Error += new SemtechLib.General.Events.ErrorEventHandler(deviceViewControl_Error);
            deviceViewList[0].DocumentationChanged += new DocumentationChangedEventHandler(deviceViewControl_DocumentationChanged);

            deviceViewList[1].Name = "sx1276LoRaViewControl";
            ((Control)deviceViewList[1]).Location = new Point(0, 0);
            ((Control)deviceViewList[1]).Size = new Size(1008, 525);
            deviceViewList[1].Device = deviceList[1];
            deviceViewList[1].Dock = DockStyle.Fill;
            deviceViewList[1].Enabled = false;
            deviceViewList[1].Visible = false;
            deviceViewList[1].TabIndex = 0;
            deviceViewList[1].Error += new SemtechLib.General.Events.ErrorEventHandler(deviceViewControl_Error);
            deviceViewList[1].DocumentationChanged += new DocumentationChangedEventHandler(deviceViewControl_DocumentationChanged);

            toolStripContainer1.ContentPanel.Controls.Add((Control)deviceViewList[0]);
            toolStripContainer1.ContentPanel.Controls.Add((Control)deviceViewList[1]);

            deviceViewControl = deviceViewList[0];

            toolStripContainer1.BottomToolStripPanel.ResumeLayout(false);
            toolStripContainer1.BottomToolStripPanel.PerformLayout();
            toolStripContainer1.TopToolStripPanel.ResumeLayout(false);

            toolStripContainer1.TopToolStripPanel.PerformLayout();

            toolStripContainer1.ResumeLayout(false);

            toolStripContainer1.PerformLayout();

            try
            {
                appSettings = new ApplicationSettings();
            }
            catch (Exception ex)
            {
                SetError(ex.Message);
            }

            if (!appTestArg)
                Text = AssemblyTitle ?? "";
            else
                Text = AssemblyTitle + " - ..::: TEST :::..";
        }
Ejemplo n.º 8
0
        /// <inheritdoc />
        public virtual void SetDevice(IDeviceView device)
        {
            if (this.Device != null)
                throw new InterfaceAlreadyAttachedToDeviceException (this.Name);

            if (! device.Interfaces.Contains (this))
                throw new InterfaceNotAttachedToDeviceException (this.Name, device.Name);

            this.Device = device;
        }
Ejemplo n.º 9
0
        public void SetDevice(IDeviceView device)
        {
            if (device == null)
                throw new ArgumentNullException ();

            if (this.Device != null)
                throw new ArgumentException ();

            if (! device.Interfaces.Contains (this))
                throw new ArgumentException ();

            this.Device = device;
        }
Ejemplo n.º 10
0
 public void SetDevice(IDeviceView device)
 {
     Contract.Requires <ArgumentNullException> (device != null);
     Contract.Ensures (this.Device == device);
     Contract.EnsuresOnThrow <InterfaceAlreadyAttachedToDeviceException> (this.Device != null);
     Contract.EnsuresOnThrow <InterfaceNotAttachedToDeviceException> (Contract.ForAll (device.Interfaces,
                                                                                       i => i != this));
 }
Ejemplo n.º 11
0
 public void Attached(Interrupt interrupt, IDeviceView view)
 {
     this.interrupt = interrupt;
     this.View = view;
     Attached();
 }
Ejemplo n.º 12
0
 public byte AddDevice(IProcessor processor, IDevice device, IDeviceView view)
 {
     if(devices.Count >= byte.MaxValue) { throw new ArgumentException(MessageMaxDevicesReached); }
     while (devices.ContainsKey(nextSlot)) { ++nextSlot; }
     return AddDevice(processor, device, view, nextSlot++);
 }
Ejemplo n.º 13
0
 public void SetDevice(IDeviceView device)
 {
 }