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
|
# SPDX-License-Identifier: BSD-3-Clause
#
# Copyright 2022 Raritan Inc. All rights reserved.
#
# This is an auto-generated file.
#
# Section generated by IdlC from "DateTime.idl"
#
import raritan.rpc
from raritan.rpc import Interface, Structure, ValueObject, Enumeration, typecheck, DecodeException
import raritan.rpc.datetime
import raritan.rpc.idl
# interface
class DateTime(Interface):
idlType = "datetime.DateTime:3.0.3"
# structure
class ZoneInfo(Structure):
idlType = "datetime.DateTime_3_0_3.ZoneInfo:1.0.0"
elements = ["id", "name", "hasDSTInfo"]
def __init__(self, id, name, hasDSTInfo):
typecheck.is_int(id, AssertionError)
typecheck.is_string(name, AssertionError)
typecheck.is_bool(hasDSTInfo, AssertionError)
self.id = id
self.name = name
self.hasDSTInfo = hasDSTInfo
@classmethod
def decode(cls, json, agent):
obj = cls(
id = json['id'],
name = json['name'],
hasDSTInfo = json['hasDSTInfo'],
)
return obj
def encode(self):
json = {}
json['id'] = self.id
json['name'] = self.name
json['hasDSTInfo'] = self.hasDSTInfo
return json
# structure
class ZoneCfg(Structure):
idlType = "datetime.DateTime_3_0_3.ZoneCfg:1.0.0"
elements = ["id", "name", "enableAutoDST"]
def __init__(self, id, name, enableAutoDST):
typecheck.is_int(id, AssertionError)
typecheck.is_string(name, AssertionError)
typecheck.is_bool(enableAutoDST, AssertionError)
self.id = id
self.name = name
self.enableAutoDST = enableAutoDST
@classmethod
def decode(cls, json, agent):
obj = cls(
id = json['id'],
name = json['name'],
enableAutoDST = json['enableAutoDST'],
)
return obj
def encode(self):
json = {}
json['id'] = self.id
json['name'] = self.name
json['enableAutoDST'] = self.enableAutoDST
return json
# enumeration
class Protocol(Enumeration):
idlType = "datetime.DateTime_3_0_3.Protocol:1.0.0"
values = ["STATIC", "NTP"]
Protocol.STATIC = Protocol(0)
Protocol.NTP = Protocol(1)
# structure
class NtpCfg(Structure):
idlType = "datetime.DateTime_3_0_3.NtpCfg:1.0.0"
elements = ["server1", "server2"]
def __init__(self, server1, server2):
typecheck.is_string(server1, AssertionError)
typecheck.is_string(server2, AssertionError)
self.server1 = server1
self.server2 = server2
@classmethod
def decode(cls, json, agent):
obj = cls(
server1 = json['server1'],
server2 = json['server2'],
)
return obj
def encode(self):
json = {}
json['server1'] = self.server1
json['server2'] = self.server2
return json
# structure
class Cfg(Structure):
idlType = "datetime.DateTime_3_0_3.Cfg:1.0.0"
elements = ["zoneCfg", "protocol", "deviceTime", "ntpCfg"]
def __init__(self, zoneCfg, protocol, deviceTime, ntpCfg):
typecheck.is_struct(zoneCfg, raritan.rpc.datetime.DateTime.ZoneCfg, AssertionError)
typecheck.is_enum(protocol, raritan.rpc.datetime.DateTime.Protocol, AssertionError)
typecheck.is_time(deviceTime, AssertionError)
typecheck.is_struct(ntpCfg, raritan.rpc.datetime.DateTime.NtpCfg, AssertionError)
self.zoneCfg = zoneCfg
self.protocol = protocol
self.deviceTime = deviceTime
self.ntpCfg = ntpCfg
@classmethod
def decode(cls, json, agent):
obj = cls(
zoneCfg = raritan.rpc.datetime.DateTime.ZoneCfg.decode(json['zoneCfg'], agent),
protocol = raritan.rpc.datetime.DateTime.Protocol.decode(json['protocol']),
deviceTime = raritan.rpc.Time.decode(json['deviceTime']),
ntpCfg = raritan.rpc.datetime.DateTime.NtpCfg.decode(json['ntpCfg'], agent),
)
return obj
def encode(self):
json = {}
json['zoneCfg'] = raritan.rpc.datetime.DateTime.ZoneCfg.encode(self.zoneCfg)
json['protocol'] = raritan.rpc.datetime.DateTime.Protocol.encode(self.protocol)
json['deviceTime'] = raritan.rpc.Time.encode(self.deviceTime)
json['ntpCfg'] = raritan.rpc.datetime.DateTime.NtpCfg.encode(self.ntpCfg)
return json
# value object
class ConfigurationChangedEvent(raritan.rpc.idl.Event):
idlType = "datetime.DateTime_3_0_3.ConfigurationChangedEvent:1.0.0"
def __init__(self, source):
super(raritan.rpc.datetime.DateTime.ConfigurationChangedEvent, self).__init__(source)
def encode(self):
json = super(raritan.rpc.datetime.DateTime.ConfigurationChangedEvent, self).encode()
return json
@classmethod
def decode(cls, json, agent):
obj = cls(
# for idl.Event
source = Interface.decode(json['source'], agent),
)
return obj
def listElements(self):
elements = []
elements = elements + super(raritan.rpc.datetime.DateTime.ConfigurationChangedEvent, self).listElements()
return elements
# value object
class ClockChangedEvent(raritan.rpc.idl.Event):
idlType = "datetime.DateTime_3_0_3.ClockChangedEvent:1.0.0"
def __init__(self, oldTime, newTime, source):
super(raritan.rpc.datetime.DateTime.ClockChangedEvent, self).__init__(source)
typecheck.is_time(oldTime, AssertionError)
typecheck.is_time(newTime, AssertionError)
self.oldTime = oldTime
self.newTime = newTime
def encode(self):
json = super(raritan.rpc.datetime.DateTime.ClockChangedEvent, self).encode()
json['oldTime'] = raritan.rpc.Time.encode(self.oldTime)
json['newTime'] = raritan.rpc.Time.encode(self.newTime)
return json
@classmethod
def decode(cls, json, agent):
obj = cls(
oldTime = raritan.rpc.Time.decode(json['oldTime']),
newTime = raritan.rpc.Time.decode(json['newTime']),
# for idl.Event
source = Interface.decode(json['source'], agent),
)
return obj
def listElements(self):
elements = ["oldTime", "newTime"]
elements = elements + super(raritan.rpc.datetime.DateTime.ClockChangedEvent, self).listElements()
return elements
class _getZoneInfos(Interface.Method):
name = 'getZoneInfos'
@staticmethod
def encode(useOlson):
typecheck.is_bool(useOlson, AssertionError)
args = {}
args['useOlson'] = useOlson
return args
@staticmethod
def decode(rsp, agent):
zoneInfos = [raritan.rpc.datetime.DateTime.ZoneInfo.decode(x0, agent) for x0 in rsp['zoneInfos']]
for x0 in zoneInfos:
typecheck.is_struct(x0, raritan.rpc.datetime.DateTime.ZoneInfo, DecodeException)
return zoneInfos
class _checkNtpServer(Interface.Method):
name = 'checkNtpServer'
@staticmethod
def encode(ntpServer):
typecheck.is_string(ntpServer, AssertionError)
args = {}
args['ntpServer'] = ntpServer
return args
@staticmethod
def decode(rsp, agent):
_ret_ = rsp['_ret_']
typecheck.is_bool(_ret_, DecodeException)
return _ret_
class _getActiveNtpServers(Interface.Method):
name = 'getActiveNtpServers'
@staticmethod
def encode():
args = {}
return args
@staticmethod
def decode(rsp, agent):
_ret_ = [x0 for x0 in rsp['_ret_']]
for x0 in _ret_:
typecheck.is_string(x0, DecodeException)
return _ret_
class _getCfg(Interface.Method):
name = 'getCfg'
@staticmethod
def encode():
args = {}
return args
@staticmethod
def decode(rsp, agent):
cfg = raritan.rpc.datetime.DateTime.Cfg.decode(rsp['cfg'], agent)
typecheck.is_struct(cfg, raritan.rpc.datetime.DateTime.Cfg, DecodeException)
return cfg
class _setCfg(Interface.Method):
name = 'setCfg'
@staticmethod
def encode(cfg):
typecheck.is_struct(cfg, raritan.rpc.datetime.DateTime.Cfg, AssertionError)
args = {}
args['cfg'] = raritan.rpc.datetime.DateTime.Cfg.encode(cfg)
return args
@staticmethod
def decode(rsp, agent):
_ret_ = rsp['_ret_']
typecheck.is_int(_ret_, DecodeException)
return _ret_
class _getTime(Interface.Method):
name = 'getTime'
@staticmethod
def encode(useOlson):
typecheck.is_bool(useOlson, AssertionError)
args = {}
args['useOlson'] = useOlson
return args
@staticmethod
def decode(rsp, agent):
zone = raritan.rpc.datetime.DateTime.ZoneInfo.decode(rsp['zone'], agent)
dstEnabled = rsp['dstEnabled']
utcOffset = rsp['utcOffset']
currentTime = raritan.rpc.Time.decode(rsp['currentTime'])
typecheck.is_struct(zone, raritan.rpc.datetime.DateTime.ZoneInfo, DecodeException)
typecheck.is_bool(dstEnabled, DecodeException)
typecheck.is_int(utcOffset, DecodeException)
typecheck.is_time(currentTime, DecodeException)
return (zone, dstEnabled, utcOffset, currentTime)
def __init__(self, target, agent):
super(DateTime, self).__init__(target, agent)
self.getZoneInfos = DateTime._getZoneInfos(self)
self.checkNtpServer = DateTime._checkNtpServer(self)
self.getActiveNtpServers = DateTime._getActiveNtpServers(self)
self.getCfg = DateTime._getCfg(self)
self.setCfg = DateTime._setCfg(self)
self.getTime = DateTime._getTime(self)
|