예제 #1
0
  def setPause(self, pluginAction, dev):
    newValue = pluginAction.props.get(u"pauseRun", False)

    m = Magiccolor()
    m.connect()
    p = Protocol()
    p.keyNum=p.MODE_PAUSE

    indigo.server.log("%d" % newValue)

    if newValue:
      p.keyValue=1
    else:
      p.keyValue=0

    m.sendMsg(p)
    sendSuccess = True    # Set to False if it failed.

    if sendSuccess:
      # If success then log that the command was successfully sent.
      indigo.server.log(u"sent \"%s\" %s to %d" % (dev.name, "pause", newValue))

      # And then tell the Indigo Server to update the state:
      dev.updateStateOnServer("pauseRun", newValue)
    else:
      # Else log failure but do NOT update state on Indigo Server.
      indigo.server.log(u"send \"%s\" %s to %d failed" % (dev.name, "set pause", newValue), isError=True)
예제 #2
0
    def launch_protocol(self):
        #self.thread_onoff = False
        print('nb proie = ', self.nb_prey.get(), 'nb chasseur = ',
              self.nb_hunter.get())
        print('largeur = ', self.width_grid.get(), 'hauteur = ',
              self.height_grid.get())
        print('ratio = ', self.ratio_grid.get())

        self.protocols.append(
            Protocol(nb_hunter=self.nb_hunter.get(),
                     nb_prey=self.nb_prey.get(),
                     ratio=self.ratio_grid.get(),
                     time_limit=self.time_limit.get(),
                     width_grid=self.width_grid.get(),
                     height_grid=self.height_grid.get(),
                     wall=self.wall.get(),
                     id_protocol=self.nb_protocol,
                     experience=self,
                     detection_range_prey=self.detection_range_prey.get(),
                     detection_range_hunter=self.detection_range_hunter.get()))
        self.nb_protocol += 1
        for p in self.protocols:
            print(p.grid.map)
            print(p.agents)
            print("Id ", p.id_protocol, " : ", p.run)
예제 #3
0
  def setSpeed(self, pluginAction, dev):
    try:
      newValue = int(pluginAction.props.get(u"speed", 100))
    except ValueError:
      # The int() cast above might fail if the user didn't enter a number:
      indigo.server.log(u"set speed to device \"%s\" -- invalid value" % (dev.name), isError=True)
      return

    m = Magiccolor()
    m.connect()
    p = Protocol()
    p.keyNum=p.MODE_SPEED
    p.keyValue=newValue
    m.sendMsg(p)

    sendSuccess = True    # Set to False if it failed.

    if sendSuccess:
      # If success then log that the command was successfully sent.
      indigo.server.log(u"sent \"%s\" %s to %d" % (dev.name, "set speed", newValue))

      # And then tell the Indigo Server to update the state:
      dev.updateStateOnServer("programNumber", newValue)
    else:
      # Else log failure but do NOT update state on Indigo Server.
      indigo.server.log(u"send \"%s\" %s to %d failed" % (dev.name, "set speed", newValue), isError=True)
예제 #4
0
파일: SimNode.py 프로젝트: nvt/procnet
 def start(self):
     logging.info("Starting node {}".format(self.node_id))
     child_read_fd, self.write_fd = os.pipe()
     self.read_fd, child_write_fd = os.pipe()
     self.pid = os.fork()
     sys.stderr.flush()
     sys.stdout.flush()
     if self.pid != 0:
         # In the parent process.
         os.close(child_read_fd)
         os.close(child_write_fd)
         self.proto = Protocol.Protocol(self)
     else:
         # In the child process.
         os.dup2(child_read_fd, 0)
         os.dup2(child_write_fd, 1)
         os.dup2(child_write_fd, 2)
         argv = self.node_type.args.split()
         argv.insert(0, self.node_type.path)
         env = os.environ
         env['PROCNET_URI'] = "tcp://localhost:14395"
         env['PROCNET_AUTH_TOKEN'] = self.token
         try:
             os.execvpe(self.node_type.path, argv, env)
         except FileNotFoundError:
             os._exit(1)
예제 #5
0
    def __init__(self):

        self.Protocol = Protocol.Protocol()
        self.FieldManager = FieldManager.FieldManager()
        self.ConstructManager = ConstructManager.ConstructManager()
        self.StartNode = StartNode.StartNode("Name", "Protocol Desciption", "Dependent Protocol Name", "Dependency Pattern")
        self.EndNode = EndNode.EndNode()
예제 #6
0
	def main(self):
		(self.options, args) = self.parser.parse_args()
		#print("===================================")
		#print(self.options, args)
		#self.usage()
		#print(self.config)
		#print("===================================")
		protocol = Protocol()
		
		if self.options.id2ip :
			print(protocol.id2ip(int(self.options.cai), int(self.options.id2ip)))
		elif self.options.ip2id :
			print(protocol.ip2id(str(self.options.ip2id)))
		elif self.options.tms :
			tms = TMS()
			tms.sendtoid(int(self.options.cai), int(self.options.tms), args[0])
		elif self.options.route :
                        print("Please add the following route:")
                        print("route add %s.0.0.0 mask 255.0.0.0 192.168.11.1" % self.options.cai)
		elif self.options.ping :
                        os.system("ping %s" % self.options.ping)
		elif self.options.online :
                        os.system("ping %s" % protocol.id2ip(int(self.options.cai), int(self.options.online))) 
		else:
			self.usage()
예제 #7
0
 def __init__(self, root, server):
     self._root = root
     self.server = server
     self.poller = Multiplexer.BestMultiplexer()
     self.socketmap = {}
     self.workers = []
     self.protocol = Protocol.Protocol(root, self)
     # legacy vars
     self.thread = thread.get_ident()
     self.num = 0
예제 #8
0
 def main(self):
     (self.options, args) = self.parser.parse_args()
     print("===================================")
     print(self.options, args)
     #self.usage()
     #print(self.config)
     print("===================================")
     if self.options.id2ip:
         protocol = Protocol()
         print(protocol.id2ip(int(self.options.id2ip)))
     if self.options.ip2id:
         protocol = Protocol()
         print(protocol.ip2id(str(self.options.ip2id)))
     if self.options.tms:
         tms = TMS()
         tms.sendtoid(int(self.options.cai), int(self.options.tms),
                      args[0].replace(";", "\n"))
     else:
         self.usage()
