当前位置: 首页>>代码示例>>Python>>正文


Python Connector.getSignalStructure方法代码示例

本文整理汇总了Python中connector.Connector.getSignalStructure方法的典型用法代码示例。如果您正苦于以下问题:Python Connector.getSignalStructure方法的具体用法?Python Connector.getSignalStructure怎么用?Python Connector.getSignalStructure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在connector.Connector的用法示例。


在下文中一共展示了Connector.getSignalStructure方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: connect

# 需要导入模块: from connector import Connector [as 别名]
# 或者: from connector.Connector import getSignalStructure [as 别名]

#.........这里部分代码省略.........
            self.datastream_poller = None
            self.datastream_collector = None
            self.datastream_queue = None

            return True
        else:
            print ("Can't stop the data stream threads on a not-slave server")
            return False

    ## Add a new observer "update" method to the list of observers.
    # @param update_method Is the method of the observer which will be called when new data arrives. The method name is arbitrary, but it must accept a string parameter
    # @param signal_number The optional channel to register the observer to
    # @param decimation The decimation to use
    # @return The ID of the observer, to be used to remove the observer
    def addObserver(self, update_method, decimation=None, signal_number=None):
        self.setup_data_threads(None, decimation)
        return self.datastream_poller.addObserver(update_method, signal_number)

    ## Removes the observer
    # @param observer_id The ID of the observer to remove
    # @return False if the observer isn't in the observers list, True if it was correctly removed
    def removeObserver(self, observer_id):
        return self.datastream_poller.removeObserver(observer_id)

    ## Connect to the target server. Checks if master or server and call the right method on connector::Connector
    # @param password The (optional) password to catch a running master connection
    # @return The boolean result of the operation
    def connect(self, password=None):
        if self.is_slave:
            if (
                self.connection.connectSlave()
            ):  # TODO: Cambiare il metodo di connessione non passando tutto il Configurator ma usando i dati passati nel costruttore di Connector
                self.is_connected = True
                self.signal_structure = self.getSignalStructure()
                return True
            else:
                return False
        else:
            if password:
                result = self.connection.Connection_Request(
                    password
                )  # Passing self.config to let the Connector set some connection data (e.g. the session_id)
            else:
                result = self.connection.Connection_Request()
            self.is_connected = result
            return result

    ## Checks if master and if affirmative, returns the slave
    # @param target_name The target to connect to. If None gets the name from the default configuration
    # @return The slave Target or False if not a master target
    def getSlave(self, target_name=None):
        if self.is_slave:
            print "Can't ask for a slave to a slave. Try asking to a master."
            return False
        else:
            # If target is not specified, caller are requesting a "standard" connection to the primary slave target
            if not target_name:
                target_name = self.config.getAttr("target_name")

            slave = Target(
                True,
                self.config.getAttr("protocol"),
                self.config.getAttr("address"),
                self.config.getAttr("slave_port"),
                target_name,
            )
开发者ID:tommyblue,项目名称:pyRTAI,代码行数:70,代码来源:target.py


注:本文中的connector.Connector.getSignalStructure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。