diff options
author | Magnus Feuer <mfeuer@jaguarlandrover.com> | 2015-03-05 08:05:38 -0800 |
---|---|---|
committer | Magnus Feuer <mfeuer@jaguarlandrover.com> | 2015-03-05 08:05:38 -0800 |
commit | 27ccda85c18bd6e9fa3f68c459cdbebf9cfc628e (patch) | |
tree | 92ef85c1d6568bdcb6145f84ba8a66ff3b62cb73 | |
parent | a59e0d6f1a4c51fc249309de9158395a2bed92c5 (diff) | |
download | rvi_core-27ccda85c18bd6e9fa3f68c459cdbebf9cfc628e.tar.gz |
HVAC demo has been obsoleted by python/rvi_service.py and rvi_call.py
-rw-r--r-- | hvac_demo/README.md | 285 | ||||
-rw-r--r-- | hvac_demo/backend.config | 112 | ||||
-rw-r--r-- | hvac_demo/hvac_demo.png | bin | 18626 -> 0 bytes | |||
-rwxr-xr-x | hvac_demo/hvac_emulator.py | 250 | ||||
-rwxr-xr-x | hvac_demo/mobile_emulator.py | 249 | ||||
-rw-r--r-- | hvac_demo/rvi_json_rpc_server.py | 36 | ||||
-rw-r--r-- | hvac_demo/vehicle.config | 117 |
7 files changed, 0 insertions, 1049 deletions
diff --git a/hvac_demo/README.md b/hvac_demo/README.md deleted file mode 100644 index 0aab9b7..0000000 --- a/hvac_demo/README.md +++ /dev/null @@ -1,285 +0,0 @@ -Copyright (C) 2014, Jaguar Land Rover - -This document is licensed under Creative Commons -Attribution-ShareAlike 4.0 International. - - -# HVAC DEMO - VERSION 0.2 -This document describes the purpose, setup, and launch of the HVAC -demo that is the first milestone of the RVI project. - -# BACKGROUND -The remote HVAC control demo is a part of the Automotive Grade Linux -project where the Tizen IVI climate control (HVAC) screen can be -remotely controlled from a mobile device. Updates made to the IVI HVAC -screen are sent in real time to the mobile device, and vice versa. - -An initial release of the remote HVAC demo was done using the MQTT -protocol (See http://mqtt.org). The first milestone of the RVI project -will migrate the HVAC demo to the RVI technology. - -## READER ASSUMPTIONS -The reader is assumed to be able to: - -1. Have a basic understanding of Linux directory structures. -2. Start and stop programs on the RVI-hosting system - - -# PREREQUISITES -1. Erlang runtime R16B01 or later has to be installed on the hosting system. -2. Git is installed on the hosting system. - - -# DEMO COMPONENTS - -In order to test the RVI milestone 1 without having to bring up a -complete Tizen IVI and mobile device environment, a simple emulator -for these two components have been provided in hvac\_emulator.py and -mobile\_emulator.py - -All components can be run on a single system. - -Please see schematics below for an overview: - -![Demo Schematics](hvac_demo.png "Demo Schematics")<br> -*Figure 1. Demo schematics. See HVAC and mobile device emulator chapters for details* - - - -# DEMO SETUP -Two RVI nodes, both hosted by a single machine, will be involved in -the test: - -The backend RVI node will the mobile emulator -(mobile\_emulator.py). The vehicle RVI node will host the HVAC -emulator (hvac\_emulator.py). - -See [build instructions](../BUILD.md) for details on the prerequisites -for building and running the demo. - - -## INSTALL JSONRPCLIB FOR PYTHON - -The python emulator code relies on [JSONRPClib](https://github.com/joshmarshall/jsonrpclib). -This python package can be installed using either one of the two commands listed below. - - sudo easy_install jsonrpclib - sudo pip install jsonrpclib - - -## CHECK OUT THE RVI SYSTEM ## - - git clone https://gerrit.automotivelinux.org/gerrit/RVI/rvi - - -## SWITCH TO V0.2 OF THE RVI SYSTEM ## -The cloned gerrit repo contains all tags and branches. -Switch to tag v0.2 to get a release that does not contain -daily snapshots. - - cd rvi - git checkout v0.2 - - -## COMPILE THE RVI SYSTEM - - make - - -## CREATE THE VEHICLE DEVELOPMENT RELEASE - -*See ../CONFIGURE.md for details on the configuration process.* - -From the rvi root directory, setup the vehicle node: - - ./scripts/setup_rvi_node.sh -d -n vehicle -c hvac_demo/vehicle.config - -The new developer release will be created in a subdiretory named ```vehicle``` - - -## CREATE THE BACKEND DEVELOPMENT RELEASE -In a similar manner, setup the backend node: - - ./scripts/setup_rvi_node.sh -d -n backend -c hvac_demo/backend.config - - -The release will be created in a subdiretory named ```backend``` - -# DEMO LAUNCH - -## LAUNCH THE BACKEND RVI NODE - -In its own window, launch the backend rvi node that the subscription -service and mobile device emulator will connect to. - - ./scripts/rvi_node.sh -n backend - -Make a note of the Service Edge URL address printed out by the logging service. - - -## LAUNCH THE VEHICLE RVI NODE - -* Please note that the backend node must be started before the vehicle node. * - -In its own window, launch the vehicle RVI node that will serve the HVAC emulator. - - ./scripts/rvi_node.sh -n vehicle - -The VIN number that will be used by the mobile device are the digits -at the end of the "Node Service Prefix" printed out at the end of the -launch process. - -By default, the ```hvac_demo/vehicle.config``` file has its ```node_service_prefix``` -entry set to ```jlr.com/vin/1234/```, -yielding a VIN of "1234". - - -## LAUNCH THE HVAC EMULATOR - -In its own window, launch the HVAC emulator and have it connect to -the vehicle RVI node. - - cd hvac_demo - ./hvac_emulator.py http://127.0.0.1:8811 - -Modify the ```http://127.0.0.1:8811``` to match the Service Edge URL -reported by the vehicle RVI node. - -At startup the HVAC emulator will report the VIN number that it is -associacted with. (Default 1234) - -The HVAC emulator accepts \[key\] \[value\] input lines that are -distributed to all mobile devices controlling the VIN of the vehicle RVI -node. - - -## LAUNCH THE MOBILE DEVICE EMULATOR - -In its own window, launch the mobile device emulator and have it -connect to the backend RVI node. - - cd hvac_demo - ./mobile_emulator.py http://127.0.0.1:8801 +1941231234 1234 - -Modify the ```http://127.0.0.1:8801``` to match the Service Edge URL -reported by the backend RVI node. - -The phone number (+19491231234) is arbitrary, but has to be unique -across all running mobile device emulators. - -The VIN number (1234) is the VIN number reported by the HVAC emulator -at startup. - -The mobile device emulator accepts \[key\] \[value\] input lines that -are distributed to the vehicle with the matching VIN. - - -# DEMO EXECUTION - -## SEND VALUES FROM MOBILE TO HVAC EMULATOR - -Any \[key\] \[value\] entered in the mobile device emulator -will be sent up to the subscription service and forwarded to -the HVAC emulator. - - -## SEND VALUES FROM HVAC TO MOBILE EMULATOR - -Any \[key\] \[value\] entered in the HVAC emulator -will be sent up to the subscription service and forwarded to -the mobile emulator. - - -## EXIT PROGRAMS - -Terminate the mobile device emulator by entering "q" followed by enter. - -Terminate the HVAC emulator by entering "q" followed by enter. - -Terminate the subscription service by pressing Ctrl-c. - -Terminate the vehicle RVI node by pressing Ctrl-c Ctrl-c. - -Terminate the backend RVI node by pressing Ctrl-c Ctrl-c. - - - -## HVAC EMULATOR TECHNICAL DETAILS -The HVAC emulator simulates an HVAC application unit installed in a -vehicle. - -The emulator connects to the Service Edge of the vehicle RVI node, -started with "rvi_node -n vehicle" and registers two services with it: - -* ```jlr.com/vin/[vin]/hvac/subscribe```<br> - Used by the mobile emulator to subscribe to updates entered on the - HVAC emulator's command line. - -* ```jlr.com/vin/[vin]/hvac/publish```<br> - Used by the mobile emulator to report updated values entered on - its command line - -In both cases, ```jlr.com/vin/[vin]``` is the vehicle RVI node's service -prefix specified in ```vehicle.configure```->```env```->```rvi```->```node_service_prefix```. - - -The mobile emulator invokes the subscribe service above in order -to receive new HVAC values published by the HVAC emulator. - -When a new key/value pair is entered on the HVAC emulator's command line, -The mobile emulator services registered through an /hvac/subscribe -message will be invoked with the key, value, and VIN number -of the HVAC's RVI node. The receiving mobile emulators will -print out the information. - -If a new key/value pair is entered on a mobile emulator's command -line, they will be sent to the HVAC emulator's /hvac/publish service, -which will print them on screen. - - -## MOBILE DEVICE EMULATOR TECHNICAL DETAILS - -The mobile device emulator connects to Service Edge of the backend - server, started with "./rvi_node -n backend", and subscribes to - HVAC updates (temp, fan speed, etc) updates from the vehicle with a - given VIN. - -At startup, the mobile emulator will do two things: - -1. <b>Register a service with the backend RVI node</b><br> - This service is invoked by the HVAC emulator to transmit - key/value pairs entered on its commandd line. - - The service name has the following layout: - - jlr.com/backend/mobile/[phone_nr]/hvac/publish - - The ```jlr.com/backend``` prefix is the backend RVI node's service prefix specified - in ```backend.configure```->```env```->```rvi```->```node_service_prefix```. - - The ```[phone_nr]``` is the phone number specified on the command - line when the mobile emulator is started. - -2. <b>Send a suscription request to the HVAC emulator</b><br> - The HVAC emulator's subscription service is invoked as - - jlr.com/vin/[vin]/hvac/subscribe - - where ```[vin]``` is the command-line specified VIN of the - vehicle RVI node to connect to. - The subscription request's single parameter is the full name of - the publish service registered in step 1. When the HVAC - emulator has a key/value pair entered at its command line, the - key/value/vin will be sent to the publish service on the mobile - emulator. - - - When a new key/value pair is entered on the mobile emulator's - command line, simulating screen input on the HVAC app, the - key/value pair will be sent to: - - jlr.com/vin/[vin]/hvac/publish - - The HVAC emulator will receive the published key/value pair and - print it on screen. - diff --git a/hvac_demo/backend.config b/hvac_demo/backend.config deleted file mode 100644 index d8ca456..0000000 --- a/hvac_demo/backend.config +++ /dev/null @@ -1,112 +0,0 @@ -%% -*- erlang -*- - -%% Copyright (C) 2014, Jaguar Land Rover -%% -%% This program is licensed under the terms and conditions of the -%% Mozilla Public License, version 2.0. The full text of the -%% Mozilla Public License is at https://www.mozilla.org/MPL/2.0/ -%% -%% -%% Configuration file for the backend server. -%% -%% See README.md for details on the demo. -%% -%% See ../CONFIGURE.md for a details on the configuration process -%% itself. -%% -%% See ../rvi_sample.config for a fully documented sample -%% configuration file -%% - - -[ - {apps, - [kernel, - stdlib, - sasl, - {setup, load}, - syntax_tools, - lager, - crypto, - public_key, - exo, - compiler, - ssl, - asn1, - wse, - - rvi, - rvi_common, - service_edge, - service_discovery, - authorize, - schedule, - data_link_bert_rpc, - protocol ]}, - - {env, - [ - {lager, - [ { handlers, - [{lager_console_backend, info}] - } - ] - }, - - {rvi, - [ - { node_address, "127.0.0.1:8807" }, - { node_service_prefix, "jlr.com/backend/"}, - - { static_nodes, - [ - %% We are the backend server. No need. - ] - }, - - { components, - [ - { service_edge, - [ - { gen_server, service_edge_rpc }, - { url, "http://127.0.0.1:8801" }, - { exo_http_opts, [ { port, 8801 } ]} - ] - }, - { service_discovery, - [ - { gen_server, service_discovery_rpc } - ] - }, - { schedule, - [ - { gen_server, schedule } - ] - }, - { authorize, - [ - { gen_server, authorize_rpc } - ] - }, - { protocol, - [ - { gen_server, protocol_rpc } - ] - }, - { data_link, - [ - { gen_server, data_link_bert_rpc_rpc }, - - %% The bert_rpc_server port will be used to listen to incoming - %% traffic from remote nodes. - %% Must match the port given in node_address - { bert_rpc_server, [ {port, 8807 }]} - ] - - } - ] - } - ]} -]} - -]. diff --git a/hvac_demo/hvac_demo.png b/hvac_demo/hvac_demo.png Binary files differdeleted file mode 100644 index e31b864..0000000 --- a/hvac_demo/hvac_demo.png +++ /dev/null diff --git a/hvac_demo/hvac_emulator.py b/hvac_demo/hvac_emulator.py deleted file mode 100755 index e108dc2..0000000 --- a/hvac_demo/hvac_emulator.py +++ /dev/null @@ -1,250 +0,0 @@ -#!/usr/bin/python - -# -# Copyright (C) 2014, Jaguar Land Rover -# -# This program is licensed under the terms and conditions of the -# Mozilla Public License, version 2.0. The full text of the -# Mozilla Public License is at https://www.mozilla.org/MPL/2.0/ -# - -# -# Emulate an HVAC apoplication -# -# This emulator connects to the Service Edge of the vehicle RVI node -# as a service and simulates an HVAC application unit installed in a -# vehicle. -# -# The emulator connects to the Service Edge of its local RVI node, -# started with "rvi_node -n vehicle" and registers two services with it: -# -# /hvac/subscribe - Used by the mobile emulator to subscribe to -# updates entered on the HVAC emulator's command -# line. -# -# /hvac/publish - Used by the mobile emulator to report updated -# values entered on its command line -# -# Mobile emulators invoke the subscribe service above in order -# to receive new HVAC values published by the HVAC emulator. -# -# When a new key/value pair is entered on the HVAC emulator's command line, -# The mobile emulator services registered through an /hvac/subscribe -# message will be invoked with the key, value, and VIN number -# of the HVAC's RVI node. The receiving mobile emulators will -# print out the information. -# -# If a new key/value pair is entered on a mobile emulator's command -# line, they will be sent to the HVAC emulator's /hvac/publish service, -# which will print them on screen. -# -# Invocation Example: -# python hvac_emulator.py http://127.0.0.1:8811 -# -# http://127.0.0.1:8811 is the RVI node's Service Edge URL. -# See vehicle.conf's env -> rvi -> components -> service_edge -> url -# for the correct value. -# -import sys -from rvi_json_rpc_server import RVIJSONRPCServer -import jsonrpclib -import random -import time -import threading - -def usage(): - print "Usage:", sys.argv[0], "<rvi_url>" - print " <rvi_url> URL of Service Edge on a local RVI node" - print - print "The RVI Service Edge URL can be found in" - print "[backend,vehicle].config as" - print "env -> rvi -> components -> service_edge -> url" - print - print "The Service Edge URL is also logged as a notice when the" - print "RVI node is started." - sys.exit(255) - - -# -# Publish command is invoked by the mobile emulator when it sends -# messages to jlr.com/vin/1234/hvac/publish service. -# -def publish(key, value): - print - print "Publish invoked!" - print "key:", key - print "value:", value - print - sys.stdout.write("Enter <key> <val> or q to quit: ") - sys.stdout.flush() - return ['ok'] - -def services_available(services): - print - print "Services available: ", services - - sys.stdout.write("Enter <key> <val> or q to quit: ") - sys.stdout.flush() - return ['ok'] - -def services_unavailable(services): - print - print "Services not available: ", services - - sys.stdout.write("Enter <key> <val> or q to quit: ") - sys.stdout.flush() - return ['ok'] - -# -# Subscribe command is invoked by the mobile emulator when it sends -# messages to the jlr.com/vin/1234/hvac/subscribe service. -# The single argument provided is the subscribing service to be invoked when -# an value is updated on the command line of the HVAC emulator. -# -def subscribe(subscribing_service): - print - print "Got subscription" - print "vin:", vin - print "subscribing_service:", subscribing_service - print - # Add the subscribing service to list of subscribers, - # given that is is not already there. - if not subscribing_service in subscribers: - subscribers.append(subscribing_service) - else: - print subscribing_service," already subscribing" - - sys.stdout.write("Enter <key> <val> or q to quit: ") - sys.stdout.flush() - return ['ok'] - -# -# Publish an updated HVAC value, entered at the command line of the -# HVAC emulator, to all services who have set themselves up as -# subscribers through the jlr.com/vin/1234/hvac/subscribe service. -# -def publish_to_subscribers(vin, key, val): - for subscriber in subscribers: - print "Sending:",vin," key:", key," val:",val," to:", subscriber - rvi_server.message(calling_service = emulator_publish_service_name, - service_name = subscriber, - timeout = int(time.time())+60, - parameters = [{u'vin': vin, u'key': key, u'value': val}]) - -# -# A list of service names that should be notified when a value is -# updated on the HVAC emulator's command line. -# -subscribers = [] - -# -# Setup a localhost URL, using a random port, that we will listen to -# incoming JSON-RPC publish calls on, delivered by our RVI service -# edge (specified by rvi_url). -# -emulator_service_host = 'localhost' -emulator_service_port = random.randint(20001, 59999) -emulator_service_url = 'http://'+emulator_service_host + ':' + str(emulator_service_port) - -# -# Check that we have the correct arguments -# -if len(sys.argv) != 2: - usage() - -# 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 -emulator_publish_service_name = '/hvac/publish' -emulator_subscribe_service_name = '/hvac/subscribe' - -# Setup an outbound JSON-RPC connection to the RVI Service Edeg. -rvi_server = jsonrpclib.Server(rvi_url) - -emulator_service = RVIJSONRPCServer(addr=((emulator_service_host, emulator_service_port)), - logRequests=False) - - -# -# Regsiter callbacks for incoming JSON-RPC calls delivered to -# the HVAC emulator from the vehicle RVI node's Service Edge. -# -emulator_service.register_function(publish, emulator_publish_service_name) -emulator_service.register_function(subscribe, emulator_subscribe_service_name) -emulator_service.register_function(services_available, 'services_available') -emulator_service.register_function(services_unavailable, 'services_unavailable') - - -# Create a thread to handle incoming stuff so that we can do input -# in order to get new values -thr = threading.Thread(target=emulator_service.serve_forever) -thr.start() - -# We may see traffic immediately from the RVI node when -# we register. Let's sleep for a bit to allow the emulator service -# thread to get up to speed. -time.sleep(0.5) - - -# -# Register our HVAC emulator service with the vehicle RVI node's Service Edge. -# We register both services using our own URL as a callback. -# -res = rvi_server.register_service(service = emulator_publish_service_name, - network_address = emulator_service_url) - -# -# Record the returned full service name so that we can print it out -# below. -# -full_emulator_publish_service_name = res['service'] - -res = rvi_server.register_service(service = emulator_subscribe_service_name, - network_address = emulator_service_url) - -# -# Record the returned full service name so that we can print it out -# below. -# -full_emulator_subscribe_service_name = res['service'] - -[ t1, t2, vin, t3, t4] = full_emulator_subscribe_service_name.split('/') - -# We are in mobile device mode. Setup the vin numbers for publish -pub_vin = "hvac_"+vin -sub_vin = "mobile_"+vin - -print "HVAC Emulator." -print "Vehicle RVI node URL: ", rvi_url -print "Emulator URL: ", emulator_service_url -print "VIN: ", vin -print "Full publish service name ", full_emulator_publish_service_name -print "Full subscribe service name ", full_emulator_subscribe_service_name - -while True: - line = raw_input('Enter <key> <val> or "q" for quit: ') - if line == 'q': - emulator_service.shutdown() - sys.exit(0) - - # Read a line and split it into a key val pair - lst = line.split(' ') - if len(lst) != 2: - print "Nope", len(lst), lst - continue - - [k, v] = line.split(' ') - - # Send out update to the subscriber - publish_to_subscribers(vin, k, v) - - print('Key {} set to {} for vin{}'. format(k, v, vin)) diff --git a/hvac_demo/mobile_emulator.py b/hvac_demo/mobile_emulator.py deleted file mode 100755 index 6eebe03..0000000 --- a/hvac_demo/mobile_emulator.py +++ /dev/null @@ -1,249 +0,0 @@ -#!/usr/bin/python - -# -# Copyright (C) 2014, Jaguar Land Rover -# -# This program is licensed under the terms and conditions of the -# Mozilla Public License, version 2.0. The full text of the -# Mozilla Public License is at https://www.mozilla.org/MPL/2.0/ -# - -# -# Emulate a mobile device. -# -# The mobile device emulator connects to Service Edge of the backend -# server, started with "./rvi_node -n backend", and subscribes to -# HVAC updates (temp, fan speed, etc) updates from the vehicle with a -# given VIN. -# -# At startup, the mobile emulator will do two things: -# -# 1. Register a service with the backend RVI node. -# -# This service is invoked by the HVAC emulator to transmit -# key/value pairs entered on its commandd line. -# -# The service name has the following layout: -# jlr.com/backend/mobile/[phone_nr]/hvac/publish -# -# The jlr.com/backend prefix is added by the RVI node to make -# the service globally unique. The [phone_nr] is the command-line -# specified phone number. -# -# 2. Send a suscription request to the HVAC emulator. -# The HVAC emulator's subscription service is invoked as -# jlr.com/vin/[vin]/hvac/subscribe -# -# where [vin] is the command-line specified VIN of the -# vehicle RVI node to connect to. -# The subscription request's only parameter is the full name of -# the publish service registered in step 1. When the HVAC -# emulator has a key/value pair entered at its command line, the -# key/value/vin will be sent to the publish service on the mobile -# emulator. -# -# -# When a new key/value pair is entered on the mobile emulator's -# command line, simulating screen input on the HVAC app, the -# key/value pair will be sent to: -# jlr.com/vin/[vin]/hvac/publish -# -# The HVAC emulator will receive the published key/value pair and -# print it on screen. -# -# Usage: -# -# python mobile_emulator.py <rvi_url> <phone_number> <vin> -# -# Example: mobile_emulator.py http://127.0.0.1:8801 +19491231234 1234 -# -# http://127.0.0.1:8801 is the RVI node's Service Edge URL. -# See backend.conf's env -> rvi -> components -> service_edge -> url -# for the correct value. -# -# +19491231234 is the phone number. -# It can be an arbitrary value, but has to be unique across all -# registered mobile emulators. -# -# 1234 is the VIN number of the vehicle RVI node. -# Please see the last field in the vehicle.config's -# env -> rvi -> node_service_prefix configuration entry for -# the correct value. -# - -import sys -from rvi_json_rpc_server import RVIJSONRPCServer -import jsonrpclib -import random -import threading -import time - -def usage(): - print "Usage:", sys.argv[0], " <rvi_url> <phone_number> <vin>" - print " <rvi_url> URL of RVI Service Edge on local host." - print " <phone_number> Phone number to register emulator as." - print " <vin> The VIN that the mobile device is to control." - print - print "The RVI Service Edge URL can be found in" - print "[backend,vehicle].config as" - print "env -> rvi -> components -> service_edge -> url" - print - print "The Service Edge URL is also logged as a notice when the" - print "RVI node is started." - sys.exit(255) - -# -# Publish command is invoked by the -# subscriber server above when it receives a publish command -# from a VIN that this emulator subscribes to. -# -def publish(vin, key, value): - print - print "Publish invoked!" - print "vin:", vin - print "key:", key - print "value:", value - print - sys.stdout.write("Enter <key> <val> or q to quit: ") - sys.stdout.flush() - return ['ok'] - - - -def services_available(services): - print - print "Services available: ", services - - sys.stdout.write("Enter <key> <val> or q to quit: ") - sys.stdout.flush() - return ['ok'] - -def services_unavailable(services): - print - print "Services not available: ", services - - sys.stdout.write("Enter <key> <val> or q to quit: ") - sys.stdout.flush() - return ['ok'] - - -# -# Check that we have the correct arguments -# -if len(sys.argv) != 4: - usage() - -[ progname, rvi_url, phone_number, vin ] = sys.argv - -# Setup self's server that we will receive incoming calls from service edge on. - -# -# Setup a localhost URL, using a random port, that we will listen to -# incoming JSON-RPC publish calls on, delivered by our RVI service -# edge (specified by rvi_url). -# -emulator_service_host = 'localhost' -emulator_service_port = random.randint(20001, 59999) -emulator_service_url = 'http://'+emulator_service_host + ':' + str(emulator_service_port) - -# -# Setup the target service, the vehicle hvac app emulator, -# that will receive 'publish' and 'subscribe' commands from us. -# -target_hvac_publish_service = 'jlr.com/vin/'+vin+'/hvac/publish' -target_hvac_subscribe_service = 'jlr.com/vin/'+vin+'/hvac/subscribe' - -# -# Setup the service name we will register with. -# The complete service name will be: -# jlr.com/backend/mobile/<phone_nr>/hvac/publish -# -emulator_service_name = '/mobile/'+phone_number+'/hvac/publish' - -# -# Setup an outbound JSON-RPC connection to the backend RVI node -# Service Edge. -# -rvi_server = jsonrpclib.Server(rvi_url) - -emulator_service = RVIJSONRPCServer(addr=((emulator_service_host, emulator_service_port)), - logRequests=False) - -# Register the publish function with the publish service -# so that publish() gets called when we receive a message -# to /mobile/[phone_nr]/hvac/publish -# -emulator_service.register_function(publish, emulator_service_name) - -# Create a thread to handle incoming stuff so that we can do input -# in order to get new values -thr = threading.Thread(target=emulator_service.serve_forever) -thr.start() - - -# We may see traffic immediately from the RVI node when -# we register. Let's sleep for a bit to allow the emulator service -# thread to get up to speed. -time.sleep(0.5) - - -# -# Register our HVAC mobile emulator service with backend RVI node -# Service Edge. -# -print "Emulator service URL", emulator_service_url - -res = rvi_server.register_service(service = emulator_service_name, - network_address = emulator_service_url) - - -# Service Edge will return the full, global service name that the -# registration was recorded as: -# -# jlr.com/backend/mobile/[phone_number]/hvac/publish -# -full_emulator_service_name = res['service'] -emulator_service.register_function(services_available, 'services_available') -emulator_service.register_function(services_unavailable, 'services_unavailable') - -# -# Send of a subscribe to the hvac emulator running on the -# vehicle. -# -# We provide our own full service name to be invoked when -# a value is updated on the command line of the hvac emulator. -# -rvi_server.message(calling_service = emulator_service_name, - service_name = target_hvac_subscribe_service, - timeout = int(time.time()) + 60, # Not yet implemented - parameters = [ { u'subscribing_service': full_emulator_service_name}]) - -print "Mobile Device Emulator." -print "Backend RVI node URL: ", rvi_url -print "Emulator URL: ", emulator_service_url -print "Phone Number: ", phone_number -print "VIN: ", vin -print "Full Service Name: ", full_emulator_service_name - -while True: - line = raw_input('Enter <key> <val> or "q" to quit: ') - if line == 'q': - emulator_service.shutdown() - sys.exit(0) - - # Read a line and split it into a key val pair - lst = line.split(' ') - if len(lst) != 2: - print "Nope", len(lst), lst - continue - - [k, v] = line.split(' ') - - # Send out update to the subscriber - rvi_server.message(calling_service= emulator_service_name, - service_name = target_hvac_publish_service, - timeout = int(time.time()) + 60, - parameters = [{ u'key': k, - u'value': v}]) - - print('Key {} set to {} for vin{}'. format(k, v, vin)) diff --git a/hvac_demo/rvi_json_rpc_server.py b/hvac_demo/rvi_json_rpc_server.py deleted file mode 100644 index c3b45e2..0000000 --- a/hvac_demo/rvi_json_rpc_server.py +++ /dev/null @@ -1,36 +0,0 @@ -# -# Copyright (C) 2014, Jaguar Land Rover -# -# This program is licensed under the terms and conditions of the -# Mozilla Public License, version 2.0. The full text of the -# Mozilla Public License is at https://www.mozilla.org/MPL/2.0/ -# -from jsonrpclib.SimpleJSONRPCServer import SimpleJSONRPCServer -import jsonrpclib - -class RVIJSONRPCServer(SimpleJSONRPCServer): - # Check if method is 'message', if so dispatch on - # name 'service_name' instead. - def _dispatch(self, method, params): - if method == 'message': - # print "Will dispatch message to: " + params['service_name'] - dict_param = {} - # Extract the 'parameters' element from the top level JSON-RPC - # 'param'. - # Convert 'parameters' from [{'vin': 1234}, {hello: 'world'}] to - # a regular dictionary: {'vin': 1234, hello: 'world'} - - # print "Parameters:", params['parameters'] - msg_params = params['parameters'] - for i in range(0, len(msg_params)): - for j in range(0, len(msg_params[i].keys())): - # print "params", msg_params[i].keys()[j], "=", msg_params[i].values()[j] - dict_param[msg_params[i].keys()[j]] = msg_params[i].values()[j] - - # print "Parameter disctionary: ", dict_param - # print - # Ship the processed dispatch info upward. - return SimpleJSONRPCServer._dispatch(self, params['service_name'], dict_param) - - - return SimpleJSONRPCServer._dispatch(self,method, params) diff --git a/hvac_demo/vehicle.config b/hvac_demo/vehicle.config deleted file mode 100644 index 22fa2b7..0000000 --- a/hvac_demo/vehicle.config +++ /dev/null @@ -1,117 +0,0 @@ -%% -*- erlang -*- - -%% Copyright (C) 2014, Jaguar Land Rover -%% -%% This program is licensed under the terms and conditions of the -%% Mozilla Public License, version 2.0. The full text of the -%% Mozilla Public License is at https://www.mozilla.org/MPL/2.0/ -%% -%% Configuration file for the (in-vehicle) IVI used by the hvac_demo -%% -%% See README.md for details on the demo. -%% -%% See README.md for details on the demo. -%% -%% See ../CONFIGURE.md for a details on the configuration process -%% itself. -%% -%% See ../rvi_sample.config for a fully documented sample -%% configuration file -%% -[ - %% All erlang apps needed to fire up a node. Do not touch. - {apps, - [kernel, - stdlib, - sasl, - {setup, load}, - syntax_tools, - lager, - crypto, - public_key, - exo, - compiler, - ssl, - asn1, - wse, - - rvi, - rvi_common, - service_edge, - service_discovery, - authorize, - schedule, - data_link_bert_rpc, - protocol ]}, - - {env, - [ - %% Lager is the main logging mechanism. - %% See https://github.com/basho/lager for details. - %% - {lager, - [ { handlers, - %% Change this to debug, info, notice, warning, or error in - %% order to lower the console chatter. - [ {lager_console_backend, info} ] - } - ] - }, - - %% All RVI configuration is done here. - %% Please note that the rvi_node.sh launch script - %% can still override the port range and static nodes - %% through its command line parameters. - %% - {rvi, - [ - { node_address, "0.0.0.0:0" }, - { node_service_prefix, "jlr.com/vin/1234/"}, - - { static_nodes, - [ - { "jlr.com/backend/", "127.0.0.1:8807" } - ] - }, - - - { components, - [ - { service_edge, - [ - { url, "http://127.0.0.1:8811" }, - { exo_http_opts, [ { port, 8811 } ] }, - { gen_server, service_edge_rpc } - ] - }, - { service_discovery, - [ - { gen_server, service_discovery_rpc } - ] - }, - { schedule, - [ - { gen_server, schedule } - ] - }, - { authorize, - [ - { gen_server, authorize_rpc } - ] - }, - { protocol, - [{ gen_server, protocol_rpc } - ] - }, - { data_link, - [ - { gen_server, data_link_bert_rpc_rpc }, - { bert_rpc_client, [ {port, 8817 }]} - ] - } - ] - } - ]} - ]} - -]. |