예제 #9
0
def example_protocol():
    sf = StartField.StartField(
        'myProtocol',
        'This is an example protocol that says the second byte is the amount of wins I have if the first bit in the first byte is bigger than 8, otherwise it is the number of losses'
    )

    sf.set_dependency_pattern('Integer')
    sf.set_dependency_protocol('Dependent protocol')

    f1 = Field.Field(1)

    sf.set_next_constructs([f1])

    f1.set_field_info('TypeBitCheck', 'check', 'Checks first bit',
                      'ftypes.UINT8', 'base.HEX', '0x80', '?', 'True')

    ref_list = ReferenceList.ReferenceList('ref_list')
    ref_list.set_descriptions(['is a value'])
    ref_list.set_values(['13'])

    f1.set_ref_list(ref_list)

    expr1 = Expression.Expression()
    expr1.set_relational_operators(['>='])
    expr1.set_operands(['8'])

    expr2 = Expression.Expression()
    expr2.set_relational_operators(['<'])
    expr2.set_operands(['8'])

    dc = DecisionConstruct.DecisionConstruct()
    dc.set_expressions([expr1, expr2])
    f1.set_next_constructs([dc])

    f2 = Field.Field(1)
    f2.set_field_info('Number of wins', 'wins', 'Is the number of wins',
                      'ftypes.UINT8', 'base.HEX', '0xff', '?', 'True')

    f3 = Field.Field(1)
    f3.set_field_info('Number of loses', 'loses', 'Is the number of loses',
                      'ftypes.UINT8', 'base.HEX', '0xff', '?', 'True')

    dc.set_next_constructs([f2, f3])
    end_field = EndField.EndField()

    f2.set_next_constructs([end_field])
    f3.set_next_constructs([end_field])

    protocol = Protocol.Protocol()
    protocol_structure = protocol.get_protocol_structure(sf)
    return protocol_structure
예제 #10
0
파일: tms.py 프로젝트: yaocl/Mototrbo
class TMSHandler(socketserver.BaseRequestHandler):

    protocol = Protocol()

    def handle(self):
        data = self.request[0]
        #.strip()
        socket = self.request[1]
        print("{} wrote:".format(self.client_address[0]))
        #print(self.client_address)
        tms = TMS(data)
        #print(data)
        #print(data.decode(encoding='UTF-16'))
        print(tms.decode())
예제 #11
0
 def parseProto(self):
     tree = ET.ElementTree(ET.fromstring(self.plainXML))
     root = tree.getroot()
     # Getting all the protocols
     for child in root:
         # Attributes of protocol
         protoName = child.get("name")
         protoShowname = child.get("showname")
         protoSize = child.get("size")
         protoPos = child.get("pos")
         protoValue = child.get("value")
         protoShow = child.get("show")
         plainXML = ET.tostring(child, encoding='utf8').decode('utf8')
         currProto = Protocol.Protocol(protoName, protoShowname, protoSize,
                                       protoPos, protoShow, protoValue,
                                       plainXML)
         self.protoList.append(currProto)
예제 #12
0
    def _rebind_slow(self):
        try:
            self.protocol = Protocol.Protocol(self)
            for channel in dict(
                    self.channels
            ):  # hack, but I guess reloading is all a hack :P
                chan = self.channels[channel].copy()
                del chan['name']  # 'cause we're passing it ourselves
                self.channels[channel] = Protocol.Channel.Channel(
                    self, channel, **chan)

            self.userdb = SQLUsers.UsersHandler(self, self.engine)
            self.channeldb = SQLUsers.ChannelsHandler(self, self.engine)
            self.chanserv.reload()
            for clientid, client in self.clients.iteritems():
                client._root = self
        except:
            self.error(traceback.format_exc())

        self.admin_broadcast('Done reloading.')
        self.console_write('Done reloading.')
예제 #13
0
파일: main.py 프로젝트: iotsysterm/RBMaster
    def callback(self, data):
        self.logger.info('recv from server : %s' % binascii.b2a_hex(data))
        pro = Protocol.decode(data)

        if (pro.head != 0xEC or pro.tail != 0xEA):
            return
        # 服务器认证
        if (pro.cmd == MASTER_AUTHOR):
            ip = "%d.%d.%d.%d" % (pro.state, pro.R, pro.G, pro.B)
            port = pro.deviceID
            self.client = RBClient(ip, port)
            protocol = Protocol(SUB_AUTHOR, pro.masterID)
            self.client.sendData(protocol.command())
            self.client.recvData(self.callback)
        # 控制设备
        if (pro.cmd == 0x03):
            light = C4Light()
            if pro.state:
                light.powerOn(pro.deviceID)
            else:
                light.powerOff(pro.deviceID)
