mains.RaspiSensorModule_0.java Source code

Java tutorial

Introduction

Here is the source code for mains.RaspiSensorModule_0.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package mains;

import com.rabbitmq.client.*;
import controllerStuff.ControllerPublisher;
import controllerStuff.LCD_Controller;
import controllerStuff.LED_Controller;
import raspisensormodule.BusRMIConnector;
import raspisensormodule.NodeSensorHandler;

//
/**
 *
 * @author thor
 */
public class RaspiSensorModule_0 {

    //++++++++++++ Hosts ++++++++++++++++++
    // static String host = "localhost";
    static String host = "192.168.43.169";
    // static String host = "192.168.1.34";

    //    static String host = "192.168.1.40";
    //   static String host = "192.168.43.74";
    //    static String host = "192.168.1.37";
    //   static String thisIp = "192.168.43.9";
    static String thisIp = "192.168.43.74";
    //  static String thisIp = "192.168.1.34";
    //    static String thisIp = "192.168.1.35";

    //   static String thisIp = "192.168.43.169";
    //-------------------------------------
    public static final String SENSOR_EXCHANGE = "sensorExchange";
    public static final String SENSOR_ROUT_KEY_BASE = "sensor.";
    public static final String NODE_ID = "node_frontTruckSection";

    public static void main(String[] argv) throws Exception {

        //________ Basic subscribe direct (Routing) __________
        ConnectionFactory factory = new ConnectionFactory();
        factory.setHost(host);
        factory.setUsername("piadmin");
        factory.setPassword("3828");
        Connection connection = factory.newConnection();
        System.setProperty("java.rmi.server.hostname", thisIp);

        ControllerPublisher conPub = new ControllerPublisher(connection, NODE_ID);
        LED_Controller ledCon = new LED_Controller("ledControllerRealTest");
        LCD_Controller lcdCon = new LCD_Controller("lcdController_messeges");

        //   NodeController ledCon1 = new NodeController("ledControllerFloor");
        //   NodeController ledCon2 = new NodeController("ledControllerCabin");

        conPub.publishController(ledCon);
        conPub.publishController(lcdCon);

        //     conPub.publishController(ledCon1);
        //   conPub.publishController(ledCon2);

        NodeSensorHandler nodeSensors = new NodeSensorHandler(connection, SENSOR_EXCHANGE,
                SENSOR_ROUT_KEY_BASE + NODE_ID);
        System.out.println("Sensors up");
        //        BusRMIConnector rmiConnection = new BusRMIConnector(connection, SENSOR_EXCHANGE, SENSOR_ROUT_KEY_BASE + NODE_ID);
        //        System.out.println("RMI up");

        System.in.read();

        connection.close();
    }
}