def __init__(self, name, canid, subscriptions, pack_template, var_names, topic_template, payload_template):
self.name= name
if not isinstance(canid, basestring) and not isinstance(canid, int):
raise ValueError("Parameter canid must be a string or an int")
if isinstance(canid, basestring):
try:
canid= int(canid, 0)
except:
pass
self.subscriptions= testForStringList(subscriptions, "subscriptions")
if not isinstance(pack_template, basestring):
raise ValueError("Parameter pack_template must be a string")
self.canid= canid
self.pack_template= pack_template
self.var_names= testForStringList(var_names, "var_names")
if topic_template:
if not isinstance(topic_template, basestring):
raise ValueError("Parameter topic_template must be a string")
try:
self.topic_template= parse.compile(topic_template)
except BaseException as e:
raise ValueError("Error compiling topic_template: %s" % e)
else:
self.topic_template= None
if not isinstance(payload_template, basestring):
raise ValueError("Parameter payload_template must be a string")
try:
self.payload_template= parse.compile(payload_template)
except BaseException as e:
raise ValueError("Error compiling payload_template: %s" % e)
self.error_count= 0
评论列表
文章目录