예제 #14
0
  def actionControlDimmerRelay(self, action, dev):
    m = Magiccolor()
    m.connect()
    p = Protocol()
    ###### TURN ON ######
    if action.deviceAction == indigo.kDimmerRelayAction.TurnOn:
      # Command hardware module (dev) to turn ON here:
      p.keyNum=p.MODE_ON
      p.keyValue=p.findProgram("WHITE")
      m.sendMsg(p)
      sendSuccess = True    # Set to False if it failed.

      if sendSuccess:
        # If success then log that the command was successfully sent.
        indigo.server.log(u"sent \"%s\" %s" % (dev.name, "on"))

        # And then tell the Indigo Server to update the state.
        dev.updateStateOnServer("onOffState", True)
      else:
        # Else log failure but do NOT update state on Indigo Server.
        indigo.server.log(u"send \"%s\" %s failed" % (dev.name, "on"), isError=True)

    ###### TURN OFF ######
    elif action.deviceAction == indigo.kDimmerRelayAction.TurnOff:
      # Command hardware module (dev) to turn OFF here:
      p.keyNum=p.MODE_OFF
      m.sendMsg(p)
      sendSuccess = True    # Set to False if it failed.

      if sendSuccess:
        # If success then log that the command was successfully sent.
        indigo.server.log(u"sent \"%s\" (%s) %s" % (dev.name, dev.address, "off") )

        # And then tell the Indigo Server to update the state:
        dev.updateStateOnServer("onOffState", False)
      else:
        # Else log failure but do NOT update state on Indigo Server.
        indigo.server.log(u"send \"%s\" %s failed" % (dev.name, "off"), isError=True)

    ###### TOGGLE ######
    elif action.deviceAction == indigo.kDimmerRelayAction.Toggle:
      # Command hardware module (dev) to toggle here:
      newOnState = not dev.onState
      
      if newOnState == False:
        p.keyNum=p.MODE_OFF
      else:
        p.keyNum=p.MODE_ON
        p.keyValue=p.findProgram("WHITE")
      m.sendMsg(p)

      sendSuccess = True    # Set to False if it failed.

      if sendSuccess:
        # If success then log that the command was successfully sent.
        indigo.server.log(u"sent \"%s\" %s" % (dev.name, "toggle"))

        # And then tell the Indigo Server to update the state:
        dev.updateStateOnServer("onOffState", newOnState)
      else:
        # Else log failure but do NOT update state on Indigo Server.
        indigo.server.log(u"send \"%s\" %s failed" % (dev.name, "toggle"), isError=True)

    ###### SET BRIGHTNESS ######
    elif action.deviceAction == indigo.kDimmerRelayAction.SetBrightness:
      # Command hardware module (dev) to set brightness here:
      # 
      # We're kinda lame here. We actually use brightness as a program 
      # so that the slider works. oh well!
      newBrightness = action.actionValue
      p.keyNum=p.MODE_ON
      p.keyValue=newBrightness
      m.sendMsg(p)
      sendSuccess = True    # Set to False if it failed.

      if sendSuccess:
        # If success then log that the command was successfully sent.
        indigo.server.log(u"sent \"%s\" %s to %d" % (dev.name, "set brightness", newBrightness))

        # And then tell the Indigo Server to update the state:
        dev.updateStateOnServer("brightnessLevel", newBrightness)
      else:
        # Else log failure but do NOT update state on Indigo Server.
        indigo.server.log(u"send \"%s\" %s to %d failed" % (dev.name, "set brightness", newBrightness), isError=True)

    ###### BRIGHTEN BY ######
    elif action.deviceAction == indigo.kDimmerRelayAction.BrightenBy:
      # Command hardware module (dev) to do a relative brighten here:
      newBrightness = dev.brightness + action.actionValue

      p.keyNum=p.MODE_ON
      p.keyValue=newBrightness
      m.sendMsg(p)

      if newBrightness > 100:
        newBrightness = 100
      sendSuccess = True    # Set to False if it failed.

      if sendSuccess:
        # If success then log that the command was successfully sent.
        indigo.server.log(u"sent \"%s\" %s to %d" % (dev.name, "brighten", newBrightness))

        # And then tell the Indigo Server to update the state:
        dev.updateStateOnServer("brightnessLevel", newBrightness)
      else:
        # Else log failure but do NOT update state on Indigo Server.
        indigo.server.log(u"send \"%s\" %s to %d failed" % (dev.name, "brighten", newBrightness), isError=True)

    ###### DIM BY ######
    elif action.deviceAction == indigo.kDimmerRelayAction.DimBy:
      # Command hardware module (dev) to do a relative dim here:
      newBrightness = dev.brightness - action.actionValue
      if newBrightness < 0:
        newBrightness = 0

      p.keyNum=p.MODE_ON
      p.keyValue=newBrightness
      m.sendMsg(p)

      sendSuccess = True    # Set to False if it failed.

      if sendSuccess:
        # If success then log that the command was successfully sent.
        indigo.server.log(u"sent \"%s\" %s to %d" % (dev.name, "dim", newBrightness))

        # And then tell the Indigo Server to update the state:
        dev.updateStateOnServer("brightnessLevel", newBrightness)
      else:
        # Else log failure but do NOT update state on Indigo Server.
        indigo.server.log(u"send \"%s\" %s to %d failed" % (dev.name, "dim", newBrightness), isError=True)
예제 #15
0
파일: run_ctrl.py 프로젝트: nfredrik/pyjunk
            parser.get('mail', 'username'),
            parser.get('mail', 'password'),
            parser.get('mail', 'smtpserver'),
           )

# Setup a file event handler
event_handler = MyEventHandler(logger, on_file_change, file2change = 'nisse.txt')
observer = Observer()
observer.schedule(event_handler, FILEWATCH_DIR, recursive=True)
observer.start()

# FIXME : Create a data object
io = NewLoopDataObject()

# FIXME : Create a protocol
protocol = Protocol(io)

generator = TrafficGenerator(protocol, logger)
# FIXME : Create an instance of a traffic generator

try:
    while True:
        time.sleep(1)
        if event.isSet():
            # FIXME: implement a protocol to send a message to the printer over a
            #        serial line 
            print parser.get('printer', 'message')
            generator.generatePrintStatus()
            event.clear() 

except KeyboardInterrupt:
예제 #16
0
파일: main.py 프로젝트: iotsysterm/RBMaster
    def connect(self, ip, port, masterID):
        client = RBClient(ip, port)

        protocol = Protocol(MASTER_AUTHOR, masterID)
        client.sendData(protocol.command())
        client.recvData(self.callback)
예제 #17
0
    def parse_assay(self):
        subExperiment = SubExperiment.SubExperiment()
        value = self.get_value('Study Experiments Number')

        if value:
            project_ids = []
            with open('./input', 'r') as f:
                lines = f.readlines()
                for idx, val in enumerate(lines):
                    if self.study_number in val:
                        project_id = val.split(":")[1].strip()
                        project_ids.append(project_id)
            for i in range(1, int(value) + 1):
                lines = self.get_lines(i, 'Experiment')
                self.subexperiment = URIRef(
                    self.graph.reproduce['SubExperiment' + '_' +
                                         self.study_number + '_' + str(i)])
                self.g.add((self.subexperiment, RDF.type,
                            URIRef(self.graph.pplan["Step"])))
                self.parse(self.subexperiment,
                           subExperiment.mapping,
                           lines=lines)
                self.g.add((self.subexperiment, self.graph.pplan.isStepOfPlan,
                            self.experiment))

                try:
                    self.g.add((self.subexperiment, self.graph.reproduce.id,
                                Literal(project_ids[i - 1])))
                    self.get_all_experiment_images(project_ids[i - 1])
                except IndexError:
                    log.debug("Parsing %s %g" % ('Screen', i))

                assay = Assay.Assay()
                self.assay = URIRef(
                    self.graph.reproduce['Assay' + '_' + self.study_number +
                                         '_' + str(i)])
                self.g.add((self.assay, RDF.type,
                            URIRef(self.graph.reproduce["Assay"])))
                self.parse(self.assay, assay.mapping, lines=lines)
                self.g.add((self.assay, self.graph.pplan.isOutputVarOf,
                            self.subexperiment))

                #ProcessedData
                self.processed_data = URIRef(
                    self.graph.reproduce['ProcessedData' + '_' +
                                         self.study_number + '_' + str(i)])
                self.g.add((self.processed_data, RDF.type,
                            URIRef(self.graph.reproduce["ProcessedData"])))
                self.g.add((self.processed_data, RDF.value,
                            Literal(
                                self.get_value('Processed Data File Name',
                                               lines=lines))))
                self.g.add(
                    (self.processed_data, self.graph.pplan.isVariableOfPlan,
                     self.experiment))
                self.g.add(
                    (self.processed_data, self.graph.pplan.isOutputVarOf,
                     self.imaging_study))

                experimentalData = ExperimentalData.ExperimentalData()
                self.experimentalData = URIRef(
                    self.graph.reproduce['ExperimentalData' + '_' +
                                         self.study_number + '_' + str(i)])
                self.g.add((self.experimentalData, RDF.type,
                            URIRef(self.graph.reproduce["ExperimentalData"])))
                self.parse(self.experimentalData,
                           experimentalData.mapping,
                           lines=lines)
                self.g.add(
                    (self.experimentalData, self.graph.pplan.isVariableOfPlan,
                     self.experiment))

                self.experimentcondition = URIRef(
                    self.graph.reproduce['ExperimentalCondition' + '_' +
                                         self.study_number + '_' + str(i)])
                self.g.add(
                    (self.experimentcondition, RDF.type,
                     URIRef(self.graph.reproduce["ExperimentalCondition"])))
                self.g.add((self.experimentcondition, RDF.value,
                            Literal(
                                self.get_value('Assay Experimental Conditions',
                                               lines=lines))))
                self.g.add(
                    (self.experimentcondition, self.graph.reproduce.type,
                     Literal(
                         self.get_value(
                             'Assay Experimental Conditions Term Accession',
                             lines=lines))))
                self.g.add((self.subexperiment,
                            self.graph.reproduce.hasExperimentalCondition,
                            self.experimentcondition))

                exp_type = 'Experiment'
                phenotype = Phenotype.Phenotype()
                self.parse_phenotype(phenotype.mapping,
                                     i,
                                     exp_type,
                                     lines=lines)

                protocol = Protocol.Protocol()
                self.parse_protocol(protocol.mapping, i, exp_type, lines=lines)

        self.initialise_relations()
