import json

class SendMessage():
	
	def __init__(self, whid):
		self.whid = whid
		tag_path = "[%s_SCADA_TAG_PROVIDER]System/wbsckt_messages_send" % (whid)
		tags_to_read = system.tag.readBlocking([tag_path])
		self.messages_to_send = system.util.jsonDecode(tags_to_read[0].value)
		system.tag.writeBlocking([tag_path],[system.util.jsonEncode({})])
		self.message_list ={}
	
	def build_message_list(self):
	    if self.messages_to_send:
	        self.message_list = json.dumps(self.messages_to_send)
	    else: 
			self.message_list = None
			
		
		
	
