MIDAS
Loading...
Searching...
No Matches
scfe.c
Go to the documentation of this file.
1/********************************************************************\
2
3 Name: scfe.c
4 Created by: Stefan Ritt Jan. 2018
5
6 Contents: Example slow control front-end for Raspberry Pi
7 computer with sense hat shield.
8
9 https://www.raspberrypi.org/products/sense-hat/
10
11 This front-end defines a "RaspberryPi" slow control
12 equipment with two device drivers rpi_temp and
13 rpi_led which read out the temperature sensor
14 on the sense hat and control the 64 LEDs.
15
16 The temperature will show up under
17 /Equipment/RaspberryPi/Variables/Input
18
19 The LEDs can be controlled via
20 /Equipment/RaspberryPi/Variables/Output[64]
21
22 where each value in the array contains the
23 RGB value for that one LED. Each R,G,B value
24 has a range 0...255 and gets bitwise or'ed
25 and shifted. Writing 0x0000FF (255) to a value
26 turns the corresponding LED blue, writing
27 0xFFFFFF (16777215) turns the LED white.
28
29 The custom page rpi.html can be used to control
30 the LEDs from a web page. To do so, put following
31 into the ODB:
32
33 /Custom/Path = /<path to rpi.html>
34 /Custom/RPi = rpi.html
35
36 Befor compiling this program, you have to install
37 the I2C package on the Raspberry Pi with:
38
39 $ sudo apt-get install libi2c-dev i2c-tools
40
41\********************************************************************/
42
43#include <stdio.h>
44#include "midas.h"
45#include "class/multi.h"
46#include "rpi_temp.h"
47#include "rpi_led.h"
48
49/*-- Globals -------------------------------------------------------*/
50
51/* The frontend name (client name) as seen by other MIDAS clients */
52const char *frontend_name = "SC Frontend";
53/* The frontend file name, don't change it */
55
56/* frontend_loop is called periodically if this variable is TRUE */
58
59/* a frontend status page is displayed with this frequency in ms */
61
62/* maximum event size produced by this frontend */
64
65/* maximum event size for fragmented events (EQ_FRAGMENTED) */
66INT max_event_size_frag = 5 * 1024 * 1024;
67
68/* buffer size to hold events */
70
71/*-- Equipment list ------------------------------------------------*/
72
73/* device driver list */
75 {"Temperature", rpi_temp, 1, NULL, DF_INPUT }, // one input channel
76 {"LED", rpi_led, 64, NULL, DF_OUTPUT }, // 64 output channels
77 {""}
78};
79
81 {"RaspberryPi", /* equipment name */
82 {4, 0, /* event ID, trigger mask */
83 "SYSTEM", /* event buffer */
84 EQ_SLOW, /* equipment type */
85 0, /* event source */
86 "MIDAS", /* format */
87 TRUE, /* enabled */
88 RO_RUNNING | RO_TRANSITIONS, /* read when running and on transitions */
89 60000, /* read every 60 sec */
90 0, /* stop run after this event limit */
91 0, /* number of sub events */
92 1, /* log history every event */
93 "", "", ""} ,
94 cd_multi_read, /* readout routine */
95 cd_multi, /* class driver main routine */
96 multi_driver, /* device driver list */
97 NULL, /* init string */
98 },
99
100 {""}
101};
102
103
104/*-- Dummy routines ------------------------------------------------*/
105
107{
108 return 1;
109};
111{
112 return 1;
113};
114
115/*-- Frontend Init -------------------------------------------------*/
116
118{
119 return CM_SUCCESS;
120}
121
122/*-- Frontend Exit -------------------------------------------------*/
123
125{
126 return CM_SUCCESS;
127}
128
129/*-- Frontend Loop -------------------------------------------------*/
130
132{
133 return CM_SUCCESS;
134}
135
136/*-- Begin of Run --------------------------------------------------*/
137
139{
140 return CM_SUCCESS;
141}
142
143/*-- End of Run ----------------------------------------------------*/
144
146{
147 return CM_SUCCESS;
148}
149
150/*-- Pause Run -----------------------------------------------------*/
151
153{
154 return CM_SUCCESS;
155}
156
157/*-- Resume Run ----------------------------------------------------*/
158
160{
161 return CM_SUCCESS;
162}
163
164/*------------------------------------------------------------------*/
#define FALSE
Definition cfortran.h:309
#define CM_SUCCESS
Definition midas.h:582
#define RO_TRANSITIONS
Definition midas.h:434
#define RO_RUNNING
Definition midas.h:426
#define EQ_SLOW
Definition midas.h:418
INT run_number[2]
Definition mana.cxx:246
double count
Definition mdump.cxx:33
DWORD BOOL
Definition midas.h:105
int INT
Definition midas.h:129
#define DF_OUTPUT
Definition midas.h:1051
#define TRUE
Definition midas.h:182
#define DF_INPUT
Definition midas.h:1050
#define POINTER_T
Definition midas.h:166
#define resume_run
#define pause_run
program test
Definition miniana.f:6
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
Definition rmidas.h:24
INT rpi_led(INT cmd,...)
Definition rpi_led.c:143
INT rpi_temp(INT cmd,...)
Definition rpi_temp.c:134
BOOL frontend_call_loop
frontend_loop is called periodically if this variable is TRUE
Definition scfe.c:57
INT poll_event(INT source[], INT count, BOOL test)
Definition scfe.c:106
const char * frontend_file_name
The frontend file name, don't change it.
Definition scfe.c:54
DEVICE_DRIVER multi_driver[]
Definition scfe.c:74
INT max_event_size
maximum event size produced by this frontend
Definition scfe.c:63
INT frontend_exit()
Frontend exit.
Definition scfe.c:124
INT frontend_init()
Frontend initialization.
Definition scfe.c:117
INT event_buffer_size
buffer size to hold events
Definition scfe.c:69
INT max_event_size_frag
maximum event size for fragmented events (EQ_FRAGMENTED)
Definition scfe.c:66
INT interrupt_configure(INT cmd, INT source[], POINTER_T adr)
Definition scfe.c:110
EQUIPMENT equipment[]
Main structure for midas equipment.
Definition scfe.c:80
const char * frontend_name
The frontend name (client name) as seen by other MIDAS clients.
Definition scfe.c:52
INT display_period
a frontend status page is displayed with this frequency in ms
Definition scfe.c:60
INT begin_of_run(INT run_number, char *error)
Begin of Run.
Definition scfe.c:138
INT frontend_loop()
Frontend loop.
Definition scfe.c:131
INT end_of_run(INT run_number, char *error)
End of Run.
Definition scfe.c:145