示例#1
0
def simulator_main(sim_class, sim_control_class=TangoTestDeviceServerBase):
    """Main function for a simulator with class sim_class

    sim_class is a tango.server.Device subclass

    """
    run_ipython = '--ipython' in sys.argv
    if run_ipython:
        import IPython
        sys.argv.remove('--ipython')

        def start_ipython(sim_class):
            IPython.embed()

        t = threading.Thread(target=start_ipython, args=(sim_class, ))
        t.setDaemon(True)
        t.start()

    logging.basicConfig(
        format='%(asctime)s - %(name)s - %(levelname)s - %(module)s - '
        '%(pathname)s : %(lineno)d - %(message)s',
        level=logging.INFO)

    classes = [sim_class]
    if sim_control_class:
        classes.append(sim_control_class)
    server_run(classes)
        """
        print(("Saving configuration: %s" % path))

        config = {
            'device': self.attr_device,
            'counter': self.attr_counter_input,
            'pulse': self.attr_counter_output,
            'freq': self.attr_pulse_freq,
            'output_dir': self.attr_output_path,
            'labels': eval(self.attr_line_labels),
            'counter_bits': self.attr_counter_bits,
            'event_bits': self.attr_event_bits,
        }

        with open(path, 'wb') as f:
            pickle.dump(config, f)

    @command(dtype_in=str, dtype_out=None)
    def copy_dataset(self, folder):
        """
        Copies last dataset to specified folder.
        """
        source = self.attr_output_path
        dest = os.path.join(folder, os.path.basename(source))

        copyfile(source, dest)


if __name__ == "__main__":
    server_run((SyncDevice, ))
示例#3
0
            pickle.dump(config, f)

    @command(dtype_in=str, dtype_out=None)
    def copy_dataset(self, folder):
        """
        Copies last dataset to specified folder.
        """
        source = self.attr_output_path
        dest = os.path.join(folder, os.path.basename(source))

        copyfile(source, dest)

    @command(dtype_in=PyTango.DevVarStringArray, dtype_out=None)
    def copy_arbitrary_file(self, path_tuple):
        """
        Copy an arbitrary file to a specified path.

        (source, destination)

        """
        source, destination = path_tuple
        print('Copying file:\n %s -> %s' % (source, destination))
        copyfile(source, destination)
        print("... Finished!")
        if self.attr_delete_on_copy:
            os.remove(source)
            print("*** Local copy removed ***")

if __name__ == "__main__":
    server_run((SyncDevice,))
示例#4
0
def main():
    sim_data_files = ['../tests/MkatVds.xmi', '../tests/MkatVds_SIMDD.json']
    model = configure_device_model(sim_data_files)
    TangoDeviceServers = get_tango_device_server(model, sim_data_files)
    server_run(TangoDeviceServers)
示例#5
0
    host = device_property(dtype=str)
    port = device_property(dtype=int, default_value=9788)
    
    def init_device(self):
        Device.init_device(self)
        self.__current = 0.0
        self	.set_state(DevState.STANDBY)
    
    def read_voltage(self):
        self.info_stream("read_voltage(%s, %d)", self.host, self.port)
        return 9.99, time.time(), AttrQuality.ATTR_WARNING
    
    def get_current(self):
        return self.__current

    def set_current(self, current):
        # should set the power supply current
        self.__current = current

    @command
    def TurnOn(self):
        self.set_state(DevState.ON)

    @command
    def TurnOff(self):
        # turn off the actual power supply here
        self.set_state(DevState.OFF)
    
if __name__ == "__main__":
    server_run([PowerSupply])
        updates the tuple with name = resource_object_string.name
        """
        # input strings are expected to have columns seperated with a '#'
        strManager = StringManager()
        resource_string_object = strManager.str_to_object(
            resource_object_string)
        resource = Resources.get(Resources.name == resource_string_object.name)

        # Updating tuple
        resource.rate = resource_string_object.rate
        resource.amount = resource_string_object.amount
        resource.availability_start = parser.parse(
            resource_string_object.availability_start)
        resource.availability_end = parser.parse(
            resource_string_object.availability_end)

        if (resource.save()):
            print resource_string_object.name, " tuple successfully updated"
            return "SUCCESS"
        else:
            print "error while updating tuple ", resource_string_object.name
            return "FAILURE"


if __name__ == "__main__":
    server_run([ResourceManager])

# Removed for now to pass flake8 test. To be used later:
# from PyTango import AttrQuality, AttrWriteType, DispLevel, DevState, DebugIt
# from PyTango.server import device_property
示例#7
0
    port = device_property(dtype=int, default_value=9788)

    def init_device(self):
        Device.init_device(self)
        self.__current = 0.0
        self.set_state(DevState.STANDBY)

    def read_voltage(self):
        self.info_stream("read_voltage(%s, %d)", self.host, self.port)
        return 9.99, time.time(), AttrQuality.ATTR_WARNING

    def get_current(self):
        return self.__current

    def set_current(self, current):
        # should set the power supply current
        self.__current = current

    @command
    def TurnOn(self):
        self.set_state(DevState.ON)

    @command
    def TurnOff(self):
        # turn off the actual power supply here
        self.set_state(DevState.OFF)


if __name__ == "__main__":
    server_run([PowerSupply])
示例#8
0
def main():
    server_run([USBCamera])
示例#9
0
def main():
    sim_data_files = ['../tests/Weather.xmi']
    model = configure_device_model(sim_data_files)
    TangoDeviceServers = get_tango_device_server(model, sim_data_files)
    server_run(TangoDeviceServers)

#intiates all Robot communication and subscribes to Diagnostics Messages
def init_ros():
    try:
        rospy.init_node('DiagnosticMessageCollector',
                        anonymous=False,
                        log_level=rospy.INFO)
        rospy.Subscriber(DIAGNOSTICS_TOPIC, HuskyStatus, callback)
        rospy.spin()
    except ROSException as err:
        print(err)


if __name__ == "__main__":

    if SIMULATION_MODE is True:
        # global variables for simulation mode
        global BatterySim, Speedup, START_TIME
        # Battery Simulator Variable which decreases linearly over time
        BatterySim = 100.0
        #Configure Speedup
        Speedup = 0.1
        # Get current time in milliseconds
        START_TIME = time.time()

    else:
        init_ros()
    # Setup the Device server in the Tango Database
    server_run((PyRobotDiagnostics, ))