예제 #18
0
    def parse_screen(self):
        screen = Screen.Screen()
        value = self.get_value('Study Screens Number')
        screen_ids = []

        if value:
            with open('./input', 'r') as f:
                lines = f.readlines()
                for idx, val in enumerate(lines):
                    if self.study_number in val:
                        screen_id = val.split(":")[1].strip()
                        screen_ids.append(screen_id)
            for i in range(1, int(value) + 1):
                lines = self.get_lines(i, 'Screen')
                self.screen = URIRef(
                    self.graph.reproduce['Screen' + '_' + self.study_number +
                                         '_' + str(i)])
                self.g.add((self.screen, RDF.type,
                            URIRef(self.graph.reproduce["Screen"])))
                self.g.add((self.screen, self.graph.pplan.isOutputVarOf,
                            self.imaging_study))
                try:
                    self.g.add((self.screen, self.graph.reproduce.id,
                                Literal(screen_ids[i - 1])))
                    self.get_all_screen_images(screen_ids[i - 1])
                except IndexError:
                    log.debug("Parsing %s %g" % ('Screen', i))
                self.parse(self.screen, screen.mapping, lines=lines)

                #ProcessedData
                self.processed_data = URIRef(
                    self.graph.reproduce['ProcessedData' + '_' +
                                         self.study_number + '_' + str(i)])
                self.g.add((self.processed_data, RDF.type,
                            URIRef(self.graph.reproduce["ProcessedData"])))
                self.g.add((self.processed_data, self.graph.reproduce.name,
                            Literal(
                                self.get_value('Processed Data File Name',
                                               lines=lines))))
                self.g.add(
                    (self.processed_data, self.graph.pplan.isVariableOfPlan,
                     self.experiment))
                self.g.add(
                    (self.processed_data, self.graph.pplan.isOutputVarOf,
                     self.imaging_study))

                experimentalData = ExperimentalData.ExperimentalData()
                self.experimentalData = URIRef(
                    self.graph.reproduce['ExperimentalData' + '_' +
                                         self.study_number + '_' + str(i)])
                self.g.add((self.experimentalData, RDF.type,
                            URIRef(self.graph.reproduce["ExperimentalData"])))
                self.parse(self.experimentalData,
                           experimentalData.mapping,
                           lines=lines)
                self.g.add(
                    (self.experimentalData, self.graph.pplan.isVariableOfPlan,
                     self.experiment))

                library = Library.Library()
                self.library = URIRef(
                    self.graph.reproduce['Library' + '_' + self.study_number +
                                         '_' + str(i)])
                self.g.add((self.library, RDF.type,
                            URIRef(self.graph.reproduce["Library"])))
                self.parse(self.library, library.mapping, lines=lines)
                self.g.add((self.library, self.graph.pplan.isInputVarOf,
                            self.imaging_study))

                manufacturer_name = self.get_value('Library Manufacturer',
                                                   lines=lines)
                if manufacturer_name:
                    self.library_agent = URIRef(
                        self.graph.reproduce['Agent' + '_' +
                                             self.study_number + 'Library' +
                                             '_' + str(i)])
                    self.g.add((self.library_agent, RDF.type,
                                URIRef(self.graph.prov["Agent"])))
                    self.g.add((self.library_agent, self.graph.reproduce.name,
                                Literal(manufacturer_name)))
                    self.g.add(
                        (self.library_agent, self.graph.reproduce.hasRole,
                         Literal('Manufacturer')))
                    self.g.add((self.library, self.graph.prov.wasAttributedTo,
                                self.library_agent))

                self.experimentcondition = URIRef(
                    self.graph.reproduce['ExperimentalCondition' + '_' +
                                         self.study_number + '_' + str(i)])
                self.g.add(
                    (self.experimentcondition, RDF.type,
                     URIRef(self.graph.reproduce["ExperimentalCondition"])))
                self.g.add(
                    (self.experimentcondition, RDF.value,
                     Literal(
                         self.get_value('Library Experimental Conditions',
                                        lines=lines))))
                self.g.add(
                    (self.experimentcondition, self.graph.reproduce.type,
                     Literal(
                         self.get_value(
                             'Library Experimental Conditions Term Accession',
                             lines=lines))))
                self.g.add((self.imaging_study,
                            self.graph.reproduce.hasExperimentalCondition,
                            self.experimentcondition))

                exp_type = 'Screen'

                phenotype = Phenotype.Phenotype()
                self.parse_phenotype(phenotype.mapping,
                                     i,
                                     exp_type,
                                     lines=lines)

                protocol = Protocol.Protocol()
                self.parse_protocol(protocol.mapping, i, exp_type, lines=lines)
예제 #19
0
from Protocol import *
from threading import Timer
import sys

protocol = Protocol()

class Controller:
    def myInit(self, mainFrame):
        self.mainFrame = mainFrame
        self.running = True
        self.t_update = None
        self.startUpdate()

    def stop(self):
        self.running = False
        self.t_update.cancel()
        #sys.exit(1)

    def startUpdate(self, timer=10):
        self.t_update = Timer(timer, protocol.update, [self.finnishUpdate])
        self.t_update.start()

    def finnishUpdate(self, devices, data, instellingen):
        #print("update", devices)
        self.mainFrame.updateGUI(devices, data, instellingen)
        if self.running:
            self.startUpdate()

    def startConnection(self, comInput):
        if str.strip(comInput) == "":
            return None
