Example #1
0
        public static void SetUpBeforeClass()
        {
            compressor = new Compressor();

            fakePressureSwitch = new DigitalOutput(11);

            fakeCompressor = new AnalogInput(1);

            fakeSolenoid1 = new DigitalInput(12);
            fakeSolenoid2 = new DigitalInput(13);

            if (RobotBase.IsSimulation)
            {
                /*
                 * pressureSwitchCallback = (s, o) =>
                 * {
                 *  var comp = SimData.GetPCM(0).Compressor;
                 *  comp.PressureSwitch = o;
                 *  comp.On = o;
                 *  double voltage = o ? CompressorOffVoltage : CompressorOnVoltage;
                 *  SimData.AnalogIn[1].Voltage = voltage;
                 * };
                 */
                pressureSwitchCallback = (string name, HAL_Value value) =>
                {
                    SimData.PCM[0].SetPressureSwitch(value.GetBoolean());
                    SimData.PCM[0].SetCompressorOn(value.GetBoolean());
                    double voltage = value.GetBoolean() ? CompressorOffVoltage : CompressorOnVoltage;
                    SimData.AnalogIn[1].SetVoltage(voltage);
                };
                callbackId = SimData.DIO[11].RegisterValueCallback(pressureSwitchCallback, false);
            }
        }
 public DioCrossConnectFixture(int input, int output)
 {
     Assert.AreNotEqual(input, output);
     m_input = new DigitalInput(input);
     m_output = new DigitalOutput(output);
     m_allocated = true;
 }
Example #3
0
 public FakeEncoderSource(int portA, int portB)
 {
     m_outputA          = new DigitalOutput(portA);
     m_outputB          = new DigitalOutput(portB);
     m_allocatedOutputs = true;
     InitQuadEncoder();
 }
Example #4
0
        public Form1()
        {
            InitializeComponent();

            m_b5000 = true; // set to true for module on ADAM-5000; set to false for module on ADAM-5000/TCP
            if (m_b5000)
            {
                m_iCom           = 2;     // using COM2
                adamCom          = new AdamCom(m_iCom);
                adamCom.Checksum = false; // disbale checksum
            }
            else
            {
                m_szIP     = "172.19.1.234";
                adamSocket = new AdamSocket();
                adamSocket.SetTimeout(1000, 1000, 1000); // set timeout
            }
            m_iAddr  = 1;                                // the slave address is 1
            m_iSlot  = 1;                                // the slot index of the module
            m_iCount = 0;                                // the counting start from 0
            m_bStart = false;
            //m_Adam5000Type = Adam5000Type.Adam5050; // the sample is for ADAM-5050
            m_Adam5000Type = Adam5000Type.Adam5051; // the sample is for ADAM-5051
            //m_Adam5000Type = Adam5000Type.Adam5052; // the sample is for ADAM-5052
            //m_Adam5000Type = Adam5000Type.Adam5055; // the sample is for ADAM-5055
            //m_Adam5000Type = Adam5000Type.Adam5056; // the sample is for ADAM-5056
            //m_Adam5000Type = Adam5000Type.Adam5060; // the sample is for ADAM-5060
            //m_Adam5000Type = Adam5000Type.Adam5068; // the sample is for ADAM-5068
            //m_Adam5000Type = Adam5000Type.Adam5069; // the sample is for ADAM-5069

            m_iChTotal     = DigitalInput.GetChannelTotal(m_Adam5000Type) + DigitalOutput.GetChannelTotal(m_Adam5000Type);
            txtModule.Text = m_Adam5000Type.ToString();
        }
 public FakeEncoderSource(DigitalOutput iA, DigitalOutput iB)
 {
     m_outputA = iA;
     m_outputB = iB;
     m_allocatedOutputs = false;
     InitQuadEncoder();
 }
Example #6
0
 public FakeEncoderSource(DigitalOutput iA, DigitalOutput iB)
 {
     m_outputA          = iA;
     m_outputB          = iB;
     m_allocatedOutputs = false;
     InitQuadEncoder();
 }
 /// <summary>
 /// Set the status of the specified digital output port.
 /// </summary>
 /// <param name="channel">DOUT1 to DOUT8</param>
 /// <param name="status">OFF:0; ON:1</param>
 public void SetDout(DigitalOutput channel, DigitalIOStatus status)
 {
     lock (_lockController)
     {
         Send(new CommandSetDOUT(channel, status));
     }
 }
 public FakeEncoderSource(int portA, int portB)
 {
     m_outputA = new DigitalOutput(portA);
     m_outputB = new DigitalOutput(portB);
     m_allocatedOutputs = true;
     InitQuadEncoder();
 }
