SignalF application

Introduction

In this tutorial we will develop a simple temperature monitoring system with SignalF for the Raspberry Pi. Depending on the processor temperature, the system will control various LEDs and a fan to cool the processor.

Raspberry Temperature Control

You will learn how to integrate devices and data output components into SignalF. We will also create a simple logic to monitor the temperature. In the last step, we will connect the individual components using configuration.

Create the project

First create a new project for a .NET 8 console application.

Hint

Further information on how to create a SignalF application can be found in the chapter Getting started with SignalF.

Open the file Program.cs after you have created the project. Then enter the following code.

using System.Runtime.Versioning;

namespace Tutorial;

[SupportedOSPlatform("linux")]
public class Program
{
    public static async Task Main(string[] args)
    {
        var hostBuilder = Host.CreateDefaultBuilder(args)
                              .ConfigureServices(services =>
                              {
                              });

        var host = hostBuilder.Build();

        await host.RunAsync();
    }
}

To add the SignalF functionality, we need the Nuget package SignalF.Extensions.Controller. Execute the following command in the Package Manager Console to install the Nuget package.

Install-Package -IncludePrerelease SignalF.Extensions.Controller

Now add the highlighted lines.

        var hostBuilder = Host.CreateDefaultBuilder(args)
                              .UseSignalFController()
                              .ConfigureServices(services =>
                              {
                                  services.AddSignalFControllerService();
                              });

        var host = hostBuilder.Build();

        await host.RunAsync();
    }
}

UseSignalFController() adds the SignalF functionality to the application. With services.AddSignalFControllerService() we define the behaviour of the SignalF application. The SignalF Controller Service automatically loads the configuration at startup, initialises all services and starts measurement operation.

First run

You can now compile and start the SignalF application.
Click Debug > Start Without Debugging in the menu to start the app. You should now see the following text in the console window:

Default process is running ........

SignalF is now up and running. Press Ctrl-C to exit the application.