예제 #20
0
    def init(self):
        sqlalchemy = __import__('sqlalchemy')
        if self.sqlurl.startswith('sqlite'):
            print(
                'Multiple threads are not supported with sqlite, forcing a single thread'
            )
            print('Please note the server performance will not be optimal')
            print('You might want to install a real database server')
            print('')
            self.max_threads = 1
            self.engine = sqlalchemy.create_engine(self.sqlurl, echo=False)

            def _fk_pragma_on_connect(dbapi_con, con_record):
                dbapi_con.execute('PRAGMA journal_mode = MEMORY')
                dbapi_con.execute('PRAGMA synchronous = OFF')

            ## FIXME: "ImportError: cannot import name event"
            from sqlalchemy import event
            event.listen(self.engine, 'connect', _fk_pragma_on_connect)
        else:
            self.engine = sqlalchemy.create_engine(self.sqlurl,
                                                   pool_size=self.max_threads *
                                                   2,
                                                   pool_recycle=300)

        self.userdb = SQLUsers.UsersHandler(self, self.engine)
        self.channeldb = SQLUsers.ChannelsHandler(self, self.engine)

        channels = self.channeldb.load_channels()

        for name in channels:
            channel = channels[name]

            owner = None
            admins = []
            client = self.userdb.clientFromUsername(channel['owner'])
            if client and client.id: owner = client.id

            for user in channel['admins']:
                client = userdb.clientFromUsername(user)
                if client and client.id:
                    admins.append(client.id)

            self.channels[name] = Protocol.Channel.Channel(
                self,
                name,
                chanserv=bool(owner),
                id=channel['id'],
                owner=owner,
                admins=admins,
                key=channel['key'],
                antispam=channel['antispam'],
                topic={
                    'user': '******',
                    'text': channel['topic'],
                    'time': int(time.time())
                },
                store_history=channel['store_history'])

        #self.dispatcher.addClient(self.chanserv)

        self.parseFiles()
        self.protocol = Protocol.Protocol(self)
        self.chanserv = ChanServ.ChanServClient(self, (self.online_ip, 0),
                                                self.session_id)
        self.chanserv.ChanServ.onLogin()

        for name in channels:
            self.chanserv.HandleProtocolCommand('JOIN %s' % name)
예제 #21
0
 def rebind(self):
     self.protocol = Protocol.Protocol(self._root, self)
     for client in self._root.clients.values():
         client.Bind(protocol=self.protocol)
예제 #22
0
      x=0
      for b in msg:
        print "%d - %x" % ( x, b )
        x = x + 1
  	# indigo doesn't support bytearray() (old python?) so we're going
  	# to convert int to string here

    msgparts=""
    for m in msg:
      msgparts += chr(m)
    self._socket.send(msgparts)

if __name__ == "__main__":
  m = Magiccolor()
  m.connect()
  p = Protocol()

  # key number 1 turned it on
  # key number 2 turned shit off 
  # key #3 selects mode
  # We don't know how to set speed or brightness.

  if sys.argv[1] == '-l':
    x=0
    y=0
    print "Program listing\n\n"
    for c in p.COLORLIST:
      x=x+1
      if y == 5:
        print 
        y=0
예제 #23
0
파일: flypiApp.py 프로젝트: kasbah/Flypi
    def __init__(self, master, ser=""):
        
            
        #create base path for storing files, temperature curves, etc:
        if not os.path.exists(self.basePath):
            #os.chdir('/home/pi/Desktop/')
            os.mkdir(self.basePath)
            os.chown(self.basePath, 1000, 1000)

        #create dictionary to store all classes that will be used
        usedClasses = dict() 

        ##create the mainframe
        frame = tk.Frame()
        frame.grid(row=0, column=0, rowspan=1, columnspan=1)
        
        row1Frame = tk.Frame(master=frame, bd=2, relief="ridge")
        row2Frame = tk.Frame(master=frame, bd=2, relief="ridge")
        row3Frame = tk.Frame(master=frame, bd=2, relief="ridge")
        row4Frame = tk.Frame(master=frame, bd=2, relief="ridge")
        
        if serialAvail == True:
            # for Arduino Uno from RPi
            #self.ser = serial.Serial('/dev/ttyACM0', 115200)
            # for Arduino Nano from RPi
            self.ser = serial.Serial('/dev/ttyUSB0', 9600)
#            ser = serial.Serial('/dev/ttyUSB0', 4800,timeout=0.05)
        ##show the pieces of the GUI
        ##depending on which flags are on (see above):
        

        
        ###CAMERA###
        if self.cameraFlag == 1:
            
            
            import Camera
            self.frameCam = tk.Frame(master=row2Frame, bd=3)
            self.frameCam.pack(side="top")
            self.Camera = Camera.Camera(parent=self.frameCam,
                                        label="CAMERA",
                                        basePath=self.basePath)

            usedClasses["camera"] = self.Camera
        else:
            usedClasses["camera"] = 0
        ###LED1###
        if self.led1Flag == 1:
            import LED
            
            self.frameLed1 = tk.Frame(row1Frame, bd=3)
            self.frameLed1.grid(row=0, column=0, sticky="NW")

            self.LED1 = LED.LED(parent=self.frameLed1, label="LED 1",
                          onAdd=self.led1OnAdd, offAdd=self.led1OffAdd,
                          zapDurAdd=self.led1ZapDurAdd, ser=self.ser,
                          #prot=self.prot,
                          #protFrame=self.frameProt,
                          )
            led1Off = self.led1OffAdd
            self.ser.write(led1Off.encode('utf-8'))

#            usedClasses["led1"] = self.LED1
            usedClasses["led1"] = 1
            #print (self.LED1)
        else:
            usedClasses["led1"] = 0
        ###LED2###
        if self.led2Flag == 1:
            import LED
            self.frameLed2 = tk.Frame(row1Frame, bd=3)
            self.frameLed2.grid(row=0, column=1, sticky="NW")
            self.LED2 = LED.LED(parent=self.frameLed2, label="LED 2",
                          onAdd=self.led2OnAdd, offAdd=self.led2OffAdd,
                          zapDurAdd=self.led2ZapDurAdd, ser=self.ser,
                          
                          #prot=self.prot, protFrame=self.frameProt,
                          )
            led2Off = self.led2OffAdd
            self.ser.write(led2Off.encode('utf-8'))