Example #9
0
        public Form1()
        {
            InitializeComponent();

            int iIdx;

            m_bStart   = false;                      // the action stops at the beginning
            m_szIP     = "172.18.3.200";             // modbus slave IP address
            m_iPort    = 502;                        // modbus TCP port is 502
            adamModbus = new AdamSocket();
            adamModbus.SetTimeout(1000, 1000, 1000); // set timeout for TCP

            m_Adam6000Type = Adam6000Type.Adam6024;  // the sample is for ADAM-6050

            // modbus current list view item
            m_iAiTotal = AnalogInput.GetChannelTotal(m_Adam6000Type);
            m_iDiTotal = DigitalInput.GetChannelTotal(m_Adam6000Type);
            m_iAoTotal = AnalogOutput.GetChannelTotal(m_Adam6000Type);
            m_iDoTotal = DigitalOutput.GetChannelTotal(m_Adam6000Type);

            m_bChEnabled = new bool[m_iAiTotal];
            m_byAiRange  = new byte[m_iAiTotal];
            m_byAoRange  = new byte[m_iAoTotal];

            for (iIdx = 0; iIdx < m_iAoTotal; iIdx++)
            {
                //
                cbxAOChannel.Items.Add(iIdx.ToString());
                //
            }
            cbxAOChannel.SelectedIndex = -1;

            txtModule.Text = m_Adam6000Type.ToString();
        }
Example #10
0
 public DioCrossConnectFixture(int input, int output)
 {
     Assert.AreNotEqual(input, output);
     m_input     = new DigitalInput(input);
     m_output    = new DigitalOutput(output);
     m_allocated = true;
 }
Example #11
0
    IEnumerator PulseRoutine(DigitalOutput output, float width)
    {
        output.value = true;
        yield return(new WaitForSeconds(width));

        output.value = false;
    }
Example #12
0
 /// <summary>
 /// Set the status of the specified digital output port.
 /// </summary>
 /// <param name="Channel">DOUT1 to DOUT8</param>
 /// <param name="Status">OFF:0; ON:1</param>
 public void SetDOUT(DigitalOutput Channel, DigitalIOStatus Status)
 {
     lock (lockController)
     {
         Send(new CommandSetDOUT(Channel, Status));
     }
 }
Example #13
0
 public DioCrossConnectFixture(DigitalInput input, DigitalOutput output)
 {
     Assert.NotNull(input);
     Assert.NotNull(output);
     m_input     = input;
     m_output    = output;
     m_allocated = false;
 }
Example #14
0
 public static void DisposeAll()
 {
     AnalogInput.DisposeActive();
     DigitalInput.DisposeActive();
     DigitalInterrupt.DisposeActive();
     DigitalOutput.DisposeActive();
     PwmOutput.DisposeActive();
 }
 public DioCrossConnectFixture(DigitalInput input, DigitalOutput output)
 {
     Assert.NotNull(input);
     Assert.NotNull(output);
     m_input = input;
     m_output = output;
     m_allocated = false;
 }
Example #16
0
        private ushort[] m_usRange; //for newer version
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            Database.SetInitializer(new CpDashboardDatabaseInitializer());

            RouteTable.Routes.MapHttpRoute(
                name: "Alert",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = System.Web.Http.RouteParameter.Optional }
                );

            CpDashboardContext cont = new CpDashboardContext();

            cont.Database.Initialize(true);
            cont.Database.CreateIfNotExists();

            //set a timer
            //adam initializer
            m_bStart   = false;                      // the action stops at the beginning
            m_szIP     = "192.168.10.10";            // modbus slave IP address
            m_iPort    = 502;                        // modbus TCP port is 502
            adamModbus = new AdamSocket();
            adamModbus.SetTimeout(1000, 1000, 1000); // set timeout for TCP
            adamUDP = new AdamSocket();
            adamUDP.SetTimeout(1000, 1000, 1000);    // set timeout for UDP

            m_Adam6000Type = Adam6000Type.Adam6015;  // the sample is for ADAM-6015

            adamUDP.Connect(AdamType.Adam6000, m_szIP, ProtocolType.Udp);
            if (adamUDP.Configuration().GetFirmwareVer(out m_szFwVersion))
            {
                m_DeviceFwVer = int.Parse(m_szFwVersion.Trim().Substring(0, 1));
            }
            adamUDP.Disconnect();

            m_iAiTotal = AnalogInput.GetChannelTotal(m_Adam6000Type);
            m_iDoTotal = DigitalOutput.GetChannelTotal(m_Adam6000Type);

            //txtModule.Text = m_Adam6000Type.ToString();
            m_bChEnabled = new bool[m_iAiTotal];

            //firmware version
            //fwversion.Text = m_DeviceFwVer.ToString();

            if (m_DeviceFwVer > m_Adam6000NewerFwVer)
            {
                m_usRange = new ushort[m_iAiTotal];
            }

            if (cont.Database.Exists())
            {
                // start the retrieving datas and save to db;
                startSending();
            }
        }
