summaryrefslogtreecommitdiff
path: root/common/distrio_helper.h
blob: e25560baa48a364c3789506982bb7b965868e25c (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
/**
 * CORBA helpers
 *
 *  - init orb
 *  - get reference to name service
 *  - register objects @ name service
 *
 * @author Manuel Traut <manut@mecka.net>
 * @licence GPLv2
 */

#include <distrio_io.h>
#include <distrio_ioC.h>
#include <distrio_ioS.h>

#include <distrio_managerC.h>

#include <orbsvcs/CosNamingC.h>

#define ORB_NOT_INITIALIZED 0
#define ORB_INIT 1
#define ORB_RUNNING 2

/**
 * handle to corba objects needed for registration of new objects and running
 *  the ORB
 */
typedef struct _corba_ref {
	/** init > 0 if orb is initialized */
	int init;
	CORBA::ORB_var orb;
	PortableServer::POA_var poa;
	PortableServer::POAManager_var poa_mgr;
	CosNaming::NamingContext_var nc;
	Distrio::Manager_var manager;
} corba_ref;

static corba_ref ref = {
	.init = ORB_NOT_INITIALIZED,
};

/** initialize corba orb - argc, argv as passed to main() */
int init_corba (int argc, char **argv);
/** run the orb - function starts orb in new thread and returns */
int run_orb (void);
/** join the orb - function blocks until orb is shutdown */
int join_orb (void);

/** register a digital io with a common name at the naming service */
int register_digital (Distrio_Digital_i *digital);
/** register a analog io with a common name at the naming service */
int register_analog (Distrio_Analog_i *analog);
/** register a device with a common name at the naming service */
int register_device (Distrio_Device_i *dev);

/* returns a list of all registered digital ios */
void get_digital_list (Distrio::Digital_list_var *dig_list);
/* returns a list of all registered analog ios */
void get_analog_list (Distrio::Analog_list_var *ana_list);

/** lookup a digital io by a common name at the manager */
int lookup_digital (std::string _name, Distrio::Digital_list_var dig_list,
	Distrio::Digital **ptr);
/** lookup a analog io by a common name at the manager */
int lookup_analog (std::string _name, Distrio::Analog_list_var ana_list,
	Distrio::Analog **ptr);