packet = self.port_dataShort_in.getPacket() if packet.dataBuffer is None: return NOOP outData = range(len(packet.dataBuffer)) for i in range(len(packet.dataBuffer)): if self.increaseAmplitude: outData[i] = float(packet.dataBuffer[i]) * self.amplitude else: outData[i] = float(packet.dataBuffer[i]) # NOTE: You must make at least one valid pushSRI call if packet.sriChanged: self.port_dataFloat_out.pushSRI(packet.SRI) self.port_dataFloat_out.pushPacket(outData, packet.T, packet.EOS, packet.streamID) return NORMAL """ # TODO fill in your code here self._log.debug("process() example log message") return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.INFO) logging.debug("Starting Component") start_component(cmdline_def_py_i)
self._log.info("configure called with props " + str([prop.id for prop in props])) if not self.enableErrors: errorComponent_base.configure(self, props) return for prop in props: if prop.id in ('partialConfigConfig', 'partialConfigProp'): raise CF.PropertySet.PartialConfiguration([prop]) elif prop.id in ('invalidConfigConfig', 'invalidConfigProp'): raise CF.PropertySet.InvalidConfiguration("Error from configure method", [prop]) errorComponent_base.configure(self, props) def start(self): if self.enableErrors: raise CF.Resource.StartError(CF.CF_EINVAL, "Error from start method") errorComponent_base.start(self) def stop(self): if self.enableErrors: raise CF.Resource.StopError(CF.CF_EBUSY, "Error from stop method") errorComponent_base.stop(self) def process(self): return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.WARN) logging.debug("Starting Component") start_component(errorComponent_i)
data, T, EOS, streamID, sri, sriChanged, inputQueueFlushed = self.port_dataShort_in.getPacket() if data == None: return NOOP outData = range(len(data)) for i in range(len(data)): if self.increaseAmplitude: outData[i] = float(data[i]) * self.amplitude else: outData[i] = float(data[i]) # NOTE: You must make at least one valid pushSRI call if sriChanged: self.port_dataFloat_out.pushSRI(sri); self.port_dataFloat_out.pushPacket(outData, T, EOS, streamID) return NORMAL """ # TODO fill in your code here self._log.debug("process() example log message") return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.INFO) logging.debug("Starting Component") start_component(FailableComponent_i)
data, T, EOS, streamID, sri, sriChanged, inputQueueFlushed = self.port_dataShort_in.getPacket() if data == None: return NOOP outData = range(len(data)) for i in range(len(data)): if self.increaseAmplitude: outData[i] = float(data[i]) * self.amplitude else: outData[i] = float(data[i]) # NOTE: You must make at least one valid pushSRI call if sriChanged: self.port_dataFloat_out.pushSRI(sri); self.port_dataFloat_out.pushPacket(outData, T, EOS, streamID) return NORMAL """ # TODO fill in your code here self._log.debug("process() example log message") return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.WARN) logging.debug("Starting Component") start_component(ticket_cf_939_comp_i)
# Create a CPU time-stamp tmp_time = time.time() wsec = math.modf(tmp_time)[1] fsec = math.modf(tmp_time)[0] tstamp = BULKIO.PrecisionUTCTime(BULKIO.TCM_CPU, BULKIO.TCS_VALID, 0, wsec, fsec) # Push the data self.port_out.pushPacket(data, tstamp, False, self.stream_id) # If we are throttling, wait...otherwise run at full speed if self.throttle: wait_amt = self.xfer_len * self.sample_time_delta try: time.sleep(wait_amt) finally: return NORMAL return NORMAL def onconfigure_prop_stream_id(self, oldval, newval): self.stream_id = newval self.sri.streamID = self.stream_id self.sriUpdate = True if __name__ == '__main__': logging.getLogger().setLevel(logging.WARN) logging.debug("Starting Component") start_component(SigGen_i)
return FINISH def findWaveformByComponentInstanceName(self, name): # Gets a reference to the running application for app in self.domain.apps: # Find desired application for comp in app.comps: self._log.trace("Checking if " + name + " is in " + comp._instanceName) if name in comp._instanceName: return app return None def findByDeviceName(self, dev_name): for devMgr in self.domain.devMgrs: for dev in devMgr.devs: self._log.trace("Checking if " + dev_name + " is in " + dev._instanceName) if dev_name in dev._instanceName: return dev return None if __name__ == '__main__': logging.getLogger().setLevel(logging.INFO) logging.debug("Starting Component") start_component(FrontEndController_i)
data, T, EOS, streamID, sri, sriChanged, inputQueueFlushed = self.port_dataShort_in.getPacket() if data == None: return NOOP outData = range(len(data)) for i in range(len(data)): if self.increaseAmplitude: outData[i] = float(data[i]) * self.amplitude else: outData[i] = float(data[i]) # NOTE: You must make at least one valid pushSRI call if sriChanged: self.port_dataFloat_out.pushSRI(sri); self.port_dataFloat_out.pushPacket(outData, T, EOS, streamID) return NORMAL """ # TODO fill in your code here self._log.debug("process() example log message") return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.WARN) logging.debug("Starting Component") start_component(SADUsesComponent_i)
packet = self.port_dataShort_in.getPacket() if packet.dataBuffer is None: return NOOP outData = range(len(packet.dataBuffer)) for i in range(len(packet.dataBuffer)): if self.increaseAmplitude: outData[i] = float(packet.dataBuffer[i]) * self.amplitude else: outData[i] = float(packet.dataBuffer[i]) # NOTE: You must make at least one valid pushSRI call if packet.sriChanged: self.port_dataFloat_out.pushSRI(packet.SRI) self.port_dataFloat_out.pushPacket(outData, packet.T, packet.EOS, packet.streamID) return NORMAL """ # TODO fill in your code here self._log.debug("process() example log message") return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.INFO) logging.debug("Starting Component") start_component(math_py_i)
if packet.dataBuffer is None: return NOOP outData = range(len(packet.dataBuffer)) for i in range(len(packet.dataBuffer)): if self.increaseAmplitude: outData[i] = float(packet.dataBuffer[i]) * self.amplitude else: outData[i] = float(packet.dataBuffer[i]) # NOTE: You must make at least one valid pushSRI call if packet.sriChanged: self.port_dataFloat_out.pushSRI(packet.SRI); self.port_dataFloat_out.pushPacket(outData, packet.T, packet.EOS, packet.streamID) return NORMAL """ # TODO fill in your code here self._log.debug("process() example log message") return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.INFO) logging.debug("Starting Component") start_component(timeprop_py_i)
outData[i] = float(data[i]) * self.amplitude else: outData[i] = float(data[i]) # NOTE: You must make at least one valid pushSRI call if sriChanged: self.port_dataFloat_out.pushSRI(sri); self.port_dataFloat_out.pushPacket(outData, T, EOS, streamID) return NORMAL """ # TODO fill in your code here self._log.trace("process() example trace message") self._log.debug("process() example DEBUG message") self._log.info("process() example INFO message") self._log.warning("process() example WARN message") self._log.error("process() example ERROR message") self._log.fatal("process() example FATAL message") time.sleep(.5) return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.INFO) logging.debug("Starting Component") start_component(cf_1535_p1_i)
id_='SOMEOBJREF', type_="objref", name="Object Ref", defvalue=None, kinds=("execparam"), mode="writeonly") someobjref = simpleseq_property(\ id_='DCE:5d8bfe8d-bc25-4f26-8144-248bc343aa53', type_="string", name="args", defvalue=("Hello World",)) class SomeStruct(object): field1 = simple_property(id_="item1", type_="string", defvalue="value1") field2 = simple_property(id_="item2", type_="long", defvalue=100) field3 = simple_property(id_="item3", type_="double", defvalue=3.14156) struct = struct_property(id_="DCE:ffe634c9-096d-425b-86cc-df1cce50612f", name="struct_test", structdef=SomeStruct) if __name__ == '__main__': logging.getLogger().setLevel(logging.DEBUG) start_component(CommandWrapperSPDDep_i)
data, T, EOS, streamID, sri, sriChanged, inputQueueFlushed = self.port_dataShort_in.getPacket() if data == None: return NOOP outData = range(len(data)) for i in range(len(data)): if self.increaseAmplitude: outData[i] = float(data[i]) * self.amplitude else: outData[i] = float(data[i]) # NOTE: You must make at least one valid pushSRI call if sriChanged: self.port_dataFloat_out.pushSRI(sri); self.port_dataFloat_out.pushPacket(outData, T, EOS, streamID) return NORMAL """ # TODO fill in your code here self._log.debug("process() example log message") return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.INFO) logging.debug("Starting Component") start_component(PyCallbacks_i)
data, T, EOS, streamID, sri, sriChanged, inputQueueFlushed = self.port_dataShort_in.getPacket() if data == None: return NOOP outData = range(len(data)) for i in range(len(data)): if self.increaseAmplitude: outData[i] = float(data[i]) * self.amplitude else: outData[i] = float(data[i]) # NOTE: You must make at least one valid pushSRI call if sriChanged: self.port_dataFloat_out.pushSRI(sri); self.port_dataFloat_out.pushPacket(outData, T, EOS, streamID) return NORMAL """ # TODO fill in your code here self._log.debug("process() example log message") return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.WARN) logging.debug("Starting Component") start_component(props_i)
somelonglongprop = simple_property(\ id_='DCE:a7de97ee-1e78-45e9-8e2b-204c141656fc', type_="longlong", name="somelonglongprop", defvalue=12345678901) somelonglongprop2 = simple_property(\ id_='DCE:9ec6e2ff-6a4f-4452-8f38-4df47d6eebc1', type_="longlong", name="somelonglongprop2", defvalue=12345678901) class SomeStruct(object): field1 = simple_property(id_="item1", type_="string", defvalue="value1") field2 = simple_property(id_="item2", type_="long", defvalue=100) field3 = simple_property(id_="item3", type_="double", defvalue=3.14156) struct = struct_property(id_="DCE:ffe634c9-096d-425b-86cc-df1cce50612f", name="struct_test", structdef=SomeStruct) if __name__ == '__main__': logging.getLogger().setLevel(logging.DEBUG) start_component(CommandWrapper_i)
if data == None: return NOOP outData = range(len(data)) for i in range(len(data)): if self.increaseAmplitude: outData[i] = float(data[i]) * self.amplitude else: outData[i] = float(data[i]) # NOTE: You must make at least one valid pushSRI call if sriChanged: self.port_dataFloat_out.pushSRI(sri); self.port_dataFloat_out.pushPacket(outData, T, EOS, streamID) return NORMAL """ # TODO fill in your code here self._log.debug("process() example log message") return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.INFO) logging.debug("Starting Component") start_component(name.space.comp_i)
In general, you should add customization here and not in the __init__ constructor. If you have a custom port implementation you can override the specific implementation here with a statement similar to the following: self.some_port = MyPortImplementation() """ # TODO add customization here. def getPort(self, name): if name == 'a_in': print "Looks like a_in is being grabbed, throwing exception!" raise CF.PortSupplier.UnknownPort if name == 'b_in': print "Looks like b_in is being grabbed" if name == 'a_out': print "Looks like a_out is being grabbed" if name == 'b_out': print "Looks like b_out is being grabbed" super(testIDE1095_i, self).getPort(name) def process(self): # TODO fill in your code here self._log.debug("process() example log message") return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.INFO) logging.debug("Starting Component") start_component(testIDE1095_i)
if packet.dataBuffer is None: return NOOP outData = range(len(packet.dataBuffer)) for i in range(len(packet.dataBuffer)): if self.increaseAmplitude: outData[i] = float(packet.dataBuffer[i]) * self.amplitude else: outData[i] = float(packet.dataBuffer[i]) # NOTE: You must make at least one valid pushSRI call if packet.sriChanged: self.port_dataFloat_out.pushSRI(packet.SRI); self.port_dataFloat_out.pushPacket(outData, packet.T, packet.EOS, packet.streamID) return NORMAL """ # TODO fill in your code here self._log.debug("process() example log message") return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.INFO) logging.debug("Starting Component") start_component(empty_comp_i)
if packet.dataBuffer is None: return NOOP outData = range(len(packet.dataBuffer)) for i in range(len(packet.dataBuffer)): if self.increaseAmplitude: outData[i] = float(packet.dataBuffer[i]) * self.amplitude else: outData[i] = float(packet.dataBuffer[i]) # NOTE: You must make at least one valid pushSRI call if packet.sriChanged: self.port_dataFloat_out.pushSRI(packet.SRI) self.port_dataFloat_out.pushPacket(outData, packet.T, packet.EOS, packet.streamID) return NORMAL """ # TODO fill in your code here self._log.debug("process() example log message") return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.INFO) logging.debug("Starting Component") start_component(pythonSoftpkgDep_i)
if data == None: return NOOP outData = range(len(data)) for i in range(len(data)): if self.increaseAmplitude: outData[i] = float(data[i]) * self.amplitude else: outData[i] = float(data[i]) # NOTE: You must make at least one valid pushSRI call if sriChanged: self.port_dataFloat_out.pushSRI(sri); self.port_dataFloat_out.pushPacket(outData, T, EOS, streamID) return NORMAL """ # TODO fill in your code here self._log.debug("process() example log message") return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.INFO) logging.debug("Starting Component") start_component(comp_i)
packet = self.port_dataShort_in.getPacket() if packet.dataBuffer is None: return NOOP outData = range(len(packet.dataBuffer)) for i in range(len(packet.dataBuffer)): if self.increaseAmplitude: outData[i] = float(packet.dataBuffer[i]) * self.amplitude else: outData[i] = float(packet.dataBuffer[i]) # NOTE: You must make at least one valid pushSRI call if packet.sriChanged: self.port_dataFloat_out.pushSRI(packet.SRI); self.port_dataFloat_out.pushPacket(outData, packet.T, packet.EOS, packet.streamID) return NORMAL """ # TODO fill in your code here self._log.debug("process() example log message") return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.INFO) logging.debug("Starting Component") start_component(comp_src_i)
# # REDHAWK core is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # details. # # You should have received a copy of the GNU Lesser General Public License # along with this program. If not, see http://www.gnu.org/licenses/. # # from ossie.cf import CF, CF__POA from ossie.resource import Resource, start_component import time import logging class SlowComponent_i(CF__POA.Resource, Resource): """This component simply ensures that all other components in the waveform get started and stopped together.""" def __init__(self, identifier, execparams): Resource.__init__(self, identifier, execparams) delay = int(execparams["CREATE_DELAY"]) self._log.debug('Delaying create completion by %d seconds', delay) time.sleep(delay) if __name__ == '__main__': logging.getLogger().setLevel(logging.DEBUG) start_component(SlowComponent_i)
value['structprop::alpha'] = alpha_enums elif prop.id == "structseq": number_enums = {} number_enums[ 'POSITIVE'] = enums.structseq_struct.number.POSITIVE number_enums['ZERO'] = enums.structseq_struct.number.ZERO number_enums[ 'NEGATIVE'] = enums.structseq_struct.number.NEGATIVE value['structseq::number'] = number_enums text_enums = {} text_enums['HEADER'] = enums.structseq_struct.text.HEADER text_enums['BODY'] = enums.structseq_struct.text.BODY text_enums['FOOTER'] = enums.structseq_struct.text.FOOTER value['structseq::text'] = text_enums else: unknown.append(prop) prop.value = properties.props_to_any( properties.props_from_dict(value)) if unknown: raise CF.UnknownProperties(unknown) return testValues if __name__ == '__main__': logging.getLogger().setLevel(logging.INFO) logging.debug("Starting Component") start_component(EnumTest_i)
structdef=SomeStruct) class MulticastAddress(object): ip_address = simple_property(id_="ip_address", type_="string") port = simple_property(id_="port", type_="ushort") def __init__(self, ip_address="", port=0): self.ip_address = ip_address self.port = port multicasts = structseq_property(id_="DCE:897a5489-f680-46a8-a698-e36fd8bbae80[]", name="multicasts", structdef=MulticastAddress, defvalue=[MulticastAddress("127.0.0.1", 6800), MulticastAddress("127.0.0.1", 42000)]) magicword = simple_property(id_="magicword", name="magicword", type_="string", action="external", kinds=("configure",), defvalue="nada - better change me when you create me") def __init__(self, identifier, execparams): Resource.__init__(self, identifier, execparams) if __name__ == '__main__': logging.getLogger().setLevel(logging.DEBUG) start_component(TestStructDep)
if data == None: return NOOP outData = range(len(data)) for i in range(len(data)): if self.increaseAmplitude: outData[i] = float(data[i]) * self.amplitude else: outData[i] = float(data[i]) # NOTE: You must make at least one valid pushSRI call if sriChanged: self.port_dataFloat_out.pushSRI(sri); self.port_dataFloat_out.pushPacket(outData, T, EOS, streamID) return NORMAL """ # TODO fill in your code here self._log.debug("process() example log message") return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.WARN) logging.debug("Starting Component") start_component(ticket_490_single_i)
port = simple_property(id_="port", type_="ushort") def __init__(self, ip_address="", port=0): self.ip_address = ip_address self.port = port multicasts = structseq_property(id_="DCE:897a5489-f680-46a8-a698-e36fd8bbae80[]", name="multicasts", structdef=MulticastAddress, defvalue=[MulticastAddress("127.0.0.1", 6800), MulticastAddress("127.0.0.1", 42000)]) def __init__(self, identifier, execparams): Resource.__init__(self, identifier, execparams) def runTest(self, test, props): if test == 0: # Inject values directly into property storage to allow testing of # bad conditions (invalid values) for dt in props: try: self._props[dt.id] = from_any(dt.value) except KeyError: pass return [] if __name__ == '__main__': logging.getLogger().setLevel(logging.DEBUG) start_component(TestPythonProps)
else: return -(math.pi-math.atan((y-yRead)/(x-xRead))) def radialDistance(self,x, y): #critical, accounts for discontinuities in arctan dist= math.fabs(x-y)%(2*math.pi) if(dist>math.pi): return 2*math.pi- dist return dist def normalize(self,totalP): for x in range(self.xsize): for y in range(self.ysize): self.array[x][y]=self.array[x][y]/totalP #self.maxHMVal= self.maxHMVal/totalP return self.array def greatestLoc(self): maxProb, maxX, maxY= -1,-1,-1 for x in range(self.xsize): for y in range(self.ysize): if(self.array[x][y]>maxProb): maxProb= self.array[x][y] maxX= x maxY= y return maxX, maxY if __name__ == '__main__': logging.getLogger().setLevel(logging.INFO) logging.debug("Starting Component") start_component(updater_i)
EOS = True streamID = "test" sri = bulkio.sri.create(streamID) sri.xdelta = 0.001 self.port_dataFloat.pushSRI(sri) self.port_dataFloat.pushPacket( outData, T, EOS, streamID) self.port_dataDouble.pushSRI(sri) self.port_dataDouble.pushPacket( outData, T, EOS, streamID) self.port_dataShort.pushSRI(sri) self.port_dataShort.pushPacket( outData, T, EOS, streamID) self.port_dataUshort.pushSRI(sri) self.port_dataUshort.pushPacket( outData, T, EOS, streamID) self.port_dataLong.pushSRI(sri) self.port_dataLong.pushPacket( outData, T, EOS, streamID) self.port_dataUlong.pushSRI(sri) self.port_dataUlong.pushPacket( outData, T, EOS, streamID) self.port_dataLongLong.pushSRI(sri) self.port_dataLongLong.pushPacket( outData, T, EOS, streamID) self.port_dataUlongLong.pushSRI(sri) self.port_dataUlongLong.pushPacket( outData, T, EOS, streamID) return FINISH if __name__ == '__main__': logging.getLogger().setLevel(logging.WARN) logging.debug("Starting Component") start_component(TestLargePush_i)
data, T, EOS, streamID, sri, sriChanged, inputQueueFlushed = self.port_dataShort_in.getPacket() if data == None: return NOOP outData = range(len(data)) for i in range(len(data)): if self.increaseAmplitude: outData[i] = float(data[i]) * self.amplitude else: outData[i] = float(data[i]) # NOTE: You must make at least one valid pushSRI call if sriChanged: self.port_dataFloat_out.pushSRI(sri); self.port_dataFloat_out.pushPacket(outData, T, EOS, streamID) return NORMAL """ # TODO fill in your code here self._log.debug("process() example log message") return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.WARN) logging.debug("Starting Component") start_component(TestComponentProperty_i)
if data == None: return NOOP outData = range(len(data)) for i in range(len(data)): if self.increaseAmplitude: outData[i] = float(data[i]) * self.amplitude else: outData[i] = float(data[i]) # NOTE: You must make at least one valid pushSRI call if sriChanged: self.port_dataFloat_out.pushSRI(sri); self.port_dataFloat_out.pushPacket(outData, T, EOS, streamID) return NORMAL """ # TODO fill in your code here self._log.debug("process() example log message") return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.INFO) logging.debug("Starting Component") start_component(noop_mix_two_i)
packet = self.port_dataShort_in.getPacket() if packet.dataBuffer is None: return NOOP outData = range(len(packet.dataBuffer)) for i in range(len(packet.dataBuffer)): if self.increaseAmplitude: outData[i] = float(packet.dataBuffer[i]) * self.amplitude else: outData[i] = float(packet.dataBuffer[i]) # NOTE: You must make at least one valid pushSRI call if packet.sriChanged: self.port_dataFloat_out.pushSRI(packet.SRI) self.port_dataFloat_out.pushPacket(outData, packet.T, packet.EOS, packet.streamID) return NORMAL """ # TODO fill in your code here self._log.debug("process() example log message") return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.INFO) logging.debug("Starting Component") start_component(empty_comp_i)
a custom port implementation you can override the specific implementation here with a statement similar to the following: self.some_port = MyPortImplementation() """ # TODO add customization here. def getPort(self, name): if name == 'a_in': print "Looks like a_in is being grabbed, throwing exception!" raise CF.PortSupplier.UnknownPort if name == 'b_in': print "Looks like b_in is being grabbed" if name == 'a_out': print "Looks like a_out is being grabbed" if name == 'b_out': print "Looks like b_out is being grabbed" super(testIDE1095_i, self).getPort(name) def process(self): # TODO fill in your code here self._log.debug("process() example log message") return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.INFO) logging.debug("Starting Component") start_component(testIDE1095_i)
data, T, EOS, streamID, sri, sriChanged, inputQueueFlushed = self.port_dataShort_in.getPacket() if data == None: return NOOP outData = range(len(data)) for i in range(len(data)): if self.increaseAmplitude: outData[i] = float(data[i]) * self.amplitude else: outData[i] = float(data[i]) // NOTE: You must make at least one valid pushSRI call if sriChanged: self.port_dataFloat_out.pushSRI(sri); } self.port_dataFloat_out.pushPacket(outData, T, EOS, streamID) return NORMAL """ # TODO fill in your code here self._log.debug("process() example log message") return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.WARN) logging.debug("Starting Component") start_component(NOOP_ROLL_i)
if data == None: return NOOP outData = range(len(data)) for i in range(len(data)): if self.increaseAmplitude: outData[i] = float(data[i]) * self.amplitude else: outData[i] = float(data[i]) # NOTE: You must make at least one valid pushSRI call if sriChanged: self.port_dataFloat_out.pushSRI(sri); self.port_dataFloat_out.pushPacket(outData, T, EOS, streamID) return NORMAL """ # TODO fill in your code here self._log.debug("process() example log message") return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.INFO) logging.debug("Starting Component") start_component(hanging_stop_and_release_i)
# - A boolean called increaseAmplitude data, T, EOS, streamID, sri, sriChanged, inputQueueFlushed = self.port_dataShort_in.getPacket() if data == None: return NOOP outData = range(len(data)) for i in range(len(data)): if self.increaseAmplitude: outData[i] = float(data[i]) * self.amplitude else: outData[i] = float(data[i]) // NOTE: You must make at least one valid pushSRI call if sriChanged: self.port_dataFloat_out.pushSRI(sri); } self.port_dataFloat_out.pushPacket(outData, T, EOS, streamID) return NORMAL """ # TODO fill in your code here return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.WARN) logging.debug("Starting Component") start_component(CommandWrapperStartCounter_i)
def initialize(self): Resource.initialize(self) self.toTest = TestUsesPort() self.fromOther = TestProvidesPort(self._get_identifier() + "/resource_in") self.toPropSet = PropSetUsesPort() self.eventSupplier = EventSupplierPort() self.eventConsumer = EventConsumerPort(self._onPush) self.toDomainManager = DomainManagerUsesPort() self.toDeviceManager = DeviceManagerUsesPort() def runTest(self, testid, properties): if testid == 0: return self.toTest.getIdentifiers() elif testid == 1: return self.toPropSet.query([]) elif testid == 2: return self.toDomainManager.getIdentifiers() elif testid == 3: return self.toDeviceManager.getIdentifiers() else: raise CF.TestableObject.UnknownTest() return [] def _onPush(self, data, typecode): if data == "message": self.eventSupplier.sendEvent(any.to_any("response")) if __name__ == '__main__': start_component(PortTest)
if not data: return NOOP if sriChanged: logging.debug("process() sri changed : " + str(sri) + " T: " + str(T)) self.port_dataSDDS_out.pushSRI(sri,T) self.port_dataVITA49_out.pushSRI(sri,T) self.packets_ingested += 1 return NORMAL def newSriCallback(self,sri): # Query SRIs to ensure deadlock doesn't occur sddsSriList = self.port_dataSDDS_in._get_activeSRIs() vita49SriList = self.port_dataVITA49_in._get_activeSRIs() self.callback_stats.num_new_sri_callbacks += 1 def sriChangeCallback(self,sri): # Query SRIs to ensure deadlock doesn't occur sddsSriList = self.port_dataSDDS_in._get_activeSRIs() vita49SriList = self.port_dataVITA49_in._get_activeSRIs() self.callback_stats.num_sri_change_callbacks += 1 if __name__ == '__main__': logging.getLogger().setLevel(logging.INFO) logging.debug("Starting Component") start_component(multiout_attachable_i)
""" Example component to demonstrate REDHAWK sender-side messaging port. """ message_out = usesport(name="message_out", repid="IDL:CosEventComm/PushConsumer:1.0", type_="data") def __init__(self, identifier, execparams): Resource.__init__(self, identifier, execparams) def initialize(self): self.message_out = events.MessageSupplierPort() def start(self): single_msg = test_message() single_msg.item_float = 1.0 single_msg.item_string = 'some string' self.message_out.sendMessage(single_msg) msg = test_message() msg.item_float = 2.0 msg.item_string = 'another string' msg2 = test_message() msg2.item_float = 3.0 msg2.item_string = 'yet another string' self.message_out.sendMessages([msg, msg2]) if __name__ == '__main__': logging.getLogger().setLevel(logging.DEBUG) start_component(TestMessagePort)
if packet.dataBuffer is None: return NOOP outData = range(len(packet.dataBuffer)) for i in range(len(packet.dataBuffer)): if self.increaseAmplitude: outData[i] = float(packet.dataBuffer[i]) * self.amplitude else: outData[i] = float(packet.dataBuffer[i]) # NOTE: You must make at least one valid pushSRI call if packet.sriChanged: self.port_dataFloat_out.pushSRI(packet.SRI); self.port_dataFloat_out.pushPacket(outData, packet.T, packet.EOS, packet.streamID) return NORMAL """ # TODO fill in your code here self._log.debug("process() example log message") a = b return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.INFO) logging.debug("Starting Component") start_component(svc_fn_error_i)
data, T, EOS, streamID, sri, sriChanged, inputQueueFlushed = self.port_dataShort_in.getPacket() if data == None: return NOOP outData = range(len(data)) for i in range(len(data)): if self.increaseAmplitude: outData[i] = float(data[i]) * self.amplitude else: outData[i] = float(data[i]) # NOTE: You must make at least one valid pushSRI call if sriChanged: self.port_dataFloat_out.pushSRI(sri); self.port_dataFloat_out.pushPacket(outData, T, EOS, streamID) return NORMAL """ # TODO fill in your code here self._log.debug("process() example log message") return NOOP if __name__ == "__main__": logging.getLogger().setLevel(logging.WARN) logging.debug("Starting Component") start_component(TestComponentProperty_i)
packet = self.port_dataShort_in.getPacket() if packet.dataBuffer is None: return NOOP outData = range(len(packet.dataBuffer)) for i in range(len(packet.dataBuffer)): if self.increaseAmplitude: outData[i] = float(packet.dataBuffer[i]) * self.amplitude else: outData[i] = float(packet.dataBuffer[i]) # NOTE: You must make at least one valid pushSRI call if packet.sriChanged: self.port_dataFloat_out.pushSRI(packet.SRI); self.port_dataFloat_out.pushPacket(outData, packet.T, packet.EOS, packet.streamID) return NORMAL """ # TODO fill in your code here self._log.debug("process() example log message") return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.INFO) logging.debug("Starting Component") start_component(configure_call_property_i)
if data == None: return NOOP outData = range(len(data)) for i in range(len(data)): if self.increaseAmplitude: outData[i] = float(data[i]) * self.amplitude else: outData[i] = float(data[i]) # NOTE: You must make at least one valid pushSRI call if sriChanged: self.port_dataFloat_out.pushSRI(sri); self.port_dataFloat_out.pushPacket(outData, T, EOS, streamID) return NORMAL """ # TODO fill in your code here self._log.debug("process() example log message") return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.INFO) logging.debug("Starting Component") start_component(component_stub_i)
if data == None: return NOOP outData = range(len(data)) for i in range(len(data)): if self.increaseAmplitude: outData[i] = float(data[i]) * self.amplitude else: outData[i] = float(data[i]) # NOTE: You must make at least one valid pushSRI call if sriChanged: self.port_dataFloat_out.pushSRI(sri); self.port_dataFloat_out.pushPacket(outData, T, EOS, streamID) return NORMAL """ # TODO fill in your code here self._log.debug("process() example log message") return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.INFO) logging.debug("Starting Component") start_component(noop_mix_three_i)
if self.firsttime or sriChanged: self.port_out.pushSRI(sri) self.firsttime = False outData=[] for d in data: if useA: res = self.evaluate(a=d) else: res = self.evaluate(b=d) outData.append(res) self.port_out.pushPacket(outData, T, bool(EOS), streamID, sri.mode) return NORMAL def evaluate(self,**keys): """This is where we evaluate the result of the function NOTE - eval is not safe -- users can do serious damage with this We might consider using a safer (and less powerful) way to evaluate the function If we need to """ try: return eval(self.equation,self.globals, keys) except ZeroDivisionError: return float('nan') if __name__ == '__main__': logging.getLogger().setLevel(logging.WARN) logging.debug("Starting Component") start_component(fcalc_i)
outData = range(len(packet.dataBuffer)) for i in range(len(packet.dataBuffer)): if self.increaseAmplitude: outData[i] = float(packet.dataBuffer[i]) * self.amplitude else: outData[i] = float(packet.dataBuffer[i]) # NOTE: You must make at least one valid pushSRI call if packet.sriChanged: self.port_dataFloat_out.pushSRI(packet.SRI) self.port_dataFloat_out.pushPacket(outData, packet.T, packet.EOS, packet.streamID) return NORMAL """ # TODO fill in your code here self._log.debug("process() example log message") self._baseLog.debug("message from _log") self.baseline_1_logger.debug("message from baseline_1_logger") self.baseline_2_logger.debug("message from baseline_2_logger") self.namespaced_logger.debug("message from namespaced_logger") self.basetree_logger.debug("message from basetree_logger") return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.INFO) logging.debug("Starting Component") start_component(logger_py_i)
for i in range(len(data)): if self.increaseAmplitude: outData[i] = float(data[i]) * self.amplitude else: outData[i] = float(data[i]) # NOTE: You must make at least one valid pushSRI call if sriChanged: self.port_dataFloat_out.pushSRI(sri); self.port_dataFloat_out.pushPacket(outData, T, EOS, streamID) return NORMAL """ # TODO fill in your code here self._log.fatal("process() example log message - FATAL ") self._log.error("process() example log message - ERROR ") self._log.warn("process() example log message - WARN ") self._log.info("process() example log message - INFO ") self._log.debug("process() example log message - DEBUG ") self._log.trace("process() example log message - TRACE ") return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.INFO) logging.debug("Starting Component") start_component(TestLoggingAPI_i)
somelonglongprop = simple_property(\ id_='DCE:a7de97ee-1e78-45e9-8e2b-204c141656fc', type_="longlong", name="somelonglongprop", defvalue=12345678901) somelonglongprop2 = simple_property(\ id_='DCE:9ec6e2ff-6a4f-4452-8f38-4df47d6eebc1', type_="longlong", name="somelonglongprop2", defvalue=12345678901) class SomeStruct(object): field1 = simple_property(id_="item1", type_="string", defvalue="value1") field2 = simple_property(id_="item2", type_="long", defvalue=100) field3 = simple_property(id_="item3", type_="double", defvalue=3.14156) struct = struct_property(id_="DCE:ffe634c9-096d-425b-86cc-df1cce50612f", name="struct_test", structdef=SomeStruct) if __name__ == '__main__': import sys logging.getLogger().setLevel(logging.DEBUG) start_component(CommandWrapper_i, loggerName='CommandWrapper')
if data == None: return NOOP outData = range(len(data)) for i in range(len(data)): if self.increaseAmplitude: outData[i] = float(data[i]) * self.amplitude else: outData[i] = float(data[i]) # NOTE: You must make at least one valid pushSRI call if sriChanged: self.port_dataFloat_out.pushSRI(sri); self.port_dataFloat_out.pushPacket(outData, T, EOS, streamID) return NORMAL """ # TODO fill in your code here self._log.debug("process() example log message") return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.INFO) logging.debug("Starting Component") start_component(py_i)
data, T, EOS, streamID, sri, sriChanged, inputQueueFlushed = self.port_dataShort_in.getPacket() if data == None: return NOOP outData = range(len(data)) for i in range(len(data)): if self.increaseAmplitude: outData[i] = float(data[i]) * self.amplitude else: outData[i] = float(data[i]) # NOTE: You must make at least one valid pushSRI call if sriChanged: self.port_dataFloat_out.pushSRI(sri); self.port_dataFloat_out.pushPacket(outData, T, EOS, streamID) return NORMAL """ # TODO fill in your code here self._log.debug("process() example log message") return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.WARN) logging.debug("Starting Component") start_component(TestPythonPropsRange_i)
data, T, EOS, streamID, sri, sriChanged, inputQueueFlushed = self.port_dataShort_in.getPacket() if data == None: return NOOP outData = range(len(data)) for i in range(len(data)): if self.increaseAmplitude: outData[i] = float(data[i]) * self.amplitude else: outData[i] = float(data[i]) # NOTE: You must make at least one valid pushSRI call if sriChanged: self.port_dataFloat_out.pushSRI(sri); self.port_dataFloat_out.pushPacket(outData, T, EOS, streamID) return NORMAL """ # TODO fill in your code here self._log.debug("process() example log message") return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.WARN) logging.debug("Starting Component") start_component(Sandbox_i)
# TODO fill in your code here self._log.debug("process() example log message") #LOG_DEBUG(Python_Ports_i, "serviceFunction() example log message"); self.DoPort( self.port_dataFloatIn, self.port_dataFloatOut, "FLOAT"); self.DoPort( self.port_dataDoubleIn, self.port_dataDoubleOut, "DOUBLE"); self.DoPort( self.port_dataCharIn, self.port_dataCharOut, "CHAR"); self.DoPort( self.port_dataOctetIn, self.port_dataOctetOut, "OCTET"); self.DoPort( self.port_dataShortIn, self.port_dataShortOut, "SHORT"); self.DoPort( self.port_dataUShortIn, self.port_dataUShortOut, "USHORT"); self.DoPort( self.port_dataLongIn, self.port_dataLongOut, "LONG"); self.DoPort( self.port_dataULongIn, self.port_dataULongOut, "ULONG"); self.DoPort( self.port_dataLongLongIn, self.port_dataLongLongOut, "LONGLONG"); self.DoPort( self.port_dataULongLongIn, self.port_dataULongLongOut, "ULONGLONG"); self.DoPort( self.port_dataFileIn, self.port_dataFileOut, "URL"); self.DoPort( self.port_dataXMLIn, self.port_dataXMLOut, "XML"); self._log.debug( "--TestRCV::SVC_FUNC END" ) time.sleep(.5); return NORMAL if __name__ == '__main__': logging.getLogger().setLevel(logging.WARN) logging.debug("Starting Component") start_component(Python_Ports_i)
packet = self.port_dataShort_in.getPacket() if packet.dataBuffer is None: return NOOP outData = range(len(packet.dataBuffer)) for i in range(len(packet.dataBuffer)): if self.increaseAmplitude: outData[i] = float(packet.dataBuffer[i]) * self.amplitude else: outData[i] = float(packet.dataBuffer[i]) # NOTE: You must make at least one valid pushSRI call if packet.sriChanged: self.port_dataFloat_out.pushSRI(packet.SRI); self.port_dataFloat_out.pushPacket(outData, packet.T, packet.EOS, packet.streamID) return NORMAL """ # TODO fill in your code here self._log.debug("process() example log message") return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.INFO) logging.debug("Starting Component") start_component(through_i)
if packet.dataBuffer is None: return NOOP outData = range(len(packet.dataBuffer)) for i in range(len(packet.dataBuffer)): if self.increaseAmplitude: outData[i] = float(packet.dataBuffer[i]) * self.amplitude else: outData[i] = float(packet.dataBuffer[i]) # NOTE: You must make at least one valid pushSRI call if packet.sriChanged: self.port_dataFloat_out.pushSRI(packet.SRI); self.port_dataFloat_out.pushPacket(outData, packet.T, packet.EOS, packet.streamID) return NORMAL """ # TODO fill in your code here self._log.debug("process() example log message") return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.INFO) logging.debug("Starting Component") start_component(NOOP_ADDITIONAL_DEP_i)
packet = self.port_dataShort_in.getPacket() if packet.dataBuffer is None: return NOOP outData = range(len(packet.dataBuffer)) for i in range(len(packet.dataBuffer)): if self.increaseAmplitude: outData[i] = float(packet.dataBuffer[i]) * self.amplitude else: outData[i] = float(packet.dataBuffer[i]) # NOTE: You must make at least one valid pushSRI call if packet.sriChanged: self.port_dataFloat_out.pushSRI(packet.SRI) self.port_dataFloat_out.pushPacket(outData, packet.T, packet.EOS, packet.streamID) return NORMAL """ # TODO fill in your code here self._log.debug("process() example log message") return NORMAL if __name__ == '__main__': logging.getLogger().setLevel(logging.INFO) logging.debug("Starting Component") start_component(busy_comp_i)
self.oldData = [oldData[0]]*numMissing self.oldData.extend(oldData) processData = self.oldData processData.extend(data) else: processData = data halfDelay = filtDelay/2 #make sure we have enough data to process if len(processData) >= (thisFiltLen): out = medfilt(processData,thisFiltLen) #don't include the first and last elements as there is insufficient data to get their median properly outputData = out[halfDelay:-halfDelay] #store off the last inputs to use next loop self.oldData = processData[-filtDelay:] #adjust the time code for the delay caused by the filtering T.toff = halfDelay #push out the data self.port_dataFloat_out.pushPacket(outputData.tolist(), T, EOS, sri.streamID) self.hasRun = True else: self.oldData = processData return NORMAL if __name__ == '__main__': logging.getLogger().setLevel(logging.WARN) logging.debug("Starting Component") start_component(medianfilter_i)
""" # TODO fill in your code here self._log.debug("process() example log message") if self.ecm: if self.msg_limit == self.msg_xmit: return FINISH self._log.info("Generated MSG =" + str(self.msg_xmit)) self.pub.push(self.msg_xmit) self.msg_xmit = self.msg_xmit + 1 time.sleep(.10) msgin = 0 msgin = self.sub.getData() self._log.info("Received MSG =" + str(msgin)) if msgin == (self.msg_xmit - 1): self.msg_recv = self.msg_recv + 1 else: self._log.info("mylogger" + "NO ECM ... ") return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.INFO) logging.debug("Starting Component") start_component(ECM_PY_i)
if packet.dataBuffer is None: return NOOP outData = range(len(packet.dataBuffer)) for i in range(len(packet.dataBuffer)): if self.increaseAmplitude: outData[i] = float(packet.dataBuffer[i]) * self.amplitude else: outData[i] = float(packet.dataBuffer[i]) # NOTE: You must make at least one valid pushSRI call if packet.sriChanged: self.port_dataFloat_out.pushSRI(packet.SRI); self.port_dataFloat_out.pushPacket(outData, packet.T, packet.EOS, packet.streamID) return NORMAL """ # TODO fill in your code here self._log.debug("process() example log message") return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.INFO) logging.debug("Starting Component") start_component(PropertyFilteringComp_i)
some_struct = struct_property(id_="some_struct", structdef=SomeStruct, configurationkind=("configure","event"), mode="readwrite" ) structseq_prop = structseq_property(id_="structseq_prop", structdef=SomeStruct, defvalue=[], configurationkind=("configure","event"), mode="readwrite" ) def start(self): self.myprop = 123 self.anotherprop = 123 self.seqprop = [1.0] self.some_struct.some_number = 123.0 tmp = self.SomeStruct() tmp.some_number = 2.0 tmp.some_string = "another string" newval = copy.deepcopy(self.structseq_prop) newval.append(tmp) self.structseq_prop = newval if __name__ == '__main__': logging.getLogger().setLevel(logging.DEBUG) start_component(PropertyChangeEvents)
data, T, EOS, streamID, sri, sriChanged, inputQueueFlushed = self.port_dataShort_in.getPacket() if data == None: return NOOP outData = range(len(data)) for i in range(len(data)): if self.increaseAmplitude: outData[i] = float(data[i]) * self.amplitude else: outData[i] = float(data[i]) # NOTE: You must make at least one valid pushSRI call if sriChanged: self.port_dataFloat_out.pushSRI(sri); self.port_dataFloat_out.pushPacket(outData, T, EOS, streamID) return NORMAL """ # TODO fill in your code here self._log.debug("process() example log message") return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.WARN) logging.debug("Starting Component") start_component(ServiceComponent_i)
if packet.dataBuffer is None: return NOOP outData = range(len(packet.dataBuffer)) for i in range(len(packet.dataBuffer)): if self.increaseAmplitude: outData[i] = float(packet.dataBuffer[i]) * self.amplitude else: outData[i] = float(packet.dataBuffer[i]) # NOTE: You must make at least one valid pushSRI call if packet.sriChanged: self.port_dataFloat_out.pushSRI(packet.SRI) self.port_dataFloat_out.pushPacket(outData, packet.T, packet.EOS, packet.streamID) return NORMAL """ # TODO fill in your code here self._log.debug("process() example log message") return NOOP if __name__ == '__main__': logging.getLogger().setLevel(logging.INFO) logging.debug("Starting Component") start_component(newtime_i)