Example #17
0
        public void Initialize(Adam4000Type type, int port, int address = 1, bool checksum = false)
        {
            this.AdamType         = type;
            this.SerialPortNumber = port;
            this.address          = address;
            this.Checksum         = checksum;

            this.DiNumber = DigitalInput.GetChannelTotal(type);
            this.DoNumber = DigitalOutput.GetChannelTotal(type);
        }
Example #18
0
 public void Dispose()
 {
     m_task = null;
     if (m_allocated)
     {
         m_output.Dispose();
         m_output    = null;
         m_allocated = false;
     }
 }
Example #19
0
 public void Dispose()
 {
     m_task = null;
     if (m_allocated)
     {
         m_output.Dispose();
         m_output = null;
         m_allocated = false;
     }
 }
Example #20
0
        public void OnSeaLevelDigitalOutput(DigitalOutputDevice digitalOutput)
        {
            var outputs = BitConverter.GetBytes(Convert.ToInt32(string.Join("", DigitalOutput.Select(c => Convert.ToInt32(c.Value))), 2));

            SM_WriteDigitalOutputs(0, DigitalOutput.Count, outputs);
            if (SeaLevelDigitalOutput != null)
            {
                SeaLevelDigitalOutput.Invoke(this, digitalOutput);
            }
        }
Example #21
0
        public B10001GroupBoard(NeuronGroup neuronGroup, IBoardInformation boardSystemInformation, NeuronSpiConnector spiConnector, I2CConnector i2CConnector, DriverLogger logger) : base(neuronGroup, boardSystemInformation, spiConnector, i2CConnector, logger)
        {
            #region Digital Inputs

            for (ushort i = 0; i < AnzahlDigitalInputs; i++)
            {
                var input = new DigitalInput(i + 1, neuronGroup, 0, i);
                SetObservation(0, input);
                DigitalInputDictionary.Add(input.UniqueIdentifyer, input);
            }

            #endregion Digital Inputs

            #region Digital Outputs

            for (ushort i = 0; i < AnzahlDigitalOutputs; i++)
            {
                var digitalOutput = new DigitalOutput(1 + i, neuronGroup, i, spiConnector, logger, DigitalRelayOutputType.DigitalOutput, 1, i);
                DigitalOutputsDictionary.Add(digitalOutput.UniqueIdentifyer, digitalOutput);
            }

            #endregion Digital Outputs

            #region One Wire

            var oneWireConnector = new OneWireConnector(neuronGroup, 1, Logger, I2CConnector);
            OneWireConnectorsDictionary.Add(oneWireConnector.UniqueIdentifyer, oneWireConnector);

            #endregion One Wire

            #region User LED's

            for (ushort i = 0; i < UserLedsCount; i++)
            {
                var userLed = new UserLed(i + 1, neuronGroup, (ushort)(8 + i), spiConnector, 20, i);
                UserLedsDictionary.Add(userLed.UniqueIdentifyer, userLed);
            }

            #endregion User LED's

            #region Analog Output

            var analogOutput = new AnalogOutput(neuronGroup, 1, 2, spiConnector, logger);
            AnalogOutputsDictionary.Add(analogOutput.UniqueIdentifyer, analogOutput);

            #endregion Analog Output

            #region Analog Input

            var analogInput = new AnalogInput(neuronGroup, 1, 3, spiConnector);
            SetObservation(3, analogInput);
            AnalogInputsDictionary.Add(analogInput.UniqueIdentifyer, analogInput);

            #endregion Analog Input
        }
        public void DoWork()
        {
            logger.Debug("Automation started!");
            DigitalOutput output1 = FindByAddress(1001) as DigitalOutput;

            if (output1.Value == 1)
            {
                executor.PutCommand(new DigitalCommand()
                {
                    Address = 1001, Value = 0
                });
            }
        }
