Data Acquisition Simulator
The objective is to investigate how, in embedded software design, devices abstract (hide) device-specific implementation detail (driver) away from the objects (operating system application programmer’s interface (API) that utilise their services. This assignment also demonstrates one approach as to how inter-object communications may be implemented.
In this scenario, the objective is to design a program to simulate a data acquisition environment. The benefit of this approach is that, assuming an actual component device exposes the same class interface, the hardware may be substituted into the system without any re-writing of code required, other than substituting the class associated with the particular hardware device driver in question. The code may be stored in a separate module, such as a dynamic link library (DLL), for example.
The system consists of a clock source that drives a signal source (sine and random waveform), which supplies data to a channel of an analyser device. When requested by an input channel (e.g. mixed-signal oscilloscope, logic analyser, etc.). The Analyser captures processes (keeps track of a running average) and displays the current waveform value on a computer screen
The Signal Source supplies single-valued data, along with the current time, to the Analyser, when requested. The data characteristics may take the form of a triangle or sine wave.
The clock class supplies the current time to a Signal Source object, when requested. The Clock class should possess:
A parameterised constructor should allow (i) an initial starting time (in us ) to be specified, along with a (ii) custom time increment. If no parameters are supplied assume default values of 0 and 5us , respectively.
An ‘AdvanceTime’ (by specified increment) should also be provided. If no explicit increment is provided, the increment supplied upon initialisation of the class should be assumed.
As we are not writing event-driven software, we cannot configure the clock to automatically update. So, when a request is received from a signal source to supply the current time, the Clock object should automatically increment the time (having initially supplied the current time to the signal source).
A Time ‘Reset’ option should also exist.
A ‘Current time’ - Return the current elapsed time.
The data received from the interface functions should first be parsed to ensure that the values are valid. The following private functions should then be used to set the appropriate private member data required to support the clock functionality.
‘AdvanceClock’ – increment the current time stored in the Clock class.
‘SetClock’ – Set the current time stored in the clock class to the value specified.
Signal Source Class
The Signal Source should initially connect to a clock source. When requested, the signal source should calculate the value of the chosen waveform for the current time, supplied by the Clock class object.
Each Signal Source class possesses the following properties:
Signal Source Type: – Triangular, sine wave
Default type: Parameterised: type: parameters
Triangular: period 50 , amplitude.
Sine: frequency, amplitude, D.C. offset.
Constructor – Call (SetParams) function to assign signal source parameters. (Note, there should be a separate constructor for each signal type – see Signal Source Type above). [6 marks]
GetValue – Returns the current value from the chosen, validated channel (DataFromSource).
GetParams – Returns the waveform type and associated parameters. [4 marks]
DataFromSource – Accesses the channel source data.
SetParams – Sets the values for the signal source.
Private Member Data:
Determined by the programmer.
The analyser initially connects its channels to any available (supplied) signal sources. When requested, the analyser may request a signal source value from a channel. The analyser may also request the channel waveform details from the associated signal source. A running average for each channel is automatically maintained. This is information may be displayed on the analyser (PC) screen, when requested.
Constructors – 2 signal sources.
A signal source and a channel number.
ConnectChannel – If the channel has not been already attached, associate a signal source with a channel. DisconnectChannel – Disconnect a signal source from a channel, if currently connected.
RequestChannelInfo – Returns the info associated with the signal source connected to the channel, if any.
GetValue – Verify that this is a valid channel and retrieve the sample value and elapsed time. The running average should be automatically updated (AverageValue).
DisplayChannelValue – Displays the current value of the specified channel.
DisplayChannelAverage - Displays the average value of the specified channel.
AverageValue – Average of last 5 values.
DetachChannel – Disconnect from specified channel.
AttachChannel – Connect to specified channel. DataFromChannel – Accesses the channel data.
Write a program to demonstrate the operation of the Data acquisition system.
Use appropriate variable name, indentation and commenting