aboutsummaryrefslogtreecommitdiff
path: root/weshd.x
blob: 352751fcd5e95c93a12994999de2675ff8edfdf0 (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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
/* ****************************************************************************
 * weshd.x -- définition du protocole over Sun RPC pour le démon weshd.
 * Copyright (C) 2018 Thomas Touhey <thomas@touhey.fr>
 *
 * This project is governed by the CeCILL license under French law and
 * abiding by the rules of distribution of free software. You can use,
 * modify and/or redistribute the software under the terms of the
 * CeCILL license as circulated by CEA, CNRS and INRIA at the
 * following URL: "http://www.cecill.info".
 *
 * As a counterpart to the access to the source code and rights to copy,
 * modify and redistribute granted by the license, users are provided only
 * with a limited warranty and the project's author, the holder of the
 * economic rights, and the successive licensors have only limited liability.
 *
 * In this respect, the user's attention is drawn to the risks associated
 * with loading, using, modifying and/or developing or reproducing the
 * software by the user in light of its specific status of free software,
 * that may mean that it is complicated to manipulate, and that also therefore
 * means that it is reserved for developers and experienced professionals
 * having in-depth computer knowledge. Users are therefore encouraged to load
 * and test the software's suitability as regards their requirements in
 * conditions enabling the security of their systems and/or data to be
 * ensured and, more generally, to use and operate it in the same conditions
 * as regards security.
 *
 * The fact that you are presently reading this means that you have had
 * knowledge of the CeCILL license and that you accept its terms.
 * ************************************************************************* */
/* Les codes de retour (ou d'erreur) sont les suivants :
 *
 * - `WESRET_OK`:  aucune erreur ;
 * - `WESRET_INT`: une erreur interne s'est produite ;
 * - `WESRET_IMP`: cette fonctionnalité n'est pas (encore) implémentée.
 * - `WESRET_VAL`: arguments invalides pour cette fonctionnalité.
 *
 * - `WESRET_NOW`: la ressource n'existe pas.
 * - `WESRET_CON`: le serveur n'a pas pu être joint. */

enum wespret_t {
	WESPRET_OK  =  0,
	WESPRET_INT =  1,
	WESPRET_IMP =  2,
	WESPRET_VAL =  3,

	WESPRET_NOW = 10,
	WESPRET_CON = 11
};

/* Un identifiant d'une ressource de type serveur WES est un entier
 * allant de 1 à 32766 inclus. */

typedef int wespid_t;

/* Une adresse IP, soit version 4 soit version 6. */

enum wespiptype_t {
	WESPIPTYPE_NONE = 0,
	WESPIPTYPE_4    = 4,
	WESPIPTYPE_6    = 6
};

struct wespip_t {
	wespiptype_t type;
	unsigned char ipv4[4];
	unsigned char ipv6[16];
};

/* Les données relatives à la création d'une ressource de type serveur WES.
 * - `WESPREGTYPE_DUMMY` : faire comme si un serveur WES existait, pour
 * développer une bibliothèque ou un client sans serveur WES sous la main
 * par exemple ;
 * - `WESPREGTYPE_IP` : se connecter au serveur WES via IP. */

enum wespregtype_t {
	WESPREGTYPE_DUMMY = 0,
	WESPREGTYPE_IP    = 1
};

struct wespregopts_t {
	wespregtype_t type;
	wespip_t ip;
	string http_username<>;
	string http_password<>;
	string ftp_username<>;
	string ftp_password<>;
};

/* Une date, version protocole. */

struct wespdatetime_t {
	int year; /* e.g. 2018 */
	int mon; /* 1 à 12 */
	int dom; /* 1 à 31 */
	int hour; /* 0 à 23 */
	int min; /* 0 à 59 */
	int sec; /* 0 à 60 (leap seconds) */

	int dow; /* 0 à 6 (lundi à dimanche) */
	bool sum; /* « summer time » (heure d'été), 0 si heure d'hiver */
	int tz; /* e.g. `01 * 60 + 00` pour GMT+01:00 */
};

/* Les données relatives au réseau. */

struct wespnetcfg_t {
	bool enable_dhcp;
	unsigned char ip[4];
	unsigned char mask[4];
	unsigned char gw[4];
	unsigned char dns1[4];
	unsigned char dns2[4];
};

struct wespnetdat_t {
	unsigned char mac[6];
};

/* Les données relatives au TÉLÉINFO.
 * BDPV est un service permettant de centraliser les informations concernant
 * les panneaux solaires, etc. */

enum wesptictarif_t {
	WESPTICTARIF_BASE  = 0, /* Base (toutes heures) */
	WESPTICTARIF_HCHP  = 1, /* Heures Creuses, Heures Pleines */
	WESPTICTARIF_EJP   = 2, /* Effacement de Jours de Pointes */
	WESPTICTARIF_TEMPO = 3  /* Temporaires (jours bleus, blancs, rouges) */
};

enum wespticperiod_t {
	WESPTICPERIOD_HN   =  0, /* Heures Normales/Toutes les Heures */
	WESPTICPERIOD_HC   =  1, /* Heures Creuses (HCHP) */
	WESPTICPERIOD_HP   =  2, /* Heures Pleines (HCHP) */
	WESPTICPERIOD_PM   =  3, /* Heures de Pointe Mobile (EJP) */

	WESPTICPERIOD_JB   =  0, /* Jours Bleus */
	WESPTICPERIOD_JW   =  4, /* Jours Blancs */
	WESPTICPERIOD_JR   =  8, /* Jours Rouges */

	WESPTICPERIOD_HCJB =  1, /* Heures Creuses Jours Bleus */
	WESPTICPERIOD_HPJB =  2, /* Heures Pleines Jours Bleus */
	WESPTICPERIOD_HCJW =  5, /* Heures Creuses Jours Blancs */
	WESPTICPERIOD_HPJW =  6, /* Heures Pleines Jours Blancs */
	WESPTICPERIOD_HCJR =  9, /* Heures Creuses Jours Rouges */
	WESPTICPERIOD_HPJR = 10  /* Heures Pleines Jours Rouges */
};

enum wespticmode_t {
	WESPTICMODE_CONSO = 0, /* consommation */
	WESPTICMODE_PROD  = 1  /* production */
};

enum wespticphmode_t {
	WESPTICPHMODE_NONE = 0, /* Aucun */
	WESPTICPHMODE_MONO = 1, /* Monophasé */
	WESPTICPHMODE_TRI  = 3  /* Triphasé */
};

struct wespticcfg_t {
	/* Propriétés de base du compteur. */

	bool read; /* Le compteur est-il actif ? */
	wespticmode_t mode; /* Mode CONSO ou PRODUCTION */
	string name<>; /* Quel nom a été donné au compteur ? */

	/* Propriétés tarifaires. */

	double abo; /* Coût de l'abonnement annuel */
	bool prorata; /* Prorata abonnement au prix du kWh ou non ? */

	/* Tarif appliqué pour l'abonnement BASE. */

	double tarif_base;

	/* Tarifs appliqués pour l'abonnement HCHP (heures creuses h. pleines). */

	double tarif_hchp_hc;
	double tarif_hchp_hp;

	/* Tarifs appliqués pour l'abonnement TEMPO (jours bleus, blancs, rouges,
	 * heures creuses et pleines). */

	double tarif_tempo_hcjb;
	double tarif_tempo_hpjb;
	double tarif_tempo_hcjw;
	double tarif_tempo_hpjw;
	double tarif_tempo_hcjr;
	double tarif_tempo_hpjr;

	/* Tarifs appliqués pour l'abonnement EJP (Effacement de Jour de
	 * Pointe). */

	double tarif_ejp_hn; /* Heures Normales */
	double tarif_ejp_pm; /* Pointe Mobile */

	/* Si les résultats sont envoyés au site BDPV. */

	bool bdpv_enabled;
	int bdpv_hour;
	int bdpv_min;
};

struct wespticdat_t {
	bool plugged_in; /* Le compteur est-il branché ? */
	bool standing_by; /* Le compteur est-il en mode veille ? */

	/* Propriétés relatives au TÉLÉINFO. */

	unsigned char adco[12]; /* Identification du compteur */
	wesptictarif_t tarif; /* Type de tarif */
	wespticphmode_t phmode; /* Mode de l'entrée (monophasé ou triphasé) */
	wespticperiod_t period; /* Période tarifaire en cours */

	/* Intensités, puissances. */

	unsigned int isousc; /* Intensité souscrite */
	unsigned int pa; /* Puissance apparente (VA). */
	unsigned int iinst[3]; /* Intensité instantanée pour chaque phase */
	unsigned int imax[3]; /* Intensité maximale pour chaque phase */

	/* Index pour l'abonnement BASE. */

	unsigned long index_base;

	/* Index pour l'abonnement HCHP (heures creuses h. pleines). */

	unsigned long index_hchp_hc;
	unsigned long index_hchp_hp;

	/* Index pour l'abonnement TEMPO (jours bleus, blancs, rouges,
	 * heures creuses et pleines). */

	unsigned long index_tempo_hcjb;
	unsigned long index_tempo_hpjb;
	unsigned long index_tempo_hcjw;
	unsigned long index_tempo_hpjw;
	unsigned long index_tempo_hcjr;
	unsigned long index_tempo_hpjr;

	/* Index pour l'abonnement EJP (Effacement de Jour de
	 * Pointe). */

	unsigned long index_ejp_hn; /* Heures Normales */
	unsigned long index_ejp_pm; /* Pointe Mobile */
};

/* Structures utiles aux appels serveur. */

struct wespret_with_id_t {
	wespret_t ret;
	wespid_t id;
};

struct wespret_with_datetime_t {
	wespret_t ret;
	wespdatetime_t dt;
};

struct wespid_with_datetime_t {
	wespid_t id;
	wespdatetime_t dt;
};

struct wespid_with_ntp_t {
	wespid_t id;
	string ntpserver<>;
};

struct wespid_with_hostname_t {
	wespid_t id;
	string hostname<>;
};

struct wespret_with_hostname_t {
	wespret_t ret;
	string hostname<>;
};

struct wespret_with_net_t {
	wespret_t ret;
	wespnetcfg_t cfg;
	wespnetdat_t data;
};

struct wespid_with_net_t {
	wespid_t id;
	wespnetcfg_t cfg;
};

struct wespid_with_ids_t {
	wespid_t id;
	string username<>;
	string password<>;
};

struct wespid_with_tic_id_t {
	wespid_t id;
	int tic_id;
};

struct wespret_with_tic_t {
	wespret_t ret;
	wespticcfg_t cfg;
	wespticdat_t data;
};

struct wespid_with_tic_t {
	wespid_t id;
	int tic_id;
	wespticcfg_t cfg;
};

/* Voici la définition du programme en lui-même. */

program WESHD_PROG {
	version WESHD_VERS1 {
		/* Gérer les ressources existantes. */

		wespret_with_id_t gather(wespregopts_t args) = 1;
		wespret_t unregister(wespid_t id) = 2;

		/* Récupérer et définir le nom d'hôte du serveur WES. */

		wespret_with_hostname_t get_host_name(wespid_t id) = 3;
		wespret_t set_host_name(wespid_with_hostname_t id) = 4;

		/* Gérer les identifiants du serveur WES (si l'interface
		 * l'utilise). */

		wespret_t set_http_ids(wespid_with_ids_t id) = 5;
		wespret_t set_ftp_ids(wespid_with_ids_t id) = 6;

		/* Gérer l'heure du serveur WES. */

		wespret_with_datetime_t get_date_time(wespid_t id) = 16;
		wespret_t set_date_time(wespid_with_datetime_t id) = 17;
#if 0
		wespret_t set_ntp(wespid_with_ntp_t id) = 18;
		wespret_t enable_ntp(wespid_t id) = 19;
		wespret_t disable_ntp(wespid_t id) = 20;
#endif

		/* Gérer l'aspect réseau du WES. */

		wespret_with_net_t get_network(wespid_t id) = 21;
		wespret_t set_network(wespid_with_net_t id) = 22;

		/* Gérer les compteurs branchés via TÉLÉINFO. */

		wespret_with_tic_t get_tic(wespid_with_tic_id_t id) = 23;
		wespret_t set_tic(wespid_with_tic_t id) = 24;
	} = 1;
} = 0x20001234;

#ifdef RPC_HDR
%extern void weshd_prog_1(struct svc_req *rqstp, SVCXPRT *transp);
#endif