##// END OF EJS Templates
clean abs code
jespinoza -
r315:b3c54f0853ae
parent child
Show More
@@ -396,7 +396,8 class ABSConfiguration(Configuration):
396 status[int(address[0][10:])-1] = '3'
396 status[int(address[0][10:])-1] = '3'
397 elif data == '0':
397 elif data == '0':
398 status[int(address[0][10:])-1] = '1'
398 status[int(address[0][10:])-1] = '1'
399 except:
399 except Exception as e:
400 print 'Error {}'.format(e)
400 n += 1
401 n += 1
401 sock.close()
402 sock.close()
402 else:
403 else:
@@ -492,9 +493,10 class ABSConfiguration(Configuration):
492 multicast_group = ('224.3.29.71', 10000)
493 multicast_group = ('224.3.29.71', 10000)
493 # Create the datagram socket
494 # Create the datagram socket
494 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
495 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
495 sock.settimeout(0.5)
496 sock.settimeout(1)
496 # sock.bind((local_ip, 10000))
497 # sock.bind((local_ip, 10000))
497 local_ip = os.environ.get('LOCAL_IP', '127.0.0.1')
498 local_ip = os.environ.get('LOCAL_IP', '127.0.0.1')
499 local_ip = '192.168.1.128'
498 sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_IF, socket.inet_aton(local_ip))
500 sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_IF, socket.inet_aton(local_ip))
499 sent = sock.sendto(message, multicast_group)
501 sent = sock.sendto(message, multicast_group)
500 print('Sending ' + message)
502 print('Sending ' + message)
@@ -513,6 +515,7 class ABSConfiguration(Configuration):
513 for i in range(32):
515 for i in range(32):
514 #if True:
516 #if True:
515 try:
517 try:
518 address = None
516 data, address = sock.recvfrom(1024)
519 data, address = sock.recvfrom(1024)
517 print address, data
520 print address, data
518 if data == '1':
521 if data == '1':
@@ -552,10 +555,8 class ABSConfiguration(Configuration):
552 confdds = ''
555 confdds = ''
553 confjars = ''
556 confjars = ''
554 confrc = ''
557 confrc = ''
555 print 'Starting...', self.experiment
556 #TO STOP DEVICES: DDS-JARS-RC
558 #TO STOP DEVICES: DDS-JARS-RC
557 for i in range(0,len(confs)):
559 for i in range(0,len(confs)):
558 print i
559 if i==0:
560 if i==0:
560 for conf in confs:
561 for conf in confs:
561 if conf.device.device_type.name == 'dds':
562 if conf.device.device_type.name == 'dds':
@@ -570,12 +571,10 class ABSConfiguration(Configuration):
570 break
571 break
571 if i==2:
572 if i==2:
572 for conf in confs:
573 for conf in confs:
573 print conf
574 if conf.device.device_type.name == 'rc':
574 if conf.device.device_type.name == 'rc':
575 confrc = conf
575 confrc = conf
576 confrc.stop_device()
576 confrc.stop_device()
577 break
577 break
578 print 'Stop devices'
579 if beam_pos > 0:
578 if beam_pos > 0:
580 beam_pos = beam_pos - 1
579 beam_pos = beam_pos - 1
581 else:
580 else:
@@ -585,9 +584,7 class ABSConfiguration(Configuration):
585 #El servidor tcp en el embebido comienza a contar desde 0
584 #El servidor tcp en el embebido comienza a contar desde 0
586 status = ['0'] * 64
585 status = ['0'] * 64
587 message = 'CHGB{}'.format(beam_pos)
586 message = 'CHGB{}'.format(beam_pos)
588 print 'Before send'
589 sock = self.send_multicast(message)
587 sock = self.send_multicast(message)
590 print 'Waiting'
591 for i in range(32):
588 for i in range(32):
592 try:
589 try:
593 data, address = sock.recvfrom(1024)
590 data, address = sock.recvfrom(1024)
@@ -596,7 +593,8 class ABSConfiguration(Configuration):
596 status[int(address[0][10:])-1] = '3'
593 status[int(address[0][10:])-1] = '3'
597 elif data == '0':
594 elif data == '0':
598 status[int(address[0][10:])-1] = '1'
595 status[int(address[0][10:])-1] = '1'
599 except:
596 except Exception as e:
597 print 'Error {}'.format(e)
600 pass
598 pass
601
599
602 sock.close()
600 sock.close()
General Comments 0
You need to be logged in to leave comments. Login now