コード例 #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))
コード例 #2
0
    reconnectInterval=1,
    # nodeId='bd7610ba-e787-4131-b23e-cfa452185e08',
    nodeId='71b52ec1-2e0f-437a-8f79-32be8d45ecff',
    # If type is Device, DeviceId must be filled
    deviceId='deviceId',
    # 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="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)