#            usedClasses["led2"] = self.LED2
            usedClasses["led2"] = 1
        else:   
            usedClasses["led2"] = 0


        ###MATRIX###
        if self.matrixFlag == 1:
            import Matrix
            self.frameMatrix = tk.Frame(row1Frame, bd=3)
            self.frameMatrix.grid(row=0, column=2, sticky="W",)
            self.Matrix = Matrix.Matrix(parent=self.frameMatrix, label="MATRIX",
                               pat3Add=self.matPat3Add,pat4Add=self.matPat4Add, offAdd=self.matOffAdd,
                               pat1Add=self.matPat1Add, pat2Add=self.matPat2Add,
                               brightAdd=self.matBrightAdd,
                
                               ser=self.ser
                               )
            matOff = self.matOffAdd
            self.ser.write(matOff.encode('utf-8'))
            usedClasses["matrix"] = 1#self.Matrix
        else:   
            usedClasses["matrix"] = 0

        ###RING###
        if self.ringFlag == 1:
            import Ring
            self.frameRing = tk.Frame(row1Frame, bd=3)
            self.frameRing.grid(row=1, column=0, sticky="NW",
                                columnspan=3, rowspan=1)

            self.Ring = Ring.Ring(parent=self.frameRing, label="RING",
                             ringOnAdd=self.ringOnAdd,
                             ringOffAdd=self.ringOffAdd,
                             ringZapAdd=self.ringZapAdd,
                             redAdd=self.ringRedAdd,
                             greenAdd=self.ringGreenAdd,
                             blueAdd=self.ringBlueAdd,
                             allAdd=self.ringAllAdd,
                             rotAdd=self.ringRotAdd,
                             ser=self.ser)

            ringOff=self.ringOffAdd
            self.ser.write(ringOff.encode('utf-8'))
            usedClasses["ring"] = 1#self.Ring
        else:   
            usedClasses["ring"] = 0
            
        ###PELTIER###
        if self.peltierFlag == 1:
            import Peltier
            self.framePelt = tk.Frame(row4Frame, bd=3)
            self.framePelt.pack(side="left")
            self.Peltier = Peltier.Peltier(parent=self.framePelt,
                                           label="PELTIER",
                                           onAdd=self.peltOnAdd,
                                           offAdd=self.peltOffAdd,
                                           tempAdd=self.peltTempAdd,
                                           basePath=self.basePath,
                                           ser=self.ser)
            peltOff = self.peltOffAdd
            self.ser.write(peltOff.encode('utf-8'))
            usedClasses["peltier"] = 1#self.Peltier
            
        else:   
            usedClasses["peltier"] = 0


        ###Auto Focus###
        if self.autofocusFlag == 1:
            import AutoFocus
            self.frameAuto = tk.Frame(row4Frame, bd=3)
            self.frameAuto.pack(side="left")
            self.AutoFocus = AutoFocus.AutoFocus(parent=self.frameAuto,
                                           label="Focus",
                                           velAdd=self.autoFocusAdd,
                                           ser=self.ser)
            servoOff=str(self.autoFocusAdd)+"*"+ str(0)+"*"
            self.ser.write(servoOff.encode('utf-8'))

        ###Protocol###
        if self.protocolFlag == 1:
            import Protocol
            
            self.frameProt = tk.Frame(master=row3Frame,
                                      bd=3,
                                      relief="ridge")
            self.frameProt.pack(side="top")
            self.Protocol = Protocol.Protocol(parent = self.frameProt,
                                              usedClasses=usedClasses,
                                              basePath = self.basePath+"/protocol/",
                                              label="Protocols",ser=self.ser,
                                              timingAdd=self.timeAdd)
#            print(self.timeAdd)
            #self.prot = True
            #self.protocol = Protocol(parent=self.frameProt, ser=self.ser)

        else:
            self.frameProt = ""
            self.prot = False
	##mock up###
        if self.mockupFlag == 1:
            import Mock_up
            self.frameMock = tk.Frame(row4Frame, bd=3)
            self.frameMock.pack(side="left")
            self.Mockup= Mock_up.Mock_up(parent=self.frameMock,
                                           label="mock_up",
                                           ser=self.ser)

        ###QUIT###
        if self.quitFlag == 1:
            self.frameQuit = tk.Frame(master=row4Frame)
            self.frameQuit.pack(side="right")
            #self.frameQuit.grid(row=5, column=2, sticky="NW")
            self.quitAPP(parent=self.frameQuit)

        #draw all frames on screen
        row4Frame.grid(row=5, column=0, sticky="NWE", columnspan=1)
        row1Frame.grid(row=1, column=0, sticky="NWE", columnspan=1)
        row3Frame.grid(row=1, column=2, sticky="NWE")
        row2Frame.grid(row=0, column=0, sticky="NWE", columnspan=1)
