Permalink
Browse files

lol

  • Loading branch information...
1 parent bc4fbdb commit 54d5c529529b757dbde828fe75c734c2e2a04021 @technocake technocake committed Mar 26, 2013
View
@@ -1,9 +1,9 @@
Bit Pin Farge
-A 2 dark orange
-B 1 light orange
-C 6 dark green
-D 3 light green
-E 4 dark blue blå
-F 5 light blue
-G 8 dark brown
-H 7 light brown
+1A 2 dark orange
+2B 1 light orange
+3C 6 dark green
+4D 3 light green
+5E 4 dark blue
+6F 5 light blue
+7G 8 dark brown
+8H 7 light brown
@@ -4,5 +4,6 @@
COM_PORT = '/dev/tty.usbmodemfd121'
URL = "File:///Users/technocake/code/pizza-netmap2/nms-simulator/switchlist.txt"
POLL_INTERVAL = 5 #Seconds between update
-
+COLOR_SUPPORT = False
+SWITCH_DELIM = "\s"
# END CONFIG
View
@@ -0,0 +1,11 @@
+#!/usr/bin/env python
+# coding: utf-8
+#CONFIG
+
+COM_PORT = '/dev/tty.usbmodemfd121'
+URL = "File:///Users/technocake/code/pizza-netmap2/nms-simulator/switchlist.txt"
+POLL_INTERVAL = 5 #Seconds between update
+COLOR_SUPPORT = False
+SWITCH_DELIM = "\s"
+
+# END CONFIG
View
Binary file not shown.
View
@@ -10,20 +10,23 @@
import string
import re
-
-URL = "http://www.komsys.org/pizza-netmap/src/pizza-netmap2/nms-simulator/switchlist.txt"
-
-
-statusmap = [ re.split("\s", string.rstrip(u)) for u in urllib2.urlopen(URL).readlines() ]
-
-
-
-
-def color(i):
+from config import *
+#URL = "http://www.komsys.org/pizza-netmap/src/pizza-netmap2/nms-simulator/switchlist.txt"
+
+statusmap = [ re.split(SWITCH_DELIM, string.rstrip(u)) for u in urllib2.urlopen(URL).readlines() ]
+
+BOLD = '\033[1m'
+ENDC = '\033[0m'
+def color(i ,binary=False):
+ if binary and not COLOR_SUPPORT:
+ return ''
+ elif binary:
+ return ['\033[91m' , '\033[93m', '\033[92m', '\033[82m', '\033[94m', '\033[096m', '\033[090m', '\033[097m' ][i]
try:
return ["dark orange", "light orange", "dark green", "light green", "dark blue", "light blue", "dark brown", "light brown"][i]
except:
print "ERROR color"
+ return ''
@@ -41,7 +44,7 @@ def patchPins(lvl, c,d,p,n):
while pin <= 8:
if (n >= len(statusmap)):
return n,res
- res += "%s%s %u.%u.%u.%u (%s)\n" % ("\t"*lvl, statusmap[n-1][0], c,d,p,pin, color(pin-1))
+ res += "%s%s %u.%u.%u.%u (%s%s%s%s)\n" % ("\t"*lvl, statusmap[n-1][0], c,d,p,pin, BOLD, color(pin-1, True), color(pin-1), ENDC)
pin += 1
n += 1
return n, res
@@ -88,13 +91,5 @@ def patchCores(lvl=0,c=1,d=1,p=1,n=1 ):
return res
print ( patchCores())
-
-
-
-
-
-
-
-
View
@@ -12,7 +12,7 @@
#
# Config is in config.py. Edit that file.
##
-from config import *
+
# END CONFIG
@@ -25,7 +25,6 @@
def list_com_ports():
from serial.tools import list_ports
-
return "Choose serial device / COM port: \n %s" % '\n'.join(list("\t[%u] : %s" % (i, u[0]) for i,u in enumerate( list_ports.comports() )))
@@ -35,12 +34,31 @@ def list_com_ports():
print ("Init")
print ( list_com_ports())
+
+ from config import *
api = pnmp.api(COM_PORT)
+ #todo, implement..
+ #n_cores, distros_in_cores = api.getNetworkGraph()
+
+ print (
+ """
+ Pizzadaemon
+
+ ________________________________________________
+
+ Cores: %d\t Distros, per core: %s\t
+
+ """ % (2, str([3,2]))
+
+
+
+ )
+
try:
while 1:
- statusmap = [ re.split("\s", string.rstrip(u)) for u in urllib2.urlopen(URL).readlines() ]
+ statusmap = [ re.split(SWITCH_DELIM, string.rstrip(u)) for u in urllib2.urlopen(URL).readlines() ]
print ("Pushing state")
print (statusmap)
api.pushState(statusmap)
View
@@ -25,6 +25,8 @@ class api():
PUSHSTATE = [0xF0, 0xF1] #1 bit signaling command and not data (first)
WRITE_LED = [0xF2]
+ GET_NETWORK_GRAPH = [0xF3]
+
def __init__(self, COM_PORT, BAUD_RATE=9600):
@@ -47,9 +49,6 @@ def __init__(self, COM_PORT, BAUD_RATE=9600):
except Exception as e:
print ("error, %s" % e )
self.clean_the_mess_up_after_you() #die
-
-
-
def mapNodes(self, nodemap):
View
Binary file not shown.
Oops, something went wrong.

0 comments on commit 54d5c52

Please sign in to comment.