Commit 16737d50 authored by aw613's avatar aw613

initial commit

parents
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry combineaccessrules="false" kind="src" path="/jmeds2.0-beta10"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>SmartSensor</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>com.sysdeo.eclipse.tomcat.tomcatnature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
/**********************************************************************************
* Copyright (c) 2007 MATERNA Information & Communications and
* TU Dortmund, Dpt. of Computer Science, Chair 4, Distributed Systems
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
**********************************************************************************/
package org.ws4d.smartsensor.device;
import java.io.IOException;
import org.ws4d.java.communication.CommunicationException;
import org.ws4d.java.schema.Element;
import org.ws4d.java.schema.SchemaUtil;
import org.ws4d.java.security.CredentialInfo;
import org.ws4d.java.service.InvocationException;
import org.ws4d.java.service.Operation;
import org.ws4d.java.service.parameter.ParameterValue;
import org.ws4d.java.service.parameter.ParameterValueManagement;
/**
* The Temperature Action returns the current Temperature.
*
*
*/
public class GetLightAction extends Operation
{
public static final String ACT_HW_NAME = "LightAction";
//public static final String PARAM_HW_OUTPUT = "temperature";
public static final String PARAM_HW_OUTPUT = "light";
public GetLightAction () {
super(ACT_HW_NAME, HelloWorldService.QN_PORTTYPE);
Element lightOutput = new Element(PARAM_HW_OUTPUT, HelloWorldDevice.NAMESPACE, SchemaUtil.TYPE_INT);
setOutput(lightOutput);
}
@Override
protected ParameterValue invokeImpl(ParameterValue parameterValue,
CredentialInfo credentialInfo) throws InvocationException,
CommunicationException {
ParameterValue luminescenceOutput = createOutputValue();
ParameterValueManagement.setString(luminescenceOutput, PARAM_HW_OUTPUT, "80");
return luminescenceOutput;
}
}
package org.ws4d.smartsensor.device;
/**********************************************************************************
* Copyright (c) 2007 MATERNA Information & Communications and
* TU Dortmund, Dpt. of Computer Science, Chair 4, Distributed Systems
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
**********************************************************************************/
import java.io.IOException;
import org.ws4d.java.communication.CommunicationException;
import org.ws4d.java.schema.Element;
import org.ws4d.java.schema.SchemaUtil;
import org.ws4d.java.security.CredentialInfo;
import org.ws4d.java.service.InvocationException;
import org.ws4d.java.service.Operation;
import org.ws4d.java.service.parameter.ParameterValue;
import org.ws4d.java.service.parameter.ParameterValueManagement;
/**
* The Temperature Action returns the current Temperature.
*
*
*/
public class GetTemperatureAction extends Operation
{
// private ITemperatureInput tempSensor = (ITemperatureInput) Resources.lookup(ITemperatureInput.class);
//private ILightSensor lightSensor = (ILightSensor) Resources.lookup(ILightSensor.class);
public static final String ACT_HW_NAME = "TemperatureAction";
public static final String PARAM_HW_OUTPUT = "temperature";
//public static final String PARAM_HW_OUTPUT2 = "light";
public GetTemperatureAction () {
super(ACT_HW_NAME, HelloWorldService.QN_PORTTYPE);
Element temperatureOutput = new Element(PARAM_HW_OUTPUT, HelloWorldDevice.NAMESPACE, SchemaUtil.TYPE_INT);
//Parameter lightOutput = new Parameter(PARAM_HW_OUTPUT2, HelloWorldDevice.NAMESPACE, ParameterType.PARAMETER_TYPE_INT);
setOutput(temperatureOutput);
// addOutputParameterDefinition(temperatureOutput);
//addOutputParameterDefinition(lightOutput);
}
@Override
protected ParameterValue invokeImpl(ParameterValue parameterValue,
CredentialInfo credentialInfo) throws InvocationException,
CommunicationException {
ParameterValue temperatureOutput = createOutputValue();
ParameterValueManagement.setString(temperatureOutput, PARAM_HW_OUTPUT, "20");
return temperatureOutput;
}
// protected ParameterValue invokeImpl() {
// try {
// ParameterValue temperatureOutput = createOutputValue(); //getOutputParameter(PARAM_HW_OUTPUT);
// //Parameter lightOutput = getOutputParameter(PARAM_HW_OUTPUT2);
//
// ParameterValueManagement.setString(temperatureOutput, PARAM_HW_OUTPUT, "20");
// // The DPWS stack handles all simple type parameters as strings. The developer is
// // responsible to check any constraints and to perform any necessary type conversions.
//
// // business logic
//// double temperature = tempSensor.getCelsius();
//// temperatureOutput.setValue(""+temperature);
//
// return temperatureOutput;
// //double light = lightSensor.getAverageValue();
// //lightOutput.setValue(""+light);
// }
// catch (IOException ex) {}
//}
}
package org.ws4d.smartsensor.device;
import org.ws4d.java.communication.DPWSCommunicationManager;
import org.ws4d.java.service.DefaultDevice;
import org.ws4d.java.types.LocalizedString;
import org.ws4d.java.types.QName;
import org.ws4d.java.types.QNameSet;
/**
* HelloWorldDevice describes the SPOT as a DPWS hosting device.
*
* modified by Christin Groba
*
*/
public class HelloWorldDevice extends DefaultDevice{
public static final String NAMESPACE = "http://www.demo.com/bbsr";
public static final String PORTTYPE = "Sensor";
public static final String LOCALE_EN = "en_GB";
public HelloWorldDevice() {
super(DPWSCommunicationManager.COMMUNICATION_MANAGER_ID);
// set PortType
this.setPortTypes(new QNameSet ( new QName (PORTTYPE, NAMESPACE )));
// add device name ( name is language specific )
this.addFriendlyName ("en -US", "Sun SPOT - Sensor Device");
this.addFriendlyName ( LocalizedString.LANGUAGE_DE , "Sun SPOT - Sensor Device");
// add device manufacturer ( manufacturer is language specific )
this.addManufacturer ( LocalizedString.LANGUAGE_EN , "Test Inc.");
this.addManufacturer ("de -DE", " Test GmbH ");
this.addModelName ( LocalizedString.LANGUAGE_EN , "Sun Spot");
}
}
package org.ws4d.smartsensor.device;
import org.ws4d.java.communication.DPWSCommunicationManager;
import org.ws4d.java.service.DefaultDevice;
import org.ws4d.java.service.DefaultService;
import org.ws4d.java.types.QName;
import org.ws4d.java.types.URI;
/**
* HelloWorldService describes the service that is hosted by the SPOT.
* In particular the service has one method HelloWorldAction.
*
*/
public class HelloWorldService extends DefaultService {
// global settings
public static final String NAMESPACE = HelloWorldDevice.NAMESPACE;
public static final String PORTTYPE = "SensorInterface";
public static final String ENDPOINT_PATH = "/SunSPOTSensor";
public static final QName QN_PORTTYPE = new QName(PORTTYPE, NAMESPACE);
public final static URI DOCU_EXAMPLE_SERVICE_ID = new URI(NAMESPACE + ENDPOINT_PATH);
public HelloWorldService() {
super(DPWSCommunicationManager.COMMUNICATION_MANAGER_ID);
// Set the property
// Properties.getInstance().setServiceProperty(this, Properties.PROP_SERVICE_SECURED, false);
this.setServiceId(DOCU_EXAMPLE_SERVICE_ID);
// if endpoint not set, port type is use
// setEndpointPath(ENDPOINT_PATH);
// -- hello world action --
//HelloWorldAction helloWorldAct = new HelloWorldAction ();
//addAction(helloWorldAct);
// -- getTemperatureAction --
GetTemperatureAction getTemperatureAct = new GetTemperatureAction();
addOperation(getTemperatureAct);
// -- getValuesAction --
GetLightAction getLightAct = new GetLightAction();
addOperation(getLightAct);
// -- getValuesAction --
//GetValuesAction getValuesAct = new GetValuesAction();
//addAction(getValuesAct);
}
}
package org.ws4d.smartsensor.device;
import java.io.IOException;
import org.ws4d.java.CoreFramework;
import org.ws4d.java.configuration.FrameworkProperties;
import org.ws4d.java.configuration.Properties;
public class mainclass {
public static void main(String[] args) {
CoreFramework.start(args);
HelloWorldDevice device = new HelloWorldDevice();
// create service
HelloWorldService service = new HelloWorldService();
// set device properties
// Properties.getInstance().setDeviceProperty(device, Properties.PROP_DEVICE_UUID, "urn:uuid:df0794e0-40d5-11dc-9999-40f84sunspot" );
// add service to device
device.addService(service);
// start device
try {
device.start();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment