Index: trunk/Monitoring/Watch/repo-state
===================================================================
--- trunk/Monitoring/Watch/repo-state	(revision 866)
+++ trunk/Monitoring/Watch/repo-state	(revision 866)
@@ -0,0 +1,85 @@
+#!/usr/bin/env python
+
+import curses
+from curses import panel
+
+class Menu(object):
+
+	def __init__(self, items, stdscreen):
+		self.window = stdscreen.subwin(0,0)
+		self.window.keypad(1)
+		self.panel = panel.new_panel(self.window)
+		self.panel.hide()
+		panel.update_panels()
+
+		self.position = 0
+		self.items = items
+		self.items.append(('exit','exit'))
+
+	def navigate(self, n):
+		self.position += n
+		if self.position < 0:
+			self.position = 0
+		elif self.position >= len(self.items):
+			self.position = len(self.items)-1
+
+	def display(self):
+		self.panel.top()
+		self.panel.show()
+		self.window.clear()
+
+
+		while True:
+			self.window.refresh()
+			curses.doupdate()
+			for index, item in enumerate(self.items):
+				if index == self.position:
+					mode = curses.A_REVERSE
+				else:
+					mode = curses.A_NORMAL
+
+				msg = '%d. %s' % (index, item[0])
+				self.window.addstr(1+index, 1, msg, mode)
+
+			key = self.window.getch()
+
+			if key in [curses.KEY_ENTER, ord('\n')]:
+				if self.position == len(self.items)-1:
+					break
+				else:
+					self.items[self.position][1]()
+
+			elif key == curses.KEY_UP:
+				self.navigate(-1)
+
+			elif key == curses.KEY_DOWN:
+				self.navigate(1)
+
+		self.window.clear()
+		self.panel.hide()
+		panel.update_panels()
+		curses.doupdate()
+
+
+class MyApp(object):
+
+	def __init__(self, stdscreen):
+		self.screen = stdscreen
+		curses.curs_set(0)
+
+		submenu_items = [
+				('beep', curses.beep),
+				('flash', curses.flash)
+				]
+		submenu = Menu(submenu_items, self.screen)
+
+		main_menu_items = [
+				('beep', curses.beep),
+				('flash', curses.flash),
+				('submenu', submenu.display)
+				]
+		main_menu = Menu(main_menu_items, self.screen)
+		main_menu.display()
+
+if __name__ == '__main__':
+	curses.wrapper(MyApp)
Index: trunk/Monitoring/Watch/watch
===================================================================
--- trunk/Monitoring/Watch/watch	(revision 865)
+++ trunk/Monitoring/Watch/watch	(revision 866)
@@ -26,6 +26,6 @@
 sys.path.append("/home/jripsl/snapshot/Monitoring")
 
-import smon.repo_io
-
+import smon.repo_io as repo_io
+import smon.types
 
 """
@@ -66,16 +66,20 @@
 
 	@classmethod
-	def store_msg(cls):
-		repo_io.store_messages(name)
-
-	@classmethod
-	def set_sim_status_to_error(cls):
+	def store_msg(cls,message):
+		repo_io.create_message(message)
+
+	@classmethod
+	def set_sim_status_to_error(cls,message):
 		repo_io.update_simulation_status()
 
 	@classmethod
-	def crea_sim(cls):
+	def crea_sim(cls,message):
+
 		#repo_io.retrieve_simulation(name)
 		#repo_io.delete_simulation(name)
-		repo_io.create_simulation()
+
+		simulation=smon.types.Simulation(name=message.simuid)
+
+		repo_io.create_simulation(simulation)
 
 	@classmethod
@@ -88,17 +92,17 @@
 
 		if "file" in message:
-			print "%s %s %s\n"%(message["code"],message["jobid"],message["file"])
+			print "%s %s %s\n"%(message.code,message.jobid,message.file)
 		else:
-			print "%s %s\n"%(message["code"],message["jobid"])
+			print "%s %s\n"%(message.code,message.jobid)
 
 	@classmethod
 	def log(cls,message):
 		with open("/home/jripsl/supervisor/log/supervisor.log", "a") as log_file:
-			log_file.write("%s %s %s\n"%(datetime.now().strftime('%Y%m%d_%H%M%S'), message["code"],message["jobid"]))
+			log_file.write("%s %s %s\n"%(datetime.now().strftime('%Y%m%d_%H%M%S'), message.code,message.jobid))
 
 	@classmethod
 	def execActions(cls,message):
 
-		message_code=message["code"]
+		message_code=message.code
 
 		for action in MessageActionsMapping.mapping[message_code]:
@@ -155,21 +159,66 @@
 
 		def callback(ch, method, properties, raw_msg):
-			#
-			#return
-
-			base64_decoded_msg=base64.b64decode(raw_msg)
+
+			# msg fmt: body:base64,file:base64 (no JSON here !!!)
+
+
+
+
+			# first deserialization (no JSON here !!!)
+
+			fields=raw_msg.split(",")
+
+			l__tmp_dic={}
+
+			for field in fields:
+
+				# debug
+				print " [x] Received %s" % field
+
+				splitted_field=field.split(":")
+
+				key=splitted_field[0]
+				val=splitted_field[1]
+
+				l__tmp_dic[key]=val
+
+
+			# debug
+			print " [x] Received %s (encoded)" % l__tmp_dic["body"]
+
+			
+			# base64 decode body
+			base64_decoded_msg=base64.b64decode(l__tmp_dic["body"])
+
 
 			# debug
 			#print " [x] Received %s" % raw_msg
+			print " [x] Received %s (uudecoded)" % base64_decoded_msg 
 			#print " [x] Received %s (uudecoded)" % base64_decoded_msg 
+
 
 			message=None
 			try:
-				message=json.loads(base64_decoded_msg)
+				# body deserialization 
+				JSON_msg=json.loads(base64_decoded_msg)
+				message=smon.types.Message(JSON_msg)      # all JSON object members will be available in smon.types.Message object
+
+				if "file" in l__tmp_dic:
+
+					# base64 decode file
+					base64_decoded_file=base64.b64decode(l__tmp_dic["file"])
+
+					# add into msg
+					message.file=base64_decoded_file
 
 				# message code based action
-				Watcher.execActions(message)
+				Actions.execActions(message)
+
 			except Exception,e:
 				print "Exception occurs (exception=%s,msg=%s)"%(str(e),base64_decoded_msg)
+
+				#traceback.print_exc()
+
+				raise
 
 		self.channel.basic_consume(callback, queue='myqueue', no_ack=True)
@@ -198,5 +247,5 @@
 	except Exception, e:
 
-		traceback.print_exc()
+		#traceback.print_exc()
 
 		sys.exit(1)
