def data_callback(data): global counter BLINKER_LOG("Blinker readString: ", data) counter += 1 number1.print(counter) Blinker.push("msg")
def data_callback(data): global counter BLINKER_LOG("Blinker readString: ", data) counter += 1 number1.print(counter) Blinker.wechat("title", "state", "msg")
class SpecificRobotCtrl: def valid_exprs(self): rospy.loginfo("Valid %s face expressions request.", self.robotname) return {"exprnames": self.faces.keys()} def make_face(self, exprname, intensity=1): rospy.loginfo("Face request: %s of %s for %s", intensity, exprname, self.robotname) for cmd in self.faces[exprname].new_msgs(intensity): self.blinker.log(copy.deepcopy(cmd)) pubid = cmd.id // 24 cmd.id = cmd.id % 24 self.publishers[pubid].publish(cmd) def blink(self): def close_lids(): for cmd in self.blinker.new_msgs(1.0): pubid = cmd.id // 24 cmd.id = cmd.id % 24 self.publishers[pubid].publish(cmd) def open_lids(): for cmd in self.blinker.reset_msgs(): pubid = cmd.id // 24 cmd.id = cmd.id % 24 self.publishers[pubid].publish(cmd) close_lids() Timer(0.1, open_lids).start() def __init__(self, robotname, publishers): # Dictionary of expression names mapping to FaceExprMotors instances. self.faces = FaceExpr.FaceExprMotors.from_expr_yaml( read_config(robotname + "_exprs.yaml"), to_dict(read_config(robotname + "_motors.yaml"), "name") ) # Motor commands will be sent to this publisher. self.publishers = publishers self.robotname = robotname #Initialize blink support self.blinker = Blinker(robotname, to_dict(read_config(robotname + "_motors.yaml"), "name")) self.timer_blink = RandomTimer(self.blink, (5.0, 1.0)) if robotname == "dmitry": self.blinker.add_motor("Eyelid-Upper_L", 1.0) self.blinker.add_motor("Eyelid-Upper_R", 0.0)
def data_callback(data): global counter BLINKER_LOG("Blinker readString: ", data) counter += 1 number1.print(counter) BLINKER_LOG("Blinker weather: ", Blinker.weather())
def __init__(self, robotname, publishers): # Dictionary of expression names mapping to FaceExprMotors instances. self.faces = FaceExpr.FaceExprMotors.from_expr_yaml( read_config(robotname + "_exprs.yaml"), to_dict(read_config(robotname + "_motors.yaml"), "name") ) # Motor commands will be sent to this publisher. self.publishers = publishers self.robotname = robotname #Initialize blink support self.blinker = Blinker(robotname, to_dict(read_config(robotname + "_motors.yaml"), "name")) self.timer_blink = RandomTimer(self.blink, (5.0, 1.0)) if robotname == "dmitry": self.blinker.add_motor("Eyelid-Upper_L", 1.0) self.blinker.add_motor("Eyelid-Upper_R", 0.0)
#!/usr/bin/env python # -*- coding: utf-8 -*- from Blinker import Blinker, BlinkerButton, BlinkerNumber from Blinker.BlinkerDebug import * auth = 'Your Device Secret Key' BLINKER_DEBUG.debugAll() Blinker.mode("BLINKER_WIFI") Blinker.begin(auth) button1 = BlinkerButton("btn-abc") number1 = BlinkerNumber("num-abc") counter = 0 def button1_callback(state): """ """ BLINKER_LOG('get button state: ', state) button1.icon('icon_1') button1.color('#FFFFFF') button1.text('Your button name or describe') button1.print(state) def data_callback(data):
def main(): params = ParamStore() clargs = parseclargs() if clargs.padnodetypes: params.setparam('typepad', AMRTYPEPAD) if clargs.debug: params.setparam('debug', True) if clargs.skipretyper: params.setparam('skipretyper', True) if clargs.wikify: params.setparam('wikify', True) if clargs.withdictionary: params.setparam('withdictionary', True) if clargs.outputscores: params.setparam('outputscores', True) if clargs.explorethreshold: params.setparam('explorethreshold', True) if clargs.noclobber: params.setparam('noclobber', True) if clargs.blinkcrossencoder: params.setparam('blinkfastmode', False) if clargs.scorethreshold: params.setparam('scorethreshold', clargs.scorethreshold) if isinstance(clargs.blinkthreshold, float): params.setparam('blinkthreshold', clargs.blinkthreshold) if clargs.retypeamrtypesonly: params.setparam('retypeamronly', True) lfile = open(clargs.labelsfile, 'r') retypetypes = list() for l in lfile: atyp = l.strip() if atyp.startswith(BTAG): atyp = atyp[len(BTAG):] if atyp.startswith(AMRPREFIX): atyp = atyp[len(AMRPREFIX):] retypetypes.append(atyp) params.setparam('retypetypes', retypetypes) if params.getparam('debug'): printerr(params.tostring()) if params.getparam('skipretyper'): retyper = None else: printerr('Loading model...') if params.getparam('withdictionary'): from etyperwithdictionary import EntityTyper else: from etyper import EntityTyper retyper = EntityTyper(pathtoclasslabelsfile=clargs.labelsfile, pathtomodeldirectory=clargs.modeldirectory) blinker = None if clargs.wikify: from Blinker import Blinker blinker = Blinker(pathtomodeldirectory=clargs.blinkmodels, pathtocachedirectory=clargs.blinkcachepath, fastmode=params.getparam('blinkfastmode'), wikititleonly=True) threshlist = [params.getparam('scorethreshold')] if params.getparam('explorethreshold'): threshlist = EXPLORETHRESHOLDLIST for thresh in threshlist: ifil = None ofil = None bfil = None jfil = None if clargs.inputfile: ifil = open(clargs.inputfile, 'r') if clargs.biooutputfile: bfil = open(clargs.biooutputfile, 'w') if clargs.jsonoutputfile: jfil = open(clargs.jsonoutputfile, 'w') if clargs.outputfile: if params.getparam('explorethreshold') or params.getparam( 'scorethreshold'): currofilname = f'{clargs.outputfile}_{thresh}.amr' else: currofilname = clargs.outputfile ofil = open(currofilname, 'w') params.setparam('scorethreshold', thresh) numparses = 0 numretypes = 0 numretypesdiff = 0 jcount = 0 if retyper: printerr(f'Retyping with threshold = {thresh}...') current_input = '' needsretyping = False current_snt = '' current_preamble = list() current_toks = list() nodelist = dict() edgelist = list() current_amrparse = '' i = 0 nodelinenum = 0 edgelinenum = 0 processing = False for line in ifil: current_input += line if line == '\n': # must have blank line between amr parses if not processing: # skip extra blank lines if already dumped previous parse continue numparses += 1 if needsretyping: numretypesadd, numretypesdiffadd, numjadd = processparse( current_amrparse, current_toks, nodelist, edgelist, current_preamble, retyper, blinker, ofil, bfil, jfil, jcount, params) numretypes += numretypesadd numretypesdiff += numretypesdiffadd jcount += numjadd else: printoutput(current_input, ofil, end='') current_input = '' needsretyping = False current_snt = '' current_preamble = list() current_toks = list() nodelist = dict() edgelist = list() current_amrparse = '' i = 0 nodelinenum = 0 edgelinenum = 0 processing = False elif line.startswith(LINETYPEPREFIXES['amrline']): processing = True if NAMEDENTITYOP in line: needsretyping = True current_amrparse += line else: current_preamble.append(line) processing = True if line.startswith(LINETYPEPREFIXES['snt']): current_snt = line[len(LINETYPEPREFIXES['snt']):] elif line.startswith(LINETYPEPREFIXES['tok']): current_toks = line[len(LINETYPEPREFIXES['tok']):].split() elif line.startswith(LINETYPEPREFIXES['node']): tmpnode = addnode(nodelinenum, line) nodelinenum += 1 if tmpnode: nodelist[i] = tmpnode i += 1 elif line.startswith(LINETYPEPREFIXES['edge']): tmpedge = addedge(edgelinenum, line) edgelinenum += 1 if tmpedge: edgelist.append(tmpedge) ifil.close() if processing: # there's a parse left over (no blank line at end of file) if needsretyping: numretypesadd, numretypesdiffadd, numjadd = processparse( current_amrparse, current_toks, nodelist, edgelist, current_preamble, retyper, blinker, ofil, bfil, jfil, jcount, params) numretypes += numretypesadd numretypesdiff += numretypesdiffadd jcount += numjadd else: printoutput(current_input, ofil) printerr(f'{numparses} AMR parses processed') printerr(f'{numretypesdiff} / {numretypes} Named Entities processed') if bfil: bfil.close() if jfil: jfil.close() if ofil: ofil.close() if blinker: blinker.done()
#!/usr/bin/env python # -*- coding: utf-8 -*- from Blinker import Blinker, BlinkerText from Blinker.BlinkerDebug import * BLINKER_DEBUG.debugAll() Blinker.mode("BLINKER_BLE") Blinker.begin() text1 = BlinkerText("TextKey") def data_callback(data): BLINKER_LOG("Blinker readString: ", data) text1.print("os time", millis()) Blinker.attachData(data_callback) if __name__ == '__main__': while True: Blinker.run()
def dataStorage(): Blinker.dataStorage("data1", random.randint(0,120)) Blinker.dataStorage("data2", random.randint(0,120)/0.5)