예제 #24
0
def example_ICMP_protocol():
    sf = StartField.StartField('ICMP_dissector_built', 'Example ICMP protocol')
    sf.set_dependency_pattern('1')
    sf.set_dependency_protocol('ip.proto')
    #    sf.set_dependency_pattern('Integer')
    #    sf.set_dependency_protocol('Dependent protocol')

    f1 = Field.Field(1)

    sf.set_next_constructs([f1])

    f1.set_field_info('ICMP Type', 'Type', 'Checks the type of message',
                      'ftypes.UINT8', 'base.HEX', 'nil', '?', 'True')

    ref_list = ReferenceList.ReferenceList('ref_list')
    ref_list.set_descriptions(['Echo Reply', 'Echo Request'])
    ref_list.set_values(['0', '8'])
    f1.set_ref_list(ref_list)
    #    ref_list = ReferenceList.ReferenceList('ref_list')
    #    ref_list.set_descriptions(['is a value'])
    #    ref_list.set_values(['13'])
    #
    #    f1.set_ref_list(ref_list)

    source_quench_expr = Expression.Expression()
    source_quench_expr.set_relational_operators_and_operands(['=='], ['4'])

    redirect_expr = Expression.Expression()
    redirect_expr.set_relational_operators_and_operands(['=='], ['5'])

    time_exceeded_expr = Expression.Expression()
    time_exceeded_expr.set_relational_operators_and_operands(['=='], ['11'])

    timestamp_expr = Expression.Expression()
    timestamp_expr.set_relational_operators_and_operands(['=='], ['13'])

    timestamp_reply_expr = Expression.Expression()
    timestamp_reply_expr.set_relational_operators_and_operands(['=='], ['14'])

    addr_mask_req = Expression.Expression()
    addr_mask_req.set_relational_operators_and_operands(['=='], ['17'])

    addr_mask_reply_req = Expression.Expression()
    addr_mask_reply_req.set_relational_operators_and_operands(['=='], ['18'])

    destination_unreachable = Expression.Expression()
    destination_unreachable.set_relational_operators_and_operands(['=='],
                                                                  ['3'])

    otherwise_expr = Expression.Expression()
    otherwise_expr.set_relational_operators_and_operands(
        ['~=', '~=', '~=', '~=', '~=', '~=', '~=', '~='],
        ['4', '5', '11', '13', '14', '17', '18', '3'])
    otherwise_expr.set_logical_operators(
        ['And', 'And', 'And', 'And', 'And', 'And', 'And'])

    dc = DecisionConstruct.DecisionConstruct()
    dc.set_expressions([
        source_quench_expr, redirect_expr, time_exceeded_expr, timestamp_expr,
        timestamp_reply_expr, addr_mask_req, addr_mask_reply_req,
        destination_unreachable, otherwise_expr
    ])
    f1.set_next_constructs([dc])

    source_quench_field = Field.Field(1)
    source_quench_field.set_field_info('Code_source', 'Code', 'Code',
                                       'ftypes.UINT8', 'nil', '0xf', 'nil',
                                       'True')

    source_quench_field_2 = Field.Field(2)
    source_quench_field_2.set_field_info('HeaderChecksum_source',
                                         'HeaderChecksum', 'HeaderChecksum',
                                         'ftypes.UINT16', 'base.HEX', '0xff',
                                         'nil', 'True')
    source_quench_field_3 = Field.Field(4)
    source_quench_field_3.set_field_info('Unused_source', 'Unused', 'Unused',
                                         'ftypes.UINT32', 'nil', '0xffff',
                                         'nil', 'True')
    source_quench_field_4 = Field.Field(4)
    source_quench_field_4.set_field_info('IP_header_source', 'IP_header',
                                         'IP_header', 'ftypes.UINT32', 'nil',
                                         '0xffff', 'nil', 'True')

    source_quench_field.set_next_constructs([source_quench_field_2])
    source_quench_field_2.set_next_constructs([source_quench_field_3])
    source_quench_field_3.set_next_constructs([source_quench_field_4])

    redirect_field = Field.Field(1)
    redirect_field.set_field_info('Code_redirect', 'Code', 'Code',
                                  'ftypes.UINT8', 'nil', '0xf', 'nil', 'True')
    redirect_field_2 = Field.Field(2)
    redirect_field_2.set_field_info('HeaderChecksum_redirect',
                                    'HeaderChecksum', 'HeaderChecksum',
                                    'ftypes.UINT16', 'base.HEX', '0xff', 'nil',
                                    'True')
    redirect_field_3 = Field.Field(4)
    redirect_field_3.set_field_info('IP_addr_redirect', 'IP_addr', 'IP_addr',
                                    'ftypes.UINT32', 'nil', '0xffff', 'nil',
                                    'True')

    redirect_field.set_next_constructs([redirect_field_2])
    redirect_field_2.set_next_constructs([redirect_field_3])

    te_field = Field.Field(1)  #Should have reference list
    te_field.set_field_info('Code_te', 'Code', 'Code', 'ftypes.UINT8', 'nil',
                            '0xf', 'nil', 'True')
    te_field_2 = Field.Field(2)
    te_field_2.set_field_info('HeaderChecksum_te', 'HeaderChecksum',
                              'HeaderChecksum', 'ftypes.UINT16', 'base.HEX',
                              '0xff', 'nil', 'True')
    te_field_3 = Field.Field(4)
    te_field_3.set_field_info('Unused_te', 'Unused', 'Unused', 'ftypes.UINT32',
                              'nil', '0xffff', 'nil', 'True')
    te_field_4 = Field.Field(4)
    te_field_4.set_field_info('IP_header_te', 'IP_header', 'IP_header',
                              'ftypes.UINT32', 'nil', '0xffff', 'nil', 'True')

    te_field.set_next_constructs([te_field_2])
    te_field_2.set_next_constructs([te_field_3])
    te_field_3.set_next_constructs([te_field_4])

    ts_field = Field.Field(1)
    ts_field.set_field_info('Code_ts', 'Code', 'Code', 'ftypes.UINT8', 'nil',
                            '0xf', 'nil', 'True')
    ts_field_2 = Field.Field(2)
    ts_field_2.set_field_info('HeaderChecksum_ts', 'HeaderChecksum',
                              'HeaderChecksum', 'ftypes.UINT16', 'base.HEX',
                              '0xff', 'nil', 'True')
    ts_field_3 = Field.Field(2)
    ts_field_3.set_field_info('Identifier_ts', 'Identifier', 'Identifier',
                              'ftypes.UINT16', 'nil', '0xff', 'nil', 'True')
    ts_field_4 = Field.Field(2)
    ts_field_4.set_field_info('Seq_number_ts', 'Seq_number', 'Seq_number',
                              'ftypes.UINT16', 'nil', '0xff', 'nil', 'True')
    ts_field_5 = Field.Field(4)
    ts_field_5.set_field_info('Original_timestamp_ts', 'Original_timestamp',
                              'Original_timestamp', 'ftypes.UINT32',
                              'base.HEX', '0xffff', 'nil', 'True')
    ts_field_6 = Field.Field(4)
    ts_field_6.set_field_info('Recieve_timestamp_ts', 'Recieve_timestamp',
                              'Recieve_timestamp', 'ftypes.UINT32', 'base.HEX',
                              '0xffff', 'nil', 'True')
    ts_field_7 = Field.Field(4)
    ts_field_7.set_field_info('Transmit_timestamp_ts', 'Transmit_timestamp',
                              'Transmit_timestamp', 'ftypes.UINT32',
                              'base.HEX', '0xffff', 'nil', 'True')

    ts_field.set_next_constructs([ts_field_2])
    ts_field_2.set_next_constructs([ts_field_3])
    ts_field_3.set_next_constructs([ts_field_4])
    ts_field_4.set_next_constructs([ts_field_5])
    ts_field_5.set_next_constructs([ts_field_6])
    ts_field_6.set_next_constructs([ts_field_7])

    tsr_field = Field.Field(1)
    tsr_field.set_field_info('Code_tsr_tsr', 'Code', 'Code', 'ftypes.UINT8',
                             'nil', '0xf', 'nil', 'True')
    tsr_field_2 = Field.Field(2)
    tsr_field_2.set_field_info('HeaderChecksum_tsr', 'HeaderChecksum',
                               'HeaderChecksum', 'ftypes.UINT16', 'base.HEX',
                               '0xff', 'nil', 'True')
    tsr_field_3 = Field.Field(2)
    tsr_field_3.set_field_info('Identifier_tsr', 'Identifier', 'Identifier',
                               'ftypes.UINT16', 'nil', '0xff', 'nil', 'True')
    tsr_field_4 = Field.Field(2)
    tsr_field_4.set_field_info('Seq_number_tsr', 'Seq_number', 'Seq_number',
                               'ftypes.UINT16', 'nil', '0xff', 'nil', 'True')
    tsr_field_5 = Field.Field(4)
    tsr_field_5.set_field_info('Original_timestamp_tsr', 'Original_timestamp',
                               'Original_timestamp', 'ftypes.UINT32', 'nil',
                               '0xffff', 'nil', 'True')
    tsr_field_6 = Field.Field(4)
    tsr_field_6.set_field_info('Recieve_timestamp_tsr', 'Recieve_timestamp',
                               'Recieve_timestamp', 'ftypes.UINT32', 'nil',
                               '0xffff', 'nil', 'True')
    tsr_field_7 = Field.Field(4)
    tsr_field_7.set_field_info('Transmit_timestamp_tsr', 'Transmit_timestamp',
                               'Transmit_timestamp', 'ftypes.UINT32', 'nil',
                               '0xffff', 'nil', 'True')

    tsr_field.set_next_constructs([tsr_field_2])
    tsr_field_2.set_next_constructs([tsr_field_3])
    tsr_field_3.set_next_constructs([tsr_field_4])
    tsr_field_4.set_next_constructs([tsr_field_5])
    tsr_field_5.set_next_constructs([tsr_field_6])
    tsr_field_6.set_next_constructs([tsr_field_7])

    adr_mask_field = Field.Field(1)
    adr_mask_field.set_field_info('Code_addrmask_adr_mask', 'Code', 'Code',
                                  'ftypes.UINT8', 'nil', '0xf', 'nil', 'True')
    adr_mask_field_2 = Field.Field(2)
    adr_mask_field_2.set_field_info('HeaderChecksum_adr_mask',
                                    'HeaderChecksum', 'HeaderChecksum',
                                    'ftypes.UINT16', 'base.HEX', '0xff', 'nil',
                                    'True')
    adr_mask_field_3 = Field.Field(2)
    adr_mask_field_3.set_field_info('Identifier_adr_mask', 'Identifier',
                                    'Identifier', 'ftypes.UINT16', 'nil',
                                    '0xff', 'nil', 'True')
    adr_mask_field_4 = Field.Field(2)
    adr_mask_field_4.set_field_info('Seq_number_adr_mask', 'Seq_number',
                                    'Seq_number', 'ftypes.UINT16', 'nil',
                                    '0xff', 'nil', 'True')
    adr_mask_field_5 = Field.Field(4)
    adr_mask_field_5.set_field_info('Address_mask_adr_mask', 'Address_mask',
                                    'Address_mask', 'ftypes.UINT32', 'nil',
                                    '0xffff', 'nil', 'True')

    adr_mask_field.set_next_constructs([adr_mask_field_2])
    adr_mask_field_2.set_next_constructs([adr_mask_field_3])
    adr_mask_field_3.set_next_constructs([adr_mask_field_4])
    adr_mask_field_4.set_next_constructs([adr_mask_field_5])

    adr_mask_r_field = Field.Field(1)
    adr_mask_r_field.set_field_info('Code_addrmask_r', 'Code', 'Code',
                                    'ftypes.UINT8', 'nil', '0xf', 'nil',
                                    'True')
    adr_mask_r_field_2 = Field.Field(2)
    adr_mask_r_field_2.set_field_info('HeaderChecksum_addrmask_r',
                                      'HeaderChecksum', 'HeaderChecksum',
                                      'ftypes.UINT16', 'base.HEX', '0xff',
                                      'nil', 'True')
    adr_mask_r_field_3 = Field.Field(2)
    adr_mask_r_field_3.set_field_info('Identifier_addrmask_r', 'Identifier',
                                      'Identifier', 'ftypes.UINT16', 'nil',
                                      '0xff', 'nil', 'True')
    adr_mask_r_field_4 = Field.Field(2)
    adr_mask_r_field_4.set_field_info('Seq_number_addrmask_r', 'Seq_number',
                                      'Seq_number', 'ftypes.UINT16', 'nil',
                                      '0xff', 'nil', 'True')
    adr_mask_r_field_5 = Field.Field(4)
    adr_mask_r_field_5.set_field_info('Address_mask_addrmask_r',
                                      'Address_mask', 'Address_mask',
                                      'ftypes.UINT32', 'nil', '0xffff', 'nil',
                                      'True')

    adr_mask_r_field.set_next_constructs([adr_mask_r_field_2])
    adr_mask_r_field_2.set_next_constructs([adr_mask_r_field_3])
    adr_mask_r_field_3.set_next_constructs([adr_mask_r_field_4])
    adr_mask_r_field_4.set_next_constructs([adr_mask_r_field_5])

    du_field = Field.Field(1)
    du_field.set_field_info('Code_du', 'Code', 'Code', 'ftypes.UINT8', 'nil',
                            '0xf', 'nil', 'True')
    du_field_2 = Field.Field(2)
    du_field_2.set_field_info('HeaderChecksum_du', 'HeaderChecksum',
                              'HeaderChecksum', 'ftypes.UINT16', 'base.HEX',
                              '0xff', 'nil', 'True')
    du_field_3 = Field.Field(2)
    du_field_3.set_field_info('Unused_du', 'Unused', 'Unused', 'ftypes.UINT16',
                              'nil', '0xff', 'nil', 'True')
    du_field_4 = Field.Field(2)
    du_field_4.set_field_info('Next_hop_MTU_du', 'Next_hop_MTU',
                              'Next_hop_MTU', 'ftypes.UINT16', 'nil', '0xff',
                              'nil', 'True')
    du_field_5 = Field.Field(4)
    du_field_5.set_field_info('ip_header_du', 'ip_header', 'ip_header',
                              'ftypes.UINT32', 'nil', '0xffff', 'nil', 'True')

    du_field.set_next_constructs([du_field_2])
    du_field_2.set_next_constructs([du_field_3])
    du_field_3.set_next_constructs([du_field_4])
    du_field_4.set_next_constructs([du_field_5])

    other_field = Field.Field(1)
    other_field.set_field_info('Code_Other', 'Code', 'Code', 'ftypes.UINT8',
                               'nil', '0xf', 'nil', 'True')
    other_field_2 = Field.Field(2)
    other_field_2.set_field_info('HeaderChecksum_other', 'HeaderChecksum',
                                 'HeaderChecksum', 'ftypes.UINT16', 'base.HEX',
                                 '0xff', 'nil', 'True')

    other_field.set_next_constructs([other_field_2])

    dc.set_next_constructs([
        source_quench_field, redirect_field, te_field, ts_field, tsr_field,
        adr_mask_field, adr_mask_r_field, du_field, other_field
    ])
    end_field = EndField.EndField()

    source_quench_field_4.set_next_constructs([end_field])
    redirect_field_3.set_next_constructs([end_field])
    te_field_4.set_next_constructs([end_field])
    ts_field_7.set_next_constructs([end_field])
    tsr_field_7.set_next_constructs([end_field])
    adr_mask_field_5.set_next_constructs([end_field])
    adr_mask_r_field_5.set_next_constructs([end_field])
    du_field_5.set_next_constructs([end_field])
    other_field_2.set_next_constructs([end_field])

    protocol = Protocol.Protocol()
    protocol_structure = protocol.get_protocol_structure(sf)
    return protocol_structure