Example #23
0
 public bool Add(DigitalOutput device)
 {
     try
     {
         context.Devices.Add(device);
         context.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Example #24
0
        /// <summary></summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public Led7R(int socketNumber)
        {
            // This finds the Socket instance from the user-specified socket number.
            // This will generate user-friendly error messages if the socket is invalid.
            // If there is more than one socket on this module, then instead of "null" for the last parameter,
            // put text that identifies the socket to the user (e.g. "S" if there is a socket type S)
            Socket socket = Socket.AttachToSocket(socketNumber, SocketType.Y);

            for (int i = 0; i < leds.Length; i++)
            {
                leds[i] = new DigitalOutput(socket, socket.SocketPins[(int)SocketPin.Three + i]);
            }
        }
Example #25
0
        private void RefreshAdam5000Information()
        {
            int  iIdx;
            byte byCode;

            Adam5000Type adamType;

            adamType = (Adam5000Type)cbxModuleType.SelectedItem;
            // AI information
            txtAITotal.Text = AnalogInput.GetChannelTotal(adamType).ToString();
            listViewAI.Items.Clear();
            for (iIdx = 0; iIdx < AnalogInput.GetRangeTotal(adamType); iIdx++)
            {
                byCode = AnalogInput.GetRangeCode(adamType, iIdx);
                listViewAI.Items.Add(new ListViewItem("0x" + byCode.ToString("X02")));           // range code
                listViewAI.Items[iIdx].SubItems.Add(AnalogInput.GetRangeName(adamType, byCode)); // range name
                listViewAI.Items[iIdx].SubItems.Add(AnalogInput.GetUnitName(adamType, byCode));  // range name
            }
            // AO information
            txtAOTotal.Text = AnalogOutput.GetChannelTotal(adamType).ToString();
            listViewAO.Items.Clear();
            for (iIdx = 0; iIdx < AnalogOutput.GetRangeTotal(adamType); iIdx++)
            {
                byCode = AnalogOutput.GetRangeCode(adamType, iIdx);
                listViewAO.Items.Add(new ListViewItem("0x" + byCode.ToString("X02")));                  // range code
                listViewAO.Items[iIdx].SubItems.Add(AnalogOutput.GetRangeName(adamType, byCode));       // range name
                listViewAO.Items[iIdx].SubItems.Add(AnalogOutput.GetUnitName(adamType, byCode));        // range name
            }
            // DIO
            txtDITotal.Text = DigitalInput.GetChannelTotal(adamType).ToString();
            txtDOTotal.Text = DigitalOutput.GetChannelTotal(adamType).ToString();
            // counter
            txtCounterTotal.Text = Counter.GetChannelTotal(adamType).ToString();
            listViewCounter.Items.Clear();
            if (Counter.GetModeTotal(adamType) > 0)
            {
                listViewCounter.Items.Add(new ListViewItem(Counter.GetModeName(adamType, (byte)Adam5080_CounterMode.Bi_Direction)));    // mode name
                listViewCounter.Items[0].SubItems.Add(Counter.GetUnitName(adamType, (byte)Adam5080_CounterMode.Bi_Direction));          // unit name
                listViewCounter.Items.Add(new ListViewItem(Counter.GetModeName(adamType, (byte)Adam5080_CounterMode.Up_Down)));         // mode name
                listViewCounter.Items[1].SubItems.Add(Counter.GetUnitName(adamType, (byte)Adam5080_CounterMode.Up_Down));               // unit name
                listViewCounter.Items.Add(new ListViewItem(Counter.GetModeName(adamType, (byte)Adam5080_CounterMode.Frequency)));       // mode name
                listViewCounter.Items[2].SubItems.Add(Counter.GetUnitName(adamType, (byte)Adam5080_CounterMode.Frequency));             // unit name
            }
            // alarm
            listViewAlarm.Items.Clear();
            for (iIdx = 0; iIdx < Alarm.GetModeTotal(adamType); iIdx++)
            {
                byCode = Alarm.GetModeCode(adamType, iIdx);
                listViewAlarm.Items.Add(new ListViewItem(Alarm.GetModeName(adamType, byCode))); // mode name
            }
        }
Example #26
0
        void ProgramStarted()
        {
            Debug.Print("Program Started");

            _digitalInput   = breadBoard_X1.SetupDigitalInput(GT.Socket.Pin.Three, GlitchFilterMode.On, ResistorMode.Disabled);
            _digitalOutput  = breadBoard_X1.SetupDigitalOutput(GT.Socket.Pin.Four, false);
            _digitalInput2  = breadBoard_X1.SetupDigitalInput(GT.Socket.Pin.Six, GlitchFilterMode.On, ResistorMode.Disabled);
            _digitalOutput2 = breadBoard_X1.SetupDigitalOutput(GT.Socket.Pin.Seven, false);

            var timer = new GT.Timer(50);

            timer.Tick += timer_Tick;
            timer.Start();
        }
Example #27
0
 public Adam6000(string name, Adam6000Type model)  : base(name, new ChannelsInfo {
     AnalogInputsCount    = AnalogInput.GetChannelTotal(model),
     AnalogOutputsCount   = AnalogOutput.GetChannelTotal(model),
     DiscreteInputsCount  = DigitalInput.GetChannelTotal(model),
     DiscreteOutputsCount = DigitalOutput.GetChannelTotal(model),
     CounterInputsCount   = DigitalInput.GetChannelTotal(model)
 })
 {
     Model = model;
     if (AnalogInputs != null)
     {
         AIRanges = new List <byte>(new byte[AnalogInputs.Count]);
     }
 }
Example #28
0
    public override void OnInspectorGUI()
    {
        this.serializedObject.Update();

        DigitalOutput controller = (DigitalOutput)target;

        GUI.enabled = false;
        EditorGUILayout.PropertyField(script, true, new GUILayoutOption[0]);
        GUI.enabled = true;
        foldout     = EditorGUILayout.Foldout(foldout, "Sketch Options");
        if (foldout)
        {
            EditorGUI.indentLevel++;
            EditorGUILayout.PropertyField(id, new GUIContent("id"));
            EditorGUILayout.PropertyField(pin, new GUIContent("pin"));
            EditorGUILayout.PropertyField(defaultValue, new GUIContent("defaultValue"));
            EditorGUILayout.PropertyField(resetOnStop, new GUIContent("resetOnStop"));
            EditorGUI.indentLevel--;
        }

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Value", GUILayout.Width(80f));
        int index = 0;

        if (controller.Value == true)
        {
            index = 1;
        }
        int newIndex = GUILayout.SelectionGrid(index, new string[] { "FALSE", "TRUE" }, 2);

        if (index != newIndex)
        {
            if (newIndex == 0)
            {
                controller.Value = false;
            }
            else
            {
                controller.Value = true;
            }

            if (!Application.isPlaying)
            {
                EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
            }
        }
        EditorGUILayout.EndHorizontal();

        this.serializedObject.ApplyModifiedProperties();
    }
        public CommandResult Execute(SaveHeaterCommand command, CommandContext context)
        {
            var validationResult = Validate(command, context);

            if (validationResult != null)
            {
                return(validationResult);
            }

            DigitalOutput outputToDisable = null;

            if (command.HeaterId.HasValue)
            {
                var existingHeater = context.ControllerState.HeaterIdToState.GetValueOrDefault(command.HeaterId.Value);

                if (existingHeater != null &&
                    (existingHeater.Heater.DigitalOutput.ProtocolName != command.PowerOutputProtocolName ||
                     DescriptorsEqual(existingHeater.Heater.DigitalOutput.OutputDescriptor, command.PowerOutputDescriptor)))
                {
                    outputToDisable = new DigitalOutput
                    {
                        ProtocolName     = existingHeater.Heater.DigitalOutput.ProtocolName,
                        OutputDescriptor = existingHeater.Heater.DigitalOutput.OutputDescriptor
                    };
                }
            }

            var heater      = _heaterSaver.Save(command, context.ControllerState.Model);
            var heaterState = context.ControllerState.HeaterIdToState.GetValueOrDefault(heater.HeaterId);

            if (heaterState == null)
            {
                context.ControllerState.HeaterIdToState.Add(heater.HeaterId, new HeaterState
                {
                    Heater = heater
                });
            }
            else
            {
                heaterState.Heater = heater;
            }

            if (outputToDisable != null)
            {
                _powerOutputProvider.Provide(outputToDisable.ProtocolName)
                .SetState(outputToDisable.OutputDescriptor, false);
            }

            return(CommandResult.Empty);
        }
Example #30
0
        //RFID Reader: Channel 0
        //5V Digital Output: Channel 0
        //LED Driver Ourput: Channel 1
        //Onboard LED: Channel 2
        public Form1()
        {
            InitializeComponent();

            dig         = new DigitalOutput();
            dig.Channel = 2;
            dig.Open();
            rfid = new RFID();
            rfid.Open();
            rfid.Attach  += new AttachEventHandler(rfid_Attach);
            rfid.Detach  += new DetachEventHandler(rfid_Detach);
            rfid.Error   += new ErrorEventHandler(rfid_Error);
            rfid.Tag     += new RFIDTagEventHandler(rfid_Tag);
            rfid.TagLost += new RFIDTagLostEventHandler(rfid_TagLost);
        }
Example #31
0
        /// <summary>
        /// Use this constructor if you are connecting XBee using Gadgteteer socket.
        /// </summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        /// <remarks>
        /// The function <see cref="Configure"/> can be called to configure the <see cref="SerialLine"/> before it is used.
        /// If it is not called before first use, then the following defaults will be used and cannot be changed afterwards:
        /// <list type="bullet">
        ///  <item>Baud Rate - 9600</item>
        ///  <item>Parity - <see cref="System.IO.Ports.Parity">Parity.None</see></item>
        ///  <item>Stop Bits - <see cref="System.IO.Ports.StopBits">StopBits.One</see></item>
        ///  <item>Data Bits - 8</item>
        /// </list>
        /// </remarks>
        public XBee(int socketNumber)
        {
            _connectedToGadgeteerSocket = true;

            // This finds the Socket instance from the user-specified socket number.
            // This will generate user-friendly error messages if the socket is invalid.
            // If there is more than one socket on this module, then instead of "null" for the last parameter,
            // put text that identifies the socket to the user (e.g. "S" if there is a socket type S)
            var socket = Socket.GetSocket(socketNumber, true, this, null);

            socket.EnsureTypeIsSupported(new[] { 'K', 'U' }, this);

            _serialPortName    = socket.SerialPortName;
            _gadgeteerResetPin = DigitalOutputFactory.Create(socket, Socket.Pin.Three, ResetState.NotRunning, this);
            _gadgeteerSleepPin = DigitalOutputFactory.Create(socket, Socket.Pin.Eight, SleepState.Awaken, this);
        }
Example #32
0
        public void AddOutput(DigitalOutput output)
        {
            if (Outputs == null)
            {
                Outputs = new List <DigitalOutput>();
            }

            if (Outputs.Count < 8)
            {
                Outputs.Add(output);
            }
            else
            {
                throw new Exception("Przekroczona ilość wyjść!");
            }
        }
Example #33
0
        private void SetDigitalOutputsProperty()
        {
            string description = "";

            for (int i = 0; i < MAX_DIGITAL_OUTPUTS; i++)
            {
                switch (i)
                {
                case 0:
                    description = "Status zadania";
                    break;

                case 1:
                    description = "Błąd drukarki";
                    break;

                case 2:
                    description = "Sterowanie sztaplarką";
                    break;

                case 3:
                    description = "Sterowanie odrzutnikiem";
                    break;

                default:
                    description = "";
                    break;
                }
                DigitalOutput output = new DigitalOutput();
                output.Id = i + 1;
                //output.OutputName = "Out " + i.ToString();
                output.Name        = ((DOutputControl)i).ToString();
                output.Description = description;
                if (i < 4)
                {
                    output.IsActive = true;
                }
                else
                {
                    output.IsActive = false;
                }

                output.DataField = -1;

                rjConnection.AddOutput(output);
            }
        }
Example #34
0
        internal protected void OnSeaIoDigitalOutput <T>(object sender, DigitalOutput digitalOutput) where T : class
        {
            var type = sender.GetType();

            if (type == typeof(SeaLevel420))
            {
                var seaio              = (SeaLevel420)sender;
                var seaioIndex         = SeaLevel420.IndexOf(seaio);
                var digitaloutputindex = seaio.DigitalOutput.IndexOf(digitalOutput);
                DigitalOutputEvent?.Invoke(seaio, seaioIndex, digitaloutputindex, digitalOutput);
            }
            else if (type == typeof(SeaLevel410))
            {
                var seaio              = (SeaLevel410)sender;
                var seaioIndex         = SeaLevel410.IndexOf(seaio);
                var digitaloutputindex = seaio.DigitalOutput.IndexOf(digitalOutput);
                DigitalOutputEvent?.Invoke(seaio, seaioIndex, digitaloutputindex, digitalOutput);
            }
        }
Example #35
0
 public bool Update(DigitalOutput device, byte value)
 {
     try
     {
         lock (obj)
         {
             var result = context.Devices.SingleOrDefault(x => x.Address == device.Address);
             if (result != null)
             {
                 (result as DigitalOutput).Value = value;
                 context.SaveChanges();
                 return(true);
             }
             return(false);
         }
     }
     catch
     {
         return(false);
     }
 }
Example #36
0
        public static void SetUpBeforeClass()
        {
            compressor = new Compressor();

            fakePressureSwitch = new DigitalOutput(11);

            fakeCompressor = new AnalogInput(1);

            fakeSolenoid1 = new DigitalInput(12);
            fakeSolenoid2 = new DigitalInput(13);

            if (RobotBase.IsSimulation)
            {
                pressureSwitchCallback = (s, o) =>
                {
                    var comp = SimData.GetPCM(0).Compressor;
                    comp.PressureSwitch = o;
                    comp.On = o;
                    double voltage = o ? CompressorOffVoltage : CompressorOnVoltage;
                    SimData.AnalogIn[1].Voltage = voltage;
                };
                SimData.DIO[11].Register("Value", pressureSwitchCallback);
            }
        }
Example #37
0
        public void TestInitTable()
        {
            using (DigitalOutput s = new DigitalOutput(0))
            {
                ITable table = new MockNetworkTable();
                Assert.DoesNotThrow(() =>
                {
                    s.InitTable(table);
                });
                Assert.That(s.Table, Is.EqualTo(table));
            }

        }
Example #38
0
 public FakeCounterSource(int port)
 {
     m_output = new DigitalOutput(port);
     m_allocated = false;
     InitEncoder();
 }
Example #39
0
 public FakeCounterSource(DigitalOutput output)
 {
     m_output = output;
     m_allocated = false;
     InitEncoder();
 }
Example #40
0
 public void TestSmartDashboardType()
 {
     using (DigitalOutput s = new DigitalOutput(0))
     {
         Assert.That(s.SmartDashboardType, Is.EqualTo("Digital Output"));
     }
 }
Example #41
0
 public void TestValueChanged()
 {
     using (DigitalOutput s = new DigitalOutput(0))
     {
         s.Set(false);
         Assert.That(GetOutputDictionary(0).Value, Is.False);
         s.ValueChanged(null, null, true, NotifyFlags.NotifyLocal);
         Assert.That(GetOutputDictionary(0).Value, Is.True);
         s.ValueChanged(null, null, false, NotifyFlags.NotifyLocal);
         Assert.That(GetOutputDictionary(0).Value, Is.False);
     }
 }
Example #42
0
 public void TestUpdateTableNull()
 {
     using (DigitalOutput s = new DigitalOutput(0))
     {
         Assert.DoesNotThrow(() =>
         {
             s.UpdateTable();
         });
     }
 }
Example #43
0
        public void TestDigitalPWMOverAllocate()
        {
            List<DigitalOutput> counters = new List<DigitalOutput>();
            for (int i = 0; i < 6; i++)
            {
                DigitalOutput output = new DigitalOutput(i);
                counters.Add(output);
                output.EnablePWM(0.5);
                Assert.That(SimData.DigitalPWM[output.PwmGeneratorChannel].Initialized, Is.True);
            }

            DigitalOutput counter = new DigitalOutput(NumCounters); ;
            Assert.DoesNotThrow(() =>
            {
                counter.EnablePWM(0.5);
                Assert.That(counter.PwmGeneratorChannel, Is.EqualTo(~0));
            });
            counter?.Dispose();

            foreach (var c in counters)
            {
                c?.Dispose();
                if (c == null) return;
                Assert.That(SimData.DigitalPWM[c.PwmGeneratorChannel].Initialized, Is.False);
            }

        }
Example #44
0
 public void TestStopLiveWindowMode()
 {
     using (DigitalOutput s = new DigitalOutput(0))
     {
         Assert.DoesNotThrow(() =>
         {
             s.StopLiveWindowMode();
         });
     }
 }