Ejemplo n.º 1
0
 public MetricFilter()
     : base("Filter",
            InputPort.CreateMany(InputPort.Create("in", PortDataType.Array)),
            OutputPort.CreateMany(OutputPort.Create("out", PortDataType.Array)))
 {
     Fc = 100000;
 }
Ejemplo n.º 2
0
 public MetricAdder()
     : base("Adder",
            InputPort.CreateMany(InputPort.Create("inA", PortDataType.Array),
                                 InputPort.Create("inB", PortDataType.Array)),
            OutputPort.CreateMany(OutputPort.Create("out", PortDataType.Array)))
 {
 }
Ejemplo n.º 3
0
        public MetricRecorder(Graph g) : base("Recorder", g)
        {
            _portData   = InputPort.Create <DataInputPort>("Data", this);
            _portEnable = InputPort.Create <ValueInputPort>("En", this);

            _set = NodeSystemSettings.Instance.SystemHost.RecordSetForGraph(Parent);
        }
Ejemplo n.º 4
0
 public MetricHalfrate(Graph graph)
     : base("Half Rate", graph,
            InputPort.CreateMany(InputPort.Create("in", PortDataType.Array)),
            OutputPort.CreateMany(OutputPort.Create("out", PortDataType.Array)))
 {
     _portInp = (DataInputPort)InputPorts[0];
     _portOut = (DataOutputPort)OutputPorts[0];
 }
Ejemplo n.º 5
0
 public MetricFFTBandEnergy(Graph graph)
     : base("Band Energy", graph,
            InputPort.CreateMany(
                InputPort.Create("in", PortDataType.FFT)),
            OutputPort.CreateMany(
                OutputPort.Create("out", PortDataType.Value)))
 {
     _portInp = (FFTInputPort)InputPorts[0];
     _portOut = (ValueOutputPort)OutputPorts[0];
 }
Ejemplo n.º 6
0
 public MetricMultiplyValue(Graph graph)
     : base("Multiply", graph,
            InputPort.CreateMany(InputPort.Create("in", PortDataType.Array),
                                 InputPort.Create("f", PortDataType.Value)),
            OutputPort.CreateMany(OutputPort.Create("out", PortDataType.Array)))
 {
     _portInp    = (DataInputPort)InputPorts[0];
     _inputValue = (ValueInputPort)InputPorts[1];
     _portOut    = (DataOutputPort)OutputPorts[0];
 }
Ejemplo n.º 7
0
        public MetricFilter(Graph graph)
            : base("Filter", graph,
                   InputPort.CreateMany(InputPort.Create("in", PortDataType.Array)),
                   OutputPort.CreateMany(OutputPort.Create("out", PortDataType.Array)))
        {
            _portInp = (DataInputPort)InputPorts[0];
            _portOut = (DataOutputPort)OutputPorts[0];

            Fc = 100000;
        }
Ejemplo n.º 8
0
        private static void Main(string[] args)
        {
            using (var port = InputPort.Create(18, GpioEdge.Both).Result)
            {
                Console.WriteLine("Started");
                port.Subscribe(reading => Console.WriteLine("Reading: {0}", reading),
                               error => Console.WriteLine("Error: {0}", error.Message));

                Console.ReadLine();
            }
        }
Ejemplo n.º 9
0
 public MetricFFT(Graph graph)
     : base("FFT", graph,
            InputPort.CreateMany(
                InputPort.Create("in", PortDataType.Array)),
            OutputPort.CreateMany(
                OutputPort.Create("out", PortDataType.FFT)))
 {
     _portInp = (DataInputPort)InputPorts[0];
     _portOut = (FFTOutputPort)OutputPorts[0];
     FFTSize  = 2048;
 }
Ejemplo n.º 10
0
        private static void Main(string[] args)
        {
            using (var inputPort = InputPort.Create(18, GpioEdge.Both).Result)
                using (var outputPort = OutputPort.Create(23, OutputPort.InitialValue.Low).Result)
                {
                    Console.WriteLine("Started");
                    inputPort.Subscribe(outputPort);

                    Console.ReadLine();
                }
        }
Ejemplo n.º 11
0
        static void Main(string[] args)
        {
            MMALCamera cam = MMALCamera.Instance;

            // Create observable that will generate an incrementing number every second
            var observable = Observable.Generate(1, x => true, x => x + 1, x => x, x => TimeSpan.FromSeconds(1));

            var relay  = OutputPort.Create(17, OutputPort.InitialValue.Low).Result;
            var light1 = OutputPort.Create(27, OutputPort.InitialValue.Low).Result;
            var light2 = OutputPort.Create(22, OutputPort.InitialValue.Low).Result;
            var button = InputPort.Create(24, GpioEdge.Both).Result;

            // Write true whenever the number is even and odd when the number is odd
            using (var imgCaptureHandler = new ImageStreamCaptureHandler("/home/pi/images/", "jpg"))
                using (observable.Select(x => x % 2 == 0).Subscribe(relay))
                    using (observable.Select(x => x % 2 == 0).Subscribe(light1))
                        //using (observable.Select(x => x % 2 != 0).Subscribe(light2))
                        //using (button.Do(pressed => Console.WriteLine(pressed)).Subscribe())
                        using (button.Subscribe(light2))
                            using (var i2cBus = new I2CBusPI("/dev/i2c-1"))
                            {
                                var takePictureTask = cam.TakePicture(imgCaptureHandler, MMALEncoding.JPEG, MMALEncoding.I420);

                                var i2cDevice = new I2CDevicePI(i2cBus, Display.DefaultI2CAddress);

                                var sensor = new BME280Sensor(i2cBus, 1014);

                                var display = new SSD1306.Display(i2cDevice, 128, 64);
                                display.Init();

                                var dfont = new AdafruitSinglePageFont();

                                for (int i = 0; i < 100; i++)
                                {
                                    display.WriteLineBuff(dfont, $"Temperature: {sensor.ReadTemperature().Result} °C", $"Pressure: {sensor.ReadPressure().Result} Pa", $"Humidity: {sensor.ReadHumidity().Result} %", $"Altitude: {sensor.ReadAltitude().Result} m", "Line 5", "Line 6", "Line 7", "Line 8");
                                    display.DisplayUpdate();
                                }

                                //for (int i = 0; i < 100; i++)
                                //    display.DrawPixel(i, i);

                                takePictureTask.Wait();
                                display.ClearDisplay();
                            }
            // releasing relay
            relay.Write(true);
            // turning of light
            light1.Write(false);
            light2.Write(false);
            // Cleanup disposes all unmanaged resources and unloads Broadcom library. To be called when no more processing is to be done
            // on the camera.
            cam.Cleanup();
        }
