summaryrefslogtreecommitdiff
path: root/interfaces/distrio_io.idl
blob: 7c483be61fb0b831b0fad91bae22dc4d983c3494 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#ifndef DISTRIO_IO_IDL
#define DISTRIO_IO_IDL

#include "distrio_common.idl"

/**
 * @brief the implementation of these interfaces are responsible for
 *	controlling the I/O hardware
 *
 * @author Manuel Traut <manut@mecka.net>
 * @copyright GPLv2
 */

module Distrio {

	interface Device;

	/** what should trigger a callback? */
	enum Digital_trigger {
		TRIGGER_EDGE,
		TRIGGER_RISING_EDGE,
		TRIGGER_FALLING_EDGE
	};

	/** a digital input or output pin */
	interface Digital {
		/** get the name of the hardware which is connected to this pin */
		Distrio::Error name (out string name);
		/** set this pin (fails if it's a digital input) */
		Distrio::Error set ();
		/** reset this pin (fails if it's a digital input) */
		Distrio::Error reset ();
		/** get the value of the pin ( 0 = reset, rest = set */
		Distrio::Error get (out long value);
		/** register a callback that is called if the state of the pin changes */
		Distrio::Error register_callback (in Device dev, in Digital_trigger trigger);
		/** stores a timestamp of the last update of the referenced value */
		attribute Distrio::Timestamp last_update;
		/** the id is given by Distrio::Manager during registration */
		attribute long id;
	};

	typedef sequence<Digital> Digital_list;

	/** what should trigger a callback? */
	struct Analog_trigger {
		/** used internal to store analog value of the last trigger */
		long last_value;
		/** e.g. if current_value > last_value + jitter -> execute callback */
		long jitter;
	};

	/** an analog input or output pin */
	interface Analog {
		/** name of the hardware which is connected to the pin */
		Distrio::Error name (out string name);
		/** minimum allowed value */
		Distrio::Error min (out long min);
		/** maximum allowd value */
		Distrio::Error max (out long max);
		/** set new value (may fail if out of range or pin is an input) */
		Distrio::Error set (in long value);
		/** get analog value of the pin */
		Distrio::Error get (out long value);
		/** register a callback that is called if the trigger matches */
		Distrio::Error register_callback (in Device dev, in Analog_trigger trigger);
		/** stores a timestamp of the last update of the referenced value */
		attribute Distrio::Timestamp last_update;
		/** the id is given by Distrio::Manager during registration */
		attribute long id;
	};

	typedef sequence<Analog> Analog_list;

	/** list of functions of all devices - new ones can be added if needed */
	enum Dev_function_id {
		DEV_START,
		DEV_STOP
	};

	/** definition to control the device, e.g. start or stop it */
	struct Dev_function {
		string description;
		long value;
		Dev_function_id id;
	};

	typedef sequence<Dev_function> Dev_function_list;

	/** a device could have several io's and can export functions which can be
	 *   controlled by a HID device or GUI
	 */
	interface Device {
		/** name of the device */
		Distrio::Error name (out string name);
		/** to execute a device specific function pass the Dev_function descriotion
		 *		(retrived by (functions ()) as parameter
		 */
		Distrio::Error execute (in Dev_function func);
		/** returns all device specific function descriptions */
		Distrio::Error functions (out Dev_function_list funcs);
		/** called by the Digital object if this object is registered as a
		 *		callback and the trigger hits */
		Distrio::Error callback_digital (in Digital io_dig);
		/** called by the Digital object if this object is registered as a
		 *		callback and the trigger hits */
		Distrio::Error callback_analog (in Analog io_ana);
		/** ID is given by Distrio::Manager during registration */
		attribute long id;
	};

	typedef sequence<Device> Device_list;

};

#endif