static void Main(string[] args) { using var pipeline = Pipeline.Create("PiTop", true); using var module = new PiTopModule(); var plate = module.GetOrCreatePlate <FoundationPlate>(); var threshold = plate .GetOrCreateDevice <Potentiometer>(AnaloguePort.A0) .CreateComponent(pipeline, TimeSpan.FromSeconds(0.5)); var distance = plate .GetOrCreateDevice <UltrasonicSensor>(DigitalPort.D3) .CreateComponent(pipeline, TimeSpan.FromSeconds(0.2)); var alert = new ValueAlertComponent(pipeline, new[] { plate.GetOrCreateDevice <Led>(DigitalPort.D0), plate.GetOrCreateDevice <Led>(DigitalPort.D1), plate.GetOrCreateDevice <Led>(DigitalPort.D2) }); threshold .Select(t => t * 50) .PipeTo(alert.Threshold); distance .Select(d => d.Value) .PipeTo(alert.Value); pipeline.Run(); }
static void Main(string[] args) { LogEvents.Subscribe(i => { i.Operation.Id = ""; Console.WriteLine(i.ToLogString()); }, new[] { //typeof(PiTop4Board).Assembly, //typeof(FoundationPlate).Assembly, typeof(Program).Assembly }); using var pipeline = Pipeline.Create("PiTop", DeliveryPolicy.Unlimited); using var module = PiTop4Board.Instance; var plate = module.GetOrCreateFoundationPlate(); var threshold = plate .GetOrCreatePotentiometer(AnaloguePort.A0) .CreateComponent(pipeline, TimeSpan.FromSeconds(0.5)); var distance = plate .GetOrCreateUltrasonicSensor(DigitalPort.D0) .CreateComponent(pipeline, TimeSpan.FromSeconds(0.2)); var alert = new ValueAlertComponent(pipeline, new[] { plate.GetOrCreateLed(DigitalPort.D1, Color.Green), plate.GetOrCreateLed(DigitalPort.D2, Color.Gold), plate.GetOrCreateLed(DigitalPort.D3, Color.RebeccaPurple) }); threshold .Select(t => t * 50) .PipeTo(alert.Threshold); distance .Select(d => Math.Min(d.Value, 50)) .PipeTo(alert.Value); pipeline.Run(); }