Legrand / Raritan Xerus™ JSON-RPC API for Remote Access Devices like KX4-101, KX3G2
Loading...
Searching...
No Matches
DateTime.idl
1/* SPDX-License-Identifier: BSD-3-Clause */
2/*
3 * Copyright 2009 Raritan Inc. All rights reserved.
4 */
5
6#include <Event.idl>
7
8/**
9 * Device Date and Time Configuration
10 */
11module datetime {
12
13 /**
14 * Date and time configuration methods
15 *
16 * Example to set timezone (id-based approach): @anchor set-timezone-example
17 *
18 * @code{.py}
19 * zoneinfos = getZoneInfos(False)
20 * cfg = getCfg()
21 * cfg.zoneCfg.id = ... # choose zone id from returned zoneinfos
22 * status = setCfg(cfg)
23 * if status != 0: ... # error handling
24 * @endcode
25 */
26 interface DateTime {
27
28 /**
29 * Time zone information (see also ZoneCfg)
30 *
31 * There are two different approaches on how to identify timezones. See the ZoneCfg description.
32 *
33 * For timezones with non-trivial daylight saving time rules #hasDSTInfo is \c false.
34 */
35 structure ZoneInfo {
36 int id; ///< Time zone id
37 string name; ///< Time zone name
38 boolean hasDSTInfo; ///< \c true if the time zone has daylight saving time rules
39 };
40
41 /**
42 * Time zone configuration
43 *
44 * There are two approaches on how timezones are identified:
45 *
46 * 1. id-based
47 * - timezone data identified with a numeric non-zero id
48 * - #id != 0
49 * - #name is the display name of the timezone and ignored on setCfg()
50 *
51 * 2. name-based (see NOTES below!)
52 * - timezone data identified with a name from the IANA timezone database (aka Olson database)
53 * - #id == 0
54 * - #name is the official IANA timezone name, e.g. Europe/Berlin or America/New_York
55 *
56 * **NOTES**:
57 * - The user frontends currently only support the id-based approach and may not work correctly with
58 * the name-based approach.
59 * - Setting #enableAutoDST to \c true has only an effect if the according ZoneInfo::hasDSTInfo
60 * field is also \c true.
61 */
62 structure ZoneCfg {
63 int id; ///< Selected time zone id
64 string name; ///< Selected time zone name (ignored on setCfg() if id != 0)
65 boolean enableAutoDST; ///< Enable automatic daylight saving time adjustment
66 };
67
68 /** Time synchronization protocol */
69 enumeration Protocol {
70 STATIC, ///< Device time is configured locally
71 NTP ///< Device time is synchronized via NTP
72 };
73
74 /** Static NTP server configuration */
75 structure NtpCfg {
76 string server1; ///< Primary NTP server
77 string server2; ///< Secondary NTP server
78 };
79
80 /** Device date and time configuration */
81 structure Cfg {
82 ZoneCfg zoneCfg; ///< Time zone configuration
83 Protocol protocol; ///< Time synchronization protocol
84 time deviceTime; ///< Device date and time (local time)
85 NtpCfg ntpCfg; ///< NTP server configuration
86 };
87
88 /** Event that is sent when the configuration changes */
89 valueobject ConfigurationChangedEvent extends idl.Event {
90 };
91
92 /** Event that is sent when the device time is changed */
93 valueobject ClockChangedEvent extends idl.Event {
94 time oldTime; ///< Device time before change (UNIX timestamp, UTC)
95 time newTime; ///< Device time after change (UNIX timestamp, UTC)
96 };
97
98 /**
99 * List all supported time zones.
100 *
101 * @param zoneInfos Result: List of time zones
102 * @param useOlson Use Olson timezone names (see also ZoneCfg)
103 */
104 void getZoneInfos(out vector<ZoneInfo> zoneInfos, in boolean useOlson);
105
106 /**
107 * Check if a specified NTP server is usable.
108 *
109 * @param ntpServer NTP server to be checked
110 *
111 * @return \c true if the NTP server is usable
112 */
113 boolean checkNtpServer(in string ntpServer);
114
115 /**
116 * Get active NTP servers.
117 *
118 * @return List of currently active NTP servers (IP addresses and/or hostnames)
119 */
120 vector<string> getActiveNtpServers();
121
122 /**
123 * Retrieve the device date and time configuration.
124 *
125 * @param cfg Result: Current date and time configuration
126 */
127 void getCfg(out Cfg cfg);
128
129 /**
130 * Set the device date and time configuration.
131 * Depending on the value of the \e protocol field either \e deviceTime
132 * or \e ntpCfg will be used from the \e cfg parameter.
133 *
134 * Specific @ref set-timezone-example "example" to set timezone.
135 *
136 * @param cfg New date and time configuration.
137 *
138 * @return 0 if OK
139 * @return 1 if the configuration is invalid
140 */
141 int setCfg(in Cfg cfg);
142
143 /**
144 * Retrieve the current device date and time.
145 *
146 * @param useOlson Use Olson timezone name (see also ZoneCfg)
147 * @param zone Result: Active time zone
148 * @param dstEnabled if false, the time zone daylight saving time flag is not used
149 * @param utcOffset Result: Offset (in minutes) between local time and UTC
150 * @param currentTime Result: Device date and time (UNIX timestamp, UTC)
151 */
152 void getTime(in boolean useOlson, out ZoneInfo zone,
153 out boolean dstEnabled, out int utcOffset,
154 out time currentTime);
155
156 };
157
158}
Date and time configuration methods.
Definition DateTime.idl:26
int setCfg(in Cfg cfg)
Set the device date and time configuration.
Protocol
Time synchronization protocol.
Definition DateTime.idl:69
@ NTP
Device time is synchronized via NTP.
Definition DateTime.idl:71
@ STATIC
Device time is configured locally.
Definition DateTime.idl:70
void getZoneInfos(out vector< ZoneInfo > zoneInfos, in boolean useOlson)
List all supported time zones.
boolean checkNtpServer(in string ntpServer)
Check if a specified NTP server is usable.
vector< string > getActiveNtpServers()
Get active NTP servers.
void getCfg(out Cfg cfg)
Retrieve the device date and time configuration.
void getTime(in boolean useOlson, out ZoneInfo zone, out boolean dstEnabled, out int utcOffset, out time currentTime)
Retrieve the current device date and time.
Device Date and Time Configuration.
Definition DateTime.idl:11
Basic IDL definitions.
Definition Event.idl:10
Device date and time configuration.
Definition DateTime.idl:81
time deviceTime
Device date and time (local time)
Definition DateTime.idl:84
NtpCfg ntpCfg
NTP server configuration.
Definition DateTime.idl:85
Protocol protocol
Time synchronization protocol.
Definition DateTime.idl:83
ZoneCfg zoneCfg
Time zone configuration.
Definition DateTime.idl:82
Event that is sent when the device time is changed.
Definition DateTime.idl:93
time oldTime
Device time before change (UNIX timestamp, UTC)
Definition DateTime.idl:94
time newTime
Device time after change (UNIX timestamp, UTC)
Definition DateTime.idl:95
Event that is sent when the configuration changes.
Definition DateTime.idl:89
Static NTP server configuration.
Definition DateTime.idl:75
string server1
Primary NTP server.
Definition DateTime.idl:76
string server2
Secondary NTP server.
Definition DateTime.idl:77
Time zone configuration.
Definition DateTime.idl:62
boolean enableAutoDST
Enable automatic daylight saving time adjustment.
Definition DateTime.idl:65
int id
Selected time zone id.
Definition DateTime.idl:63
string name
Selected time zone name (ignored on setCfg() if id != 0)
Definition DateTime.idl:64
Time zone information (see also ZoneCfg)
Definition DateTime.idl:35
string name
Time zone name.
Definition DateTime.idl:37
boolean hasDSTInfo
true if the time zone has daylight saving time rules
Definition DateTime.idl:38
Common base for all events.
Definition Event.idl:13