Difference between revisions of "Installing C++ Agent on Ubuntu"

From MTConnect® User's Portal
Jump to: navigation, search
m
(Configure the Agent)
Line 93: Line 93:
 
   agent debug /etc/mtconnect/agent/agent.cfg
 
   agent debug /etc/mtconnect/agent/agent.cfg
  
If that works, on to the next step.
+
If it works, you should see:
 +
 
 +
  MTConnect Agent Version 1.3.0.4 - built on Thu Sep  4 00:22:34 2014
 +
      0 INFO  [0] init.config: Starting agent on port 5000
 +
      5 INFO  [0] init.config: Adding adapter for VMC-3Axis on 127.0.0.1:7878
 +
      6 DEBUG [0] agent: registerFile: Path /etc/mtconnect/agent/styles/favicon.ico is not a directory: Unable to find directory /etc/mtconnect/agent/styles/favicon.ico, trying as a file
 +
      6 DEBUG [1] input.connector: Connecting to data source: 127.0.0.1 on port: 7878
 +
      6 WARN  [1] input.connector: connect: Socket exception: unable to connect to '127.0.0.1:7878'
 +
      6 INFO  [1] input.adapter: Will try to reconnect in 1000 milliseconds
 +
  1006 DEBUG [1] input.connector: Connecting to data source: 127.0.0.1 on port: 7878
 +
  1007 WARN  [1] input.connector: connect: Socket exception: unable to connect to '127.0.0.1:7878'
 +
  1007 INFO  [1] input.adapter: Will try to reconnect in 1000 milliseconds
  
 
== Setup the upstart scripts ==
 
== Setup the upstart scripts ==

Revision as of 13:35, 4 September 2014

Contents

Overview

Installation procedure for running MTConnect Agent on ubuntu 14.04 LTS. This is a general guide and covers the basic configuration of the MTConnect simulator.

Install Required Dependencies

The C++ agent depends on libxml2 and for testing libcppunit. The rest are the standard packages for building software. We also use cmake to generate the make files.

 sudo apt-get update
 sudo apt-get install libxml2 libxml2-dev cmake git libcppunit-dev build-essential screen ruby curl

Download and build the agent

Make a directory for the agent work and our build directory

 mkdir -p ~/agent/build
 cd ~/agent
 

Use git to clone the agent from the repo and create the makefiles. We're going to be building the Release version; a debug version can also be built, refer to the cmake docs for more info.

 git clone https://github.com/mtconnect/cppagent.git
 cd build
 cmake -D CMAKE_BUILD_TYPE=Release ../cppagent/

Now build the app and install it in /usr/local/bin

 make
 sudo cp agent/agent /usr/local/bin

There may be a few build warnings, these can be ignored.

Setup a configuration directory

Setup the agent

 sudo mkdir -p /etc/mtconnect/agent /etc/mtconnect/adapter
 cd ~/agent/cppagent
 sudo cp -r styles schemas simulator/VMC-3Axis.xml /etc/mtconnect/agent

Setup the simulator

 sudo cp simulator/VMC-3Axis-Log.txt simulator/run_scenario.rb /etc/mtconnect/adapter

Configure the Agent

Install the following file for the configuration:

  1. sudo sh -c 'cat <<EOT > /etc/mtconnect/agent/agent.cfg
  2. Devices = /etc/mtconnect/agent/VMC-3Axis.xml
  3. AllowPut = true
  4. ReconnectInterval = 1000
  5. BufferSize = 17
  6. SchemaVersion = 1.3
  7.  
  8. Adapters { 
  9.    VMC-3Axis { 
  10.       Host = 127.0.0.1
  11.       Port = 7878
  12.    } 
  13. }
  14.  
  15. Files {
  16.     schemas {
  17.         Path = /etc/mtconnect/agent/schemas
  18.         Location = /schemas/
  19.     }
  20.     styles {
  21.         Path = /etc/mtconnect/agent/styles
  22.         Location = /styles/
  23.     }
  24.     Favicon {
  25.         Path = /etc/mtconnect/agent/styles/favicon.ico
  26.         Location = /favicon.ico
  27.     }
  28. }
  29.  
  30. StreamsStyle {
  31.   Location = /styles/Streams.xsl
  32. }
  33.  
  34. # Logger Configuration
  35. logger_config
  36. {
  37.     logging_level = debug
  38.     output = file /var/log/mtc_agent.log
  39. }
  40. EOT'

Copy the above text and install it in /etc/mtconnect/agent/agent.cfg. You can test the agent by typing:

 agent debug /etc/mtconnect/agent/agent.cfg

If it works, you should see:

 MTConnect Agent Version 1.3.0.4 - built on Thu Sep  4 00:22:34 2014
     0 INFO  [0] init.config: Starting agent on port 5000
     5 INFO  [0] init.config: Adding adapter for VMC-3Axis on 127.0.0.1:7878
     6 DEBUG [0] agent: registerFile: Path /etc/mtconnect/agent/styles/favicon.ico is not a directory: Unable to find directory /etc/mtconnect/agent/styles/favicon.ico, trying as a file
     6 DEBUG [1] input.connector: Connecting to data source: 127.0.0.1 on port: 7878
     6 WARN  [1] input.connector: connect: Socket exception: unable to connect to '127.0.0.1:7878'
     6 INFO  [1] input.adapter: Will try to reconnect in 1000 milliseconds
  1006 DEBUG [1] input.connector: Connecting to data source: 127.0.0.1 on port: 7878
  1007 WARN  [1] input.connector: connect: Socket exception: unable to connect to '127.0.0.1:7878'
  1007 INFO  [1] input.adapter: Will try to reconnect in 1000 milliseconds

Setup the upstart scripts

The upstart script to start the agent:

 description "MTConnect Agent"
 
 start on runlevel[2345]
 stop on runlevel[016]
 
 agent_dir=/etc/mtconnect/agent/
 
 exec /usr/local/bin/agent run $agent_dir/agent.cfg
 
 respawn
 respawn limit 10 600

Copy the contents to /etc/init/mtc_agent.conf

The upstart script for the adapter:

 description "MTConnect Adapter Simulator"
 
 start on runlevel[2345]
 stop on runlevel[016]
 
 adapter_dir=/etc/mtconnect/adapter/
 
 exec ruby $adapter_dir/run_scenario.rb -l $adapter_dir/adapter/VMC-3Axis-Log.txt
 
 respawn
 respawn limit 10 600

Copy the contents to /etc/init/mtc_adapter.conf

== start the services

Start both services

 sudo start mtc_agent
 sudo start mtc_adapter

Test the services

 curl http://localhost:5000/current