Ejemplo n.º 12
0
        private void ChangeInputType()
        {
            if (InputPorts.Count > 0)
            {
                Parent.Disconnect(InputPorts[0]);
                RemoveInput(InputPorts[0]);
            }

            switch (type)
            {
            case InputType.Signal:
                InputPort.Create <DataInputPort>("In", this);
                break;

            case InputType.Value:
                InputPort.Create <ValueInputPort>("In", this);
                break;

            default:
                GlobalSettings.Instance.Errors.Add(new NodeError(this, "Unknown input type: " + type));
                break;
            }
        }
Ejemplo n.º 13
0
 public MetricHalfrate()
     : base("Half Rate",
            InputPort.CreateMany(InputPort.Create("in", PortDataType.Array)),
            OutputPort.CreateMany(OutputPort.Create("out", PortDataType.Array)))
 {
 }
Ejemplo n.º 14
0
 public MetricSlowProcess()
     : base("Slow Process",
            InputPort.CreateMany(InputPort.Create("in", PortDataType.Array)),
            OutputPort.CreateMany(OutputPort.Create("out", PortDataType.Array)))
 {
 }
Ejemplo n.º 15
0
 public MetricPower()
     : base("Power",
            InputPort.CreateMany(InputPort.Create("in", PortDataType.Array)),
            OutputPort.CreateMany(OutputPort.Create("out", PortDataType.Array)))
 {
 }
Ejemplo n.º 16
0
 public PassThroughNode(Graph g) : base("Passthrough", g)
 {
     _input  = InputPort.Create <DataInputPort>("Inp", this);
     _output = OutputPort.Create <DataOutputPort>("Out", this);
 }
Ejemplo n.º 17
0
 public SinkNode(Graph g) : base("Sink", g)
 {
     _input = InputPort.Create <DataInputPort>("Inp", this);
 }
Ejemplo n.º 18
0
 public MetricThresholdEvent(Graph g) : base("Treshold Event", g)
 {
     _dataIn   = InputPort.Create <DataInputPort>("Inp", this);
     _threshIn = InputPort.Create <ValueInputPort>("Thresh", this);
     _eventOut = OutputPort.Create <EventOutputPort>("Ev", this);
 }
Ejemplo n.º 19
0
        public MetricStop(Graph graph) : base("Stop", graph)
        {
            var port = InputPort.Create <EventInputPort>("inp", this);

            port.EventRaised += Port_EventRaised;
        }
Ejemplo n.º 20
0
 public MetricTimeStampSink(Graph g) : base("TimeStamp Display", g)
 {
     InputPort.Create <DataInputPort>("In", this);
 }
Ejemplo n.º 21
0
 public MetricRms() : base("Number Sink",
                           InputPort.CreateMany(InputPort.Create("In", PortDataType.Array),
                                                InputPort.Create("Sqr", PortDataType.Value)),
                           OutputPort.CreateMany())
 {
 }
Ejemplo n.º 22
0
 public MetricAccumulate(Graph g) : base("Accumulate", g)
 {
     InputPort.Create <DataInputPort>("inp", this);
 }
Ejemplo n.º 23
0
 public BasicTestNode(Graph g) : base("Test", g)
 {
     _inp = InputPort.Create <DataInputPort>("input", this);
     _out = OutputPort.Create <DataOutputPort>("output", this);
 }
Ejemplo n.º 24
0
        public static async Task <GpioTrigger> Create(IGpioDriver driver, int gpioPin)
        {
            var port = await InputPort.Create(gpioPin, GpioEdge.Both, driver);

            return(new GpioTrigger(port));
        }
Ejemplo n.º 25
0
 public MetricValueRecorder(Graph graph) : base("Value Recorder", graph)
 {
     _portInp = InputPort.Create <ValueInputPort>("In", this);
     _portEn  = InputPort.Create <ValueInputPort>("En", this);
 }
Ejemplo n.º 26
0
 public MetricLogicNot(Graph graph) : base("Logical Not", graph)
 {
     InputPort.Create <ValueInputPort>("in", this);
     OutputPort.Create <ValueOutputPort>("out", this);
 }
Ejemplo n.º 27
0
 public MetricValueSink(Graph graph) : base("Value Sink", graph)
 {
     InputPort.Create <ValueInputPort>("In", this);
 }
Ejemplo n.º 28
0
 public MetricAdder(Graph graph) : base("Adder", graph)
 {
     _portInA = InputPort.Create <DataInputPort>("inA", this);
     _portInB = InputPort.Create <DataInputPort>("inB", this);
     _portOut = OutputPort.Create <DataOutputPort>("out", this);
 }