Example #1
0
def log_invoked_service(payload, invoked_service):
    rvi_node = "http://localhost:8801"
    service = "jlr.com/backend/logging/report/serviceinvoked"

    print "args:", payload
    # json_args = json.loads(payload)

    # print "json_args:", json_args
    rvi_args = [{
            'username': payload['username'],
            'vehicleVIN': payload['vehicleVIN'],
            'service': invoked_service,
            'latitude': payload['latitude'],
            'longitude': payload['longitude'],
            'timestamp': datetime.now().strftime('%Y-%m-%dT%H:%M:%S.000Z'),
            },
        ]
    print "rvi_args:", rvi_args
    rvi = RVI(rvi_node)
    rvi.message(service, rvi_args)
Example #2
0
def log_invoked_service(payload, invoked_service):
    rvi_node = "http://localhost:8801"
    service = "jlr.com/backend/logging/report/serviceinvoked"

    print "args:", payload
    # json_args = json.loads(payload)

    # print "json_args:", json_args
    rvi_args = [
        {
            'username': payload['username'],
            'vehicleVIN': payload['vehicleVIN'],
            'service': invoked_service,
            'latitude': payload['latitude'],
            'longitude': payload['longitude'],
            'timestamp': datetime.now().strftime('%Y-%m-%dT%H:%M:%S.000Z'),
        },
    ]
    print "rvi_args:", rvi_args
    rvi = RVI(rvi_node)
    rvi.message(service, rvi_args)
Example #3
0
    else:
        usage()

if len(args) < 1:
    usage()

# Construct a dictionary from the provided paths.
i = 0
service = args[0]
rvi_args = []
for i in args[1:]:
    print i
    [k, v] = i.split("=")
    rvi_args = rvi_args + [{k: v}]


#
# Setup an outbound JSON-RPC connection to the backend RVI node
# Service Edge.
#
rvi = RVI(rvi_node)

print "RVI Node:         ", rvi_node
print "Service:          ", service
print "args:             ", rvi_args

#
# Send the messge.
#
rvi.message(service, rvi_args)
        elif o == '-s':
            speedup = float(a)

        else:
            usage()

    # Welcome message
    print "RVI Big Data Device Simulator"
    print "RVI Node:             ", rvi_url
    print "File(s):              ", file_names
    print "Loop data:            ", loop_data
    print "Speedup:              ", speedup
    print "Adjust time stamp:    ", adjust_ts

    # Setup outbound JSON-RPC connection to the RVI Service Edge
    rvi = RVI(rvi_url)

    # Setup data sender
    data_sender = DataSender("jlr.com/backend/logging/report", rvi)

    for file_name in file_names:
        try:
            file_reader = TaxiFileReader(file_name, data_sender, speedup,
                                         loop_data, adjust_ts)
        except IOError:
            print "Failed to open file {}. Skipped.".format(file_name)

        file_reader.start()

    # catch signals for proper shutdown
    for sig in (SIGABRT, SIGTERM, SIGINT):
Example #5
0
opts, args = getopt.getopt(sys.argv[1:], "n:")

rvi_node_url = "http://localhost:8801"
for o, a in opts:
    if o == "-n":
        rvi_node_url = a
    else:
        usage()

if len(args) != 1:
    usage()

service_name = args[0]

# Setup a connection to the local RVI node
rvi = RVI(rvi_node_url)

# Starting the thread that handles incoming calls is
# not really necessary since register_service will do it for us.

rvi.start_serve_thread()

rvi.set_services_available_callback(services_available)
rvi.set_services_unavailable_callback(services_unavailable)

# Register our service  and invoke 'service_invoked' if we
# get an incoming JSON-RPC call to it from the RVI node
#
full_service_name = rvi.register_service(service_name, service_invoked)

print "RVI General Service."
Example #6
0
    print "Example: ./callrvi.py http://rvi1.nginfotpdx.net:8801"
    print
    sys.exit(255)


#
# Check that we have the correct arguments
#
if len(sys.argv) != 1 and len(sys.argv) != 2:
    usage()

progname = sys.argv[0]

if len(sys.argv) == 2:
    rvi_node = sys.argv[1]
else:
    rvi_node = "http://localhost:8801"

#
# Setup an outbound JSON-RPC connection to the backend RVI node
# Service Edge.
#
rvi = RVI(rvi_node)


#
# Retreieve services
#
for i in rvi.get_available_services():
    print i
Example #7
0
rvi_node_url = "http://localhost:8801"
for o, a in opts:
    if o == "-n":
        rvi_node_url = a
    else:
        usage()

if len(args) != 1:
    usage()

service_name = args[0]


# Setup a connection to the local RVI node
rvi = RVI(rvi_node_url)

# Starting the thread that handles incoming calls is
# not really necessary since register_service will do it for us.

rvi.start_serve_thread() 

rvi.set_services_available_callback(services_available) 
rvi.set_services_unavailable_callback(services_unavailable) 

# Register our service  and invoke 'service_invoked' if we 
# get an incoming JSON-RPC call to it from the RVI node
#
full_service_name = rvi.register_service(service_name, service_invoked) 

Example #8
0
GPIO.setup(GPIO_LOCK, GPIO.OUT)  # lock
GPIO.setup(GPIO_LIGHTS, GPIO.OUT)  # lights
GPIO.setup(GPIO_TRUNK, GPIO.OUT)  # trunk (weird)
GPIO.setup(GPIO_PANIC, GPIO.OUT)  # panic

#
# Setup initial state
#
GPIO.output(GPIO_UNLOCK, GPIO.LOW)
GPIO.output(GPIO_LOCK, GPIO.LOW)
GPIO.output(GPIO_LIGHTS, GPIO.LOW)
GPIO.output(GPIO_TRUNK, GPIO.LOW)
GPIO.output(GPIO_PANIC, GPIO.LOW)

# Setup a connection to the local RVI node
rvi = RVI(rvi_node_url)

# Starting the thread that handles incoming calls is
# not really necessary since register_service will do it for us.

rvi.start_serve_thread() 

rvi.set_services_available_callback(services_available) 
rvi.set_services_unavailable_callback(services_unavailable) 

# Register our service  and invoke 'service_invoked' if we 
# get an incoming JSON-RPC call to it from the RVI node
#
rvi.register_service("unlock", unlock_invoked) 
rvi.register_service("lock", lock_invoked) 
#rvi.register_service("start", start_invoked) 
Example #9
0
GPIO.setup(GPIO_START, GPIO.OUT)
GPIO.setup(GPIO_STOP, GPIO.OUT)

#
# Setup initial state
#
GPIO.output(GPIO_UNLOCK, GPIO.LOW)
GPIO.output(GPIO_LOCK, GPIO.LOW)
GPIO.output(GPIO_LIGHTS, GPIO.LOW)
GPIO.output(GPIO_TRUNK, GPIO.LOW)
GPIO.output(GPIO_PANIC, GPIO.LOW)
GPIO.output(GPIO_START, GPIO.LOW)
GPIO.output(GPIO_STOP, GPIO.LOW)

# Setup a connection to the local RVI node
rvi = RVI(rvi_node_url)

# Starting the thread that handles incoming calls is
# not really necessary since register_service will do it for us.

rvi.start_serve_thread()

rvi.set_services_available_callback(services_available)
rvi.set_services_unavailable_callback(services_unavailable)

# Register our service  and invoke 'service_invoked' if we
# get an incoming JSON-RPC call to it from the RVI node
#
rvi.register_service("unlock", unlock_invoked)
rvi.register_service("lock", lock_invoked)
rvi.register_service("auto_unlock", auto_unlock_invoked)
    print
    print "Example: ./callrvi.py http://rvi1.nginfotpdx.net:8801"
    print
    sys.exit(255)


#
# Check that we have the correct arguments
#
if len(sys.argv) != 1 and len(sys.argv) != 2:
    usage()

progname = sys.argv[0]

if len(sys.argv) == 2:
    rvi_node = sys.argv[1]
else:
    rvi_node = "http://localhost:8801"

#
# Setup an outbound JSON-RPC connection to the backend RVI node
# Service Edge.
#
rvi = RVI(rvi_node)

#
# Retreieve services
#
for i in rvi.get_available_services():
    print i
Example #11
0
# Grab the URL to use
[ progname, rvi_url ] = sys.argv    


# setup the service names we will register with
# The complete service name will be: 
#  jlr.com/vin/1234/hvac/publish
#       - and -
#  jlr.com/vin/1234/hvac/subscribe
#
# Replace 1234 with the VIN number setup in the
# node_service_prefix entry in vehicle.config

# Setup an outbound JSON-RPC connection to the RVI Service Edge.
# Setup a connection to the local RVI node
rvi_server = RVI(rvi_url)
rvi_server.start_serve_thread() 


# Register our service  and invoke 'service_invoked' if we 
# get an incoming JSON-RPC call to it from the RVI node
#


server = ThreadedHTTPServer(('', 9000), WSSOTAHandler)
server.daemon_threads = True
server.auth = b64encode("")
print('started http server at port 9000')
ws_thread = threading.Thread(target=server.serve_forever)
ws_thread.start()
Example #12
0
# 
# Check that we have the correct arguments
#
if len(sys.argv) <2:
    usage()

progname = sys.argv[0]
rvi_node = sys.argv[1]


#
# Setup an outbound JSON-RPC connection to the backend RVI node
# Service Edge.
#
rvi = RVI(rvi_node)


print "RVI Node:         ", rvi_node


#
# Send the messge.
#
print rvi.get_available_services()





Example #13
0
        rvi_node = a
    else:
        usage()

if len(args) < 1:
    usage()

# Construct a dictionary from the provided paths.
i = 0
service = args[0]
rvi_args = {}
for i in args[1:]:
    print i
    [k, v] = i.split('=')
    rvi_args[k] = v

#
# Setup an outbound JSON-RPC connection to the backend RVI node
# Service Edge.
#
rvi = RVI(rvi_node)

print "RVI Node:         ", rvi_node
print "Service:          ", service
print "args:             ", rvi_args

#
# Send the messge.
#
rvi.message(service, rvi_args)
Example #14
0
    print "Download transaction",retry," completed with:",status
    return {u'status': 0}


# 
# Check that we have the correct arguments
#
if len(sys.argv) != 2:

    usage()

# Grab the URL to use
[ progname, rvi_url ] = sys.argv    

# Setup an outbound JSON-RPC connection to the RVI Service Edge.
rvi_server = RVI(rvi_url)
rvi_server.start_serve_thread() 

#
# Regsiter callbacks for incoming JSON-RPC calls delivered to
# the SOTA server from the vehicle RVI node's Service Edge.
#

full_initiate_download_service_name = rvi_server.register_service("/sota/initiate_download", initiate_download )
full_cancel_download_service_name = rvi_server.register_service("/sota/cancel_download", cancel_download )
full_download_complete_service_name = rvi_server.register_service("/sota/download_complete", download_complete )


print "Vehicle RVI node URL:                 ", rvi_url
print "Full initiate download service name : ", full_initiate_download_service_name
print "Full download complete service name : ", full_download_complete_service_name
Example #15
0
    print "through an RVI node."
    print
    print "Usage:", sys.argv[0], " RVI-node"
    print
    print "Example: ./callrvi.py http://rvi1.nginfotpdx.net:8801"
    print
    sys.exit(255)


#
# Check that we have the correct arguments
#
if len(sys.argv) < 2:
    usage()

progname = sys.argv[0]
rvi_node = sys.argv[1]

#
# Setup an outbound JSON-RPC connection to the backend RVI node
# Service Edge.
#
rvi = RVI(rvi_node)

print "RVI Node:         ", rvi_node

#
# Send the messge.
#
print rvi.get_available_services()