예제 #1
0
 def processDawnDusk(l):
   d = codec.DAWN_DUSK_ENTRY.createDataMap()
   utils.merge_dict_if_not_default(l, d, "reserved_1", 0)
   utils.merge_dict_if_not_default(l, d, "reserved_2", 0)
   d["start_double_hour"], d["start_min"] = utils.timespec_to_x10_time(l["rise"])
   d["stop_double_hour"],  d["stop_min"]  = utils.timespec_to_x10_time(l["set"])
   return d
예제 #2
0
 def toJSON(self):
   d = dict()
   utils.merge_dict_if_not_default(vars(self), d, "reserved", 0)
   utils.merge_dict_if_not_default(vars(self), d, "clauses", None)
   d["house_code"]  = codec.VALUE_TO_HOUSECODE_MAP[self.house_code]
   d["unit_code"] = codec.VALUE_TO_UNITCODE_MAP[self.unit_code]
   d["trigger_on_off"] = self.trigger_on_off and "on" or "off"
   d["macro_id"] = self.macro_ptr
   utils.convert_key_to_hex_string(d, "macro_id")
   return d
예제 #3
0
 def toJSON(self):
   l = super(self.__class__, self).toJSON()
   time = None
   if self.is_variable:
     if self.sunrise:
       time = "Sunrise"
     else:
       time = "Sunset"
   else:
     time = utils.x10_time_to_string(self.double_hour, self.min)
   l["time"] = time
   utils.merge_dict_if_not_default(vars(self), l, "reserved", 0)
   return l
예제 #4
0
 def fromJSON(cls, jsonData):
   data = dict()
   utils.merge_dict_if_not_default(jsonData, data, "dst_data", None)
   def processArray(key, clz):
     data[key] = [clz.fromJSON(m) for m in jsonData[key]]
   processArray("macro_chains", MacroChain)
   processArray("macro_initiators", MacroInitiator)
   processArray("timer_initiators", TimerInitiator)
   def processDawnDusk(l):
     d = codec.DAWN_DUSK_ENTRY.createDataMap()
     utils.merge_dict_if_not_default(l, d, "reserved_1", 0)
     utils.merge_dict_if_not_default(l, d, "reserved_2", 0)
     d["start_double_hour"], d["start_min"] = utils.timespec_to_x10_time(l["rise"])
     d["stop_double_hour"],  d["stop_min"]  = utils.timespec_to_x10_time(l["set"])
     return d
   data["sunrise_sunset_times"] = [processDawnDusk(l) for l in jsonData["sunrise_sunset_times"]]
   return cls(data)
예제 #5
0
 def toJSON(self):
   t = vars(self)
   tijson = utils.merge_dict(t, None, "start_macro_ptr", "stop_macro_ptr", "start_macro_id", "stop_macro_id")
   utils.convert_key_to_hex_string(tijson, "start_macro_ptr", "stop_macro_ptr", "start_macro_id", "stop_macro_id")
   if utils.merge_dict_if_not_default(t, tijson, "begin_year_day", 0):
     tijson["begin_date"] = utils.x10_year_day_to_string(t["begin_year_day"])
   if utils.merge_dict_if_not_default(t, tijson, "end_year_day", 367):
     tijson["end_date"] = utils.x10_year_day_to_string(t["end_year_day"])
   utils.merge_dict_if_not_default(t, tijson, "start_security", 0)
   utils.merge_dict_if_not_default(t, tijson, "stop_security", 0)
   tijson["start_time"] = utils.x10_time_to_string(t["start_double_hour"], t["start_min"])
   tijson["stop_time"] = utils.x10_time_to_string(t["stop_double_hour"], t["stop_min"])
   tijson["week_day_mask"] = utils.week_mask_to_string(t["week_day_mask"])
   return tijson
예제 #6
0
 def processDawnDusk(l):
   da = {"rise": utils.x10_time_to_string(l["start_double_hour"], l["start_min"]), \
                           "set": utils.x10_time_to_string(l["stop_double_hour"], l["stop_min"])}
   utils.merge_dict_if_not_default(l, da, "reserved_1", 0)
   utils.merge_dict_if_not_default(l, da, "reserved_2", 0)
   return da
예제 #7
0
 def toJSON(self):
   l = super(self.__class__, self).toJSON()
   l["Criteria"] = self.type == CLAUSE_TYPE_MODULES_ON and "on" or "off"
   utils.merge_dict_if_not_default(vars(self), l, "modules", None)
예제 #8
0
 def toJSON(self):
   l = super(self.__class__, self).toJSON()
   l["criteria"] = self.type == CLAUSE_TYPE_FLAGS_ON and "on" or "off"
   utils.merge_dict_if_not_default(vars(self), l, "flags", None)
   return l
예제 #9
0
 def toJSON(self):
   l = super(self.__class__, self).toJSON()
   l["week_day_mask"] = utils.week_mask_to_string(self.week_day_mask)
   utils.merge_dict_if_not_default(vars(self), l, "reserved_1", 0)
   utils.merge_dict_if_not_default(vars(self), l, "reserved_2", 0)
   return l
예제 #10
0
 def toJSON(self):
   l = super(self.__class__, self).toJSON()
   utils.merge_dict_if_not_default(vars(self), l, "year_day", None)
   l["date"] = utils.x10_year_day_to_string(self.year_day)
   utils.merge_dict_if_not_default(vars(self), l, "reserved", 0)
   return l
예제 #11
0
 def toJSON(self):
   l = {"logic_op": codec.MACRO_INITIATOR_HEADER_LOGIC_OPS[self.logic_op],
        "compare_op": codec.MACRO_INITIATOR_HEADER_COMPARE_OPS[self.compare_op]}
   utils.merge_dict_if_not_default(vars(self), l, "hdr_reserved_1", 0)
   utils.merge_dict_if_not_default(vars(self), l, "hdr_reserved_2", 0)
   return l