Ejemplo n.º 1
0
 def clickedConnect():
     try:
         if App.nodeId.get() == '':
             messagebox.showwarning("Warging", 'nodeId is necessary')
             return
         selectTab = tabControl.tab(tabControl.select(), 'text')
         edgeAgentOptions = EdgeAgentOptions(nodeId=App.nodeId.get())
         if selectTab == 'MQTT':
             edgeAgentOptions.connectType = constant.ConnectType['MQTT']
             mqttOptions = MQTTOptions(hostName=App.hostName.get(),
                                       port=App.port.get(),
                                       userName=App.userName.get(),
                                       password=App.password.get())
             edgeAgentOptions.MQTT = mqttOptions
         elif selectTab == 'DCCS':
             edgeAgentOptions.connectType = constant.ConnectType['DCCS']
             dccsOptions = DCCSOptions(
                 apiUrl=App.apiUrl.get(),
                 credentialKey=App.credentialKey.get())
             edgeAgentOptions.DCCS = dccsOptions
         if self._edgeAgent is None:
             self._edgeAgent = EdgeAgent(edgeAgentOptions)
             self._edgeAgent.on_connected = on_connected
             self._edgeAgent.on_disconnected = on_disconnected
             self._edgeAgent.on_message = on_message
         self._edgeAgent.connect()
     except ValueError as error:
         messagebox.showwarning("Warging", str(error))
Ejemplo n.º 2
0
        def connect():
            edgeAgentOptions = EdgeAgentOptions(nodeId="04f2206c-a6d5-44d5-ae02-375fc29b8079")
            edgeAgentOptions.connectType = constant.ConnectType['DCCS']
            dccsOptions = DCCSOptions(apiUrl="https://api-dccs-ensaas.sa.wise-paas.com/", credentialKey="c7b005554b8d527a1fdf2137aea055l7")
            edgeAgentOptions.DCCS = dccsOptions

            if self.edgeAgent is None:
                self.edgeAgent = EdgeAgent(edgeAgentOptions)
                self.edgeAgent.on_connected = onConnected
                self.edgeAgent.on_disconnected = onDisconnected
                self.edgeAgent.on_message = onMessage

            self.edgeAgent.connect()
Ejemplo n.º 3
0
    deviceConfig.discreteTagList.append(discrete)

    text = TextTagConfig(name='TTag1',
                         description='TTag1',
                         readOnly=False,
                         arraySize=0)
    deviceConfig.textTagList.append(text)

    config.node.deviceList.append(deviceConfig)
    return config


_edgeAgent = None
edgeAgentOptions = EdgeAgentOptions(
    nodeId='568173b8-638b-46d6-a58f-ae7c8056f003')
edgeAgentOptions.connectType = constant.ConnectType['DCCS']
dccsOptions = DCCSOptions(apiUrl='https://api-dccs-ensaas.sa.wise-paas.com/',
                          credentialKey='b37a19560cc7473403444507b500ef0k')
edgeAgentOptions.DCCS = dccsOptions
_edgeAgent = EdgeAgent(edgeAgentOptions)
_edgeAgent.on_connected = on_connected
_edgeAgent.on_disconnected = on_disconnected
_edgeAgent.on_message = edgeAgent_on_message

_edgeAgent.connect()

time.sleep(5)  # Waiting for connection to be established

for i in range(1, 60):
    __sendData()
    time.sleep(1)
Ejemplo n.º 4
0
    heartbeat=60,                                       # Default is 60 seconds
    # Need to recover data or not when disconnected
    dataRecover=True,
    # Connection type (DCCS, MQTT), default is DCCS
    connectType=constant.ConnectType['DCCS'],
    MQTT=MQTTOptions(                                   # If connectType is MQTT, must fill this options
        hostName="127.0.0.1",
        port=1883,
        userName="******",
        password="******",
        # MQTT protocal (TCP, Websocket), default is TCP
        protocalType=constant.Protocol['TCP']
    ),
    DCCS=DCCSOptions(
        apiUrl="https://api-dccs-ensaas.sa.wise-paas.com/",         # DCCS API Url
        # credentialKey="c49fe0af415c5b79d6ab10d1b13acfp1"  # Creadential key
        credentialKey="fce6538e82e18a85a0560315652e03ti"  # Creadential key
    )
)

edge_agent = EdgeAgent(options=options)


def generate_data(data, device_id, tag_name, value):
    tag = EdgeTag(device_id, tag_name, value)
    data.tagList.append(tag)


def send_data(data):
    edge_agent.sendData(data=data)
Ejemplo n.º 5
0
    # Choice your edge is Gateway or Device, Default is Gateway
    type=constant.EdgeType['Gateway'],
    heartbeat=60,                                       # Default is 60 seconds
    # Need to recover data or not when disconnected
    dataRecover=True,
    # Connection type (DCCS, MQTT), default is DCCS
    connectType=constant.ConnectType['DCCS'],
    MQTT=MQTTOptions(                                   # If connectType is MQTT, must fill this options
        hostName="127.0.0.1",
        port=1883,
        userName="******",
        password="******",
        # MQTT protocal (TCP, Websocket), default is TCP
        protocalType=constant.Protocol['TCP']),
    DCCS=DCCSOptions(
        apiUrl="https://api-dccs-ensaas.hz.wise-paas.com.cn/",
        credentialKey="0fdf1da8f2f1bf5d65614c5a6b04d8hz"))

edge_agent = EdgeAgent(options=options)


def generate_data(data, device_id, tag_name, value):
    tag = EdgeTag(device_id, tag_name, value)
    data.tagList.append(tag)


def send_data(data):
    edge_agent.sendData(data=data)


def handler_on_connected(agent, isConnected):
Ejemplo n.º 6
0
    heartbeat=60,                                       # Default is 60 seconds
    # Need to recover data or not when disconnected
    dataRecover=True,
    # Connection type (DCCS, MQTT), default is DCCS
    connectType=constant.ConnectType['DCCS'],
    MQTT=MQTTOptions(                                   # If connectType is MQTT, must fill this options
        hostName="127.0.0.1",
        port=1883,
        userName="******",
        password="******",
        # MQTT protocal (TCP, Websocket), default is TCP
        protocalType=constant.Protocol['TCP']
    ),
    DCCS=DCCSOptions(
        apiUrl="https://api-dccs-ensaas.sa.wise-paas.com/",         # DCCS API Url
        # credentialKey="c49fe0af415c5b79d6ab10d1b13acfp1"  # Creadential key
        credentialKey="3fd45702956acdcaf50de85d0e5bd26x"  # Creadential key
    )
)

edge_agent = EdgeAgent(options=options)


def generate_data(data, device_id, tag_name, value):
    tag = EdgeTag(device_id, tag_name, value)
    data.tagList.append(tag)


def send_data(data):
    edge_agent.sendData(data=data)
    # Choice your edge is Gateway or Device, Default is Gateway
    type=constant.EdgeType['Gateway'],
    heartbeat=60,  # Default is 60 seconds
    # Need to recover data or not when disconnected
    dataRecover=True,
    # Connection type (DCCS, MQTT), default is DCCS
    connectType=constant.ConnectType['DCCS'],
    MQTT=MQTTOptions(  # If connectType is MQTT, must fill this options
        hostName="127.0.0.1",
        port=1883,
        userName="******",
        password="******",
        # MQTT protocal (TCP, Websocket), default is TCP
        protocalType=constant.Protocol['TCP']),
    DCCS=DCCSOptions(
        apiUrl="https://api-dccs-ensaas.sa.wise-paas.com/",  # DCCS API Url
        credentialKey="3fd45702956acdcaf50de85d0e5bd26x"  # Creadential key
    ))

edge_agent = EdgeAgent(options=options)


def handler_on_connected(agent, isConnected):
    # Connected: when EdgeAgent is connected to IoTHub.
    print("Connected successfully")


def handler_on_disconnected(agent, isDisconnected):
    # Disconnected: when EdgeAgent is disconnected to IoTHub.
    print("Disconnected")

Ejemplo n.º 8
0
    # Choice your edge is Gateway or Device, Default is Gateway
    type=constant.EdgeType['Gateway'],
    heartbeat=60,  # Default is 60 seconds
    # Need to recover data or not when disconnected
    dataRecover=True,
    # Connection type (DCCS, MQTT), default is DCCS
    connectType=constant.ConnectType['DCCS'],
    MQTT=MQTTOptions(  # If connectType is MQTT, must fill this options
        hostName="127.0.0.1",
        port=1883,
        userName="******",
        password="******",
        # MQTT protocal (TCP, Websocket), default is TCP
        protocalType=constant.Protocol['TCP']),
    DCCS=DCCSOptions(
        apiUrl="https://api-dccs-ensaas.hz.wise-paas.com.cn/",  # DCCS API Url
        credentialKey="3a6955c550f28374a00cd771dc0f8f8z"  # Creadential key
    ))

edge_agent = EdgeAgent(options=options)


def handler_on_connected(agent, isConnected):
    # Connected: when EdgeAgent is connected to IoTHub.
    print("Connected successfully")


def handler_on_disconnected(agent, isDisconnected):
    # Disconnected: when EdgeAgent is disconnected to IoTHub.
    print("Disconnected")