// Path: AutoSIM-Environments/src/com/automatski/autosim/environments/IConnection.java
// public interface IConnection {
// 
// 	public void setConfig(Object object);
// 	
// 	
// 	public void connect() throws Exception;
// 	public void disconnect() throws Exception;
// 	
// 	public void setListener(IConnectionListener listener);
// 	public Object send(Object object) throws Exception;
// 	
// }
// 
// Path: AutoSIM-Environments/src/com/automatski/autosim/environments/IConnectionListener.java
// public interface IConnectionListener {
// 
// 	public void receive(Object object) throws Exception;
// }
// 
// Path: AutoSIM-Environments/src/com/automatski/autosim/environments/IDevice.java
// public interface IDevice {
// 
// 	public void setConfig(Object object);
// 	public void setEnvironments(IEnvironments environments);
// 	
// 	public void setup() throws Exception;
// 	public void start() throws Exception;
// 	public void stop() throws Exception;
// 	public void teardown() throws Exception;
// 	
// 	public void step() throws Exception;
// 	
// }
// 
// Path: AutoSIM-Environments/src/com/automatski/autosim/environments/IEnvironments.java
// public interface IEnvironments {
// 
// 	public void setup(String environment) throws Exception;
// 	public void start(String environment) throws Exception;
// 	public void stop(String environment) throws Exception;
// 	public void teardown(String environment) throws Exception;
// 	
// 	
// 	public void registerConnectionFactory(String name, IConnectionFactory factory); 
// 	public void deregisterConnectionFactory(String name);
// 	public IConnection getConnection(String name) throws Exception;
// 	
// 	public void registerDeviceFactory(String name, IDeviceFactory factory); 
// 	public void deregisterDeviceFactory(String name);
// 	public IDevice getDevice(String name) throws Exception;
// 	
// 	
// 	
// }
// 
// Path: AutoSIM-SampleDevices/src/com/automatski/autosim/sampledevices/config/AutoSIMDeviceConfig.java
// public class AutoSIMDeviceConfig {
// 
// 	public String name;
// 
// 	public String deviceClassName;
// 	public String connectionName;
// }


import java.util.Random;
import com.automatski.autosim.environments.IConnection;
import com.automatski.autosim.environments.IConnectionListener;
import com.automatski.autosim.environments.IDevice;
import com.automatski.autosim.environments.IEnvironments;
import com.automatski.autosim.sampledevices.config.AutoSIMDeviceConfig;
/*
 *  AutoSIM - Internet of Things Simulator
 *  Copyright (C) 2014, Aditya Yadav <aditya@automatski.com>
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.automatski.autosim.sampledevices;



public class MyAMQPDevice implements IDevice, IConnectionListener {

	private AutoSIMDeviceConfig config = null;
	private IEnvironments environments = null;
	private IConnection connection  = null;
	
	@Override
	public void setConfig(Object arg0) {
		config = (AutoSIMDeviceConfig) arg0;
		
	}

	@Override
	public void setEnvironments(IEnvironments arg0) {
		this.environments = arg0;
	}

	@Override
	public void setup() throws Exception {
		// get a connection
		connection = environments.getConnection(config.connectionName);
		connection.setListener(this);
	}


	@Override
	public void start() throws Exception {
		connection.connect();
		
	}

	@Override
	public void step() throws Exception {
		Random rnd = new Random();
		String message = "Hello World";
		connection.send(message);
	}

// Path: AutoSIM-Environments/src/com/automatski/autosim/environments/IConnection.java
// public interface IConnection {
// 
// 	public void setConfig(Object object);
// 	
// 	
// 	public void connect() throws Exception;
// 	public void disconnect() throws Exception;
// 	
// 	public void setListener(IConnectionListener listener);
// 	public Object send(Object object) throws Exception;
// 	
// }
// 
// Path: AutoSIM-Environments/src/com/automatski/autosim/environments/IConnectionListener.java
// public interface IConnectionListener {
// 
// 	public void receive(Object object) throws Exception;
// }
// 
// Path: AutoSIM-Environments/src/com/automatski/autosim/environments/IDevice.java
// public interface IDevice {
// 
// 	public void setConfig(Object object);
// 	public void setEnvironments(IEnvironments environments);
// 	
// 	public void setup() throws Exception;
// 	public void start() throws Exception;
// 	public void stop() throws Exception;
// 	public void teardown() throws Exception;
// 	
// 	public void step() throws Exception;
// 	
// }
// 
// Path: AutoSIM-Environments/src/com/automatski/autosim/environments/IEnvironments.java
// public interface IEnvironments {
// 
// 	public void setup(String environment) throws Exception;
// 	public void start(String environment) throws Exception;
// 	public void stop(String environment) throws Exception;
// 	public void teardown(String environment) throws Exception;
// 	
// 	
// 	public void registerConnectionFactory(String name, IConnectionFactory factory); 
// 	public void deregisterConnectionFactory(String name);
// 	public IConnection getConnection(String name) throws Exception;
// 	
// 	public void registerDeviceFactory(String name, IDeviceFactory factory); 
// 	public void deregisterDeviceFactory(String name);
// 	public IDevice getDevice(String name) throws Exception;
// 	
// 	
// 	
// }
// 
// Path: AutoSIM-SampleDevices/src/com/automatski/autosim/sampledevices/config/AutoSIMDeviceConfig.java
// public class AutoSIMDeviceConfig {
// 
// 	public String name;
// 
// 	public String deviceClassName;
// 	public String connectionName;
// }


// Path: AutoSIM-SampleDevices/src/com/automatski/autosim/sampledevices/MyAMQPDevice.java
import java.util.Random;
import com.automatski.autosim.environments.IConnection;
import com.automatski.autosim.environments.IConnectionListener;
import com.automatski.autosim.environments.IDevice;
import com.automatski.autosim.environments.IEnvironments;
import com.automatski.autosim.sampledevices.config.AutoSIMDeviceConfig;

/*
 *  AutoSIM - Internet of Things Simulator
 *  Copyright (C) 2014, Aditya Yadav <aditya@automatski.com>
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.automatski.autosim.sampledevices;



public class MyAMQPDevice implements IDevice, IConnectionListener {

	private AutoSIMDeviceConfig config = null;
	private IEnvironments environments = null;
	private IConnection connection  = null;
	
	@Override
	public void setConfig(Object arg0) {
		config = (AutoSIMDeviceConfig) arg0;
		
	}

	@Override
	public void setEnvironments(IEnvironments arg0) {
		this.environments = arg0;
	}

	@Override
	public void setup() throws Exception {
		// get a connection
		connection = environments.getConnection(config.connectionName);
		connection.setListener(this);
	}


	@Override
	public void start() throws Exception {
		connection.connect();
		
	}

	@Override
	public void step() throws Exception {
		Random rnd = new Random();
		String message = "Hello World";
		connection.send(message);
	}

	@Override