Non-Periodic Sampling with a Data Logger

The purpose of this guide is to show how to configure a datalogger for sampling a variable in a non-periodic manner. In this scenario, we will illustrate how to sample a variable’s value after a VariableValueChangedEvent is emitted.

Data Logger Configuration

To begin, add a model variable named Temperature by right-clicking on the Model folder and selecting New > Variable. Rename the newly created variable to Temperature. Next, add an embedded database by right-clicking the DataStores folder and selecting New > Embedded database.

Inserire un nuovo datalogger facendo clic destro sulla cartella Loggers e selezionando New > Data logger.

Alla proprietà Store del data logger, associare lo Store DatabaseInterno1 selezionandolo dal menù a cascata del panello proprietà. Inserire poi una variabile da campionare cliccando il tasto «+» in corrispondenza della proprietà Variabili da campionare e associare la variabile di modello Temperatura alla sotto proprietà VariabileDaCampionare1 tramite un collegamento dinamico.

For the purpose of this tutorial, the Periodic Sampling property of the logger has to be disabled to grant more control on when the logger can log variations of Temperature’s value.

Event Configuration

Per creare un evento che rileva il cambiamento del valore della temperatura, dal modello, selezionare la variabile Temperatura e nel panello properties, fare clic destro sulla cella Temeperatura e selezionare New > ChangedEvent. Selezionare ancora dalla cartella di modello, l’oggetto TemperaturaChangedEvent. Ora, nel panello eventi, aggiungere un nuovo evento selezionando «+» in corrispondenza di VariableValueEventChangedType. Nella finestra a comparsa di collegamento dinamico, navigare a Loggers/DataLogger1/Log.

Graphical Configuration

To change the value of Temperature at runtime, insert a new Linear Gauge into the project by right-clicking on the MainWindow and selecting New > Base Controls > Linear gauge. Next, create a dynamic link between the Value property of the Linear gauge and the Temperature variable in the Model folder.

To track the recorded values of the variable, insert a Data grid in the MainWindow and drop the logger upon it for an automatic configuration. Add a refresh button for the data grid and assign MainWindow/DataGrid1/Refresh as a MouseClickEvent in the EventView using a dynamic link.

Running the Project

Run the project and observe as values of the Temperature variable is recorded only when it is changed by the linear gauge. Click on Refresh to update the values of the data grid.

Download a sample project at this link