Commit a34e719c authored by Vlado Altmann's avatar Vlado Altmann
Browse files

running light bulb service

parent 88abd45e
......@@ -8,8 +8,6 @@
<wsdl:types>
<xs:schema targetNamespace="http://www.ws4d.org/Configuration">
<xs:import namespace="http://schemas.xmlsoap.org/ws/2004/08/addressing"
schemaLocation="addressing.xsd" />
<xs:simpleType name="RoleType">
<xs:restriction base="xs:string">
......
......@@ -35,7 +35,7 @@ public class ConfigurationService extends DefaultService {
public ConfigurationService() {
try {
define(new URI("local:/org/ws4d/airConditioner/Configuration.wsdl"), CredentialInfo.EMPTY_CREDENTIAL_INFO, CommunicationManagerRegistry.getPreferredCommunicationManagerID());
define(new URI("local:/com/pi/lightbulb/configuration/Configuration.wsdl"), CredentialInfo.EMPTY_CREDENTIAL_INFO, CommunicationManagerRegistry.getPreferredCommunicationManagerID());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
......@@ -93,7 +93,7 @@ public class ConfigurationService extends DefaultService {
ParameterValueManagement.setString(result, "Interface[" + i + "]/Role", interfaces.get(i).role.name());
// ParameterValueManagement.setString(result, "Interface[" + i + "]/Role", Boolean.toString(interfaces.get(i).ruleSupport))
ParameterValueManagement.setAttributeValue(result, "Interface[" + i + "]",
new QName("ruleSupport", Constants.NAMESPACE), Boolean.toString(interfaces.get(i).ruleSupport));
new QName("ruleSupport", Constants.NAMESPACE_CONFIGURATION), Boolean.toString(interfaces.get(i).ruleSupport));
// result.setAttributeValue(new QName("ruleSupport1", Constants.NAMESPACE), Boolean.toString(interfaces.get(i).ruleSupport));
}
......
......@@ -2,8 +2,12 @@ package com.pi.lightbulb.configuration;
public class Constants {
public final static String NAMESPACE = "http://www.ws4d.org/Configuration";
public final static String NAMESPACE_CONFIGURATION = "http://www.ws4d.org/Configuration";
public final static String NAMESPACE_DEMO = "http://www.demo.com/bbsr";
public final static String NAMESPACE = "http://www.ws4d.org/Device";
public final static String DEVICE = "LightBulb";
}
......@@ -11,15 +11,17 @@ import org.ws4d.java.service.parameter.ParameterValue;
import org.ws4d.java.service.parameter.ParameterValueManagement;
import org.ws4d.java.types.QName;
import com.pi.lightbulb.configuration.Constants;
public class GetStateOperation extends Operation {
private String state = "off";
public GetStateOperation() {
super("GetCurrentState", new QName(LightBulbService.SERVICE_TYPE, LightBulbDevice.NAMESPACE));
super("GetCurrentState", new QName(LightBulbService.SERVICE_TYPE, Constants.NAMESPACE));
// create element of type TemperatureType
Element stateElement = new Element(new QName("state", LightBulbDevice.NAMESPACE), SchemaUtil.TYPE_STRING);
Element stateElement = new Element(new QName("state", Constants.NAMESPACE), SchemaUtil.TYPE_STRING);
// set the input of the operation
// setInput(null);
......
......@@ -5,14 +5,11 @@ import org.ws4d.java.types.LocalizedString;
import org.ws4d.java.types.QName;
import org.ws4d.java.types.QNameSet;
import com.pi.lightbulb.configuration.Constants;
import com.pi.lightbulb.gpio.DefaultDeviceGPIO;
public class LightBulbDevice extends DefaultDeviceGPIO {
public final static String NAMESPACE = "http://www.ws4d.org/interface";
public final static String DEVICE = "LightBulb";
/**
* Constructor of our device.
*/
......@@ -26,7 +23,7 @@ public class LightBulbDevice extends DefaultDeviceGPIO {
*/
// set PortType
this.setPortTypes(new QNameSet(new QName(DEVICE, NAMESPACE)));
this.setPortTypes(new QNameSet(new QName(Constants.DEVICE, Constants.NAMESPACE)));
// add device name (name is language specific)
this.addFriendlyName("en-US", "Light Bulb");
this.addFriendlyName(LocalizedString.LANGUAGE_DE, "Lampe");
......
......@@ -40,13 +40,6 @@ import com.pi.lightbulb.configuration.Constants;
public class ServiceProviderWSDL {
///Device object that is handled by this service provider
public LightBulbDevice device;
// Let's count events
public static int eventCounter = 0;
/**
* @param args
*/
......@@ -61,27 +54,24 @@ public class ServiceProviderWSDL {
properties.addSupportedDPWSVersion(DPWSProtocolVersion.DPWS_VERSION_2006);
// properties.removeSupportedDPWSVersion(DPWSProtocolVersion.DPWS_VERSION_2009);
DispatchingProperties.getInstance().setResponseWaitTime(10000);
//create an instance of the ServiceProvider class
final ServiceProviderWSDL serviceProvider = new ServiceProviderWSDL();
// mandatory: Starting the DPWS Framework.
CoreFramework.start(args);
// First we need a device.
// First we need a device.
LightBulbDevice device = new LightBulbDevice();
// Then we create a service.
final ConfigurationService configurationService = new ConfigurationService();
//final Service aircondService = new Service();
final DefaultService aircondService = new DefaultService(CommunicationManagerRegistry.getPreferredCommunicationManagerID());
aircondService.setServiceId(new URI(Constants.NAMESPACE + "/AirConditionerService"));
final DefaultService mainService = new DefaultService(CommunicationManagerRegistry.getPreferredCommunicationManagerID());
mainService.setServiceId(new URI(Constants.NAMESPACE + "/LightBulb"));
try {
// configurationService.define(new URI("local:/org/ws4d/airConditioner/Configuration.wsdl"), CredentialInfo.EMPTY_CREDENTIAL_INFO, CommunicationManagerRegistry.getPreferredCommunicationManagerID());
// configurationService.setServiceId(new URI("Configuration"));
aircondService.define(new URI("local:/org/ws4d/airConditioner/AirConFull.wsdl"), CredentialInfo.EMPTY_CREDENTIAL_INFO, CommunicationManagerRegistry.getPreferredCommunicationManagerID());
aircondService.setServiceId(new URI("AirConditioner"));
mainService.define(new URI("local:/com/pi/lightbulb/device/Switch.wsdl"), CredentialInfo.EMPTY_CREDENTIAL_INFO, CommunicationManagerRegistry.getPreferredCommunicationManagerID());
mainService.setServiceId(new URI("LightBulb"));
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
......@@ -129,12 +119,12 @@ public class ServiceProviderWSDL {
configurationService.setParameter(description);
// In the end we add our service to the device.
serviceProvider.device.addService(configurationService);
serviceProvider.device.addService(aircondService);
device.addService(configurationService);
device.addService(mainService);
// Do not forget to start the device!
try {
serviceProvider.device.start();
device.start();
} catch (IOException e) {
e.printStackTrace();
}
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.ws4d.org/interface" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Switch" targetNamespace="http://www.ws4d.org/interface">
<wsdl:types>
<xsd:schema targetNamespace="http://www.ws4d.org/interface">
<xsd:element name="NewOperation">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="in" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="NewOperationResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="out" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="NewOperationRequest">
<wsdl:part element="tns:NewOperation" name="parameters"/>
</wsdl:message>
<wsdl:message name="NewOperationResponse">
<wsdl:part element="tns:NewOperationResponse" name="parameters"/>
</wsdl:message>
<wsdl:portType name="Switch">
<wsdl:operation name="NewOperation">
<wsdl:input message="tns:NewOperationRequest"/>
<wsdl:output message="tns:NewOperationResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="SwitchSOAP" type="tns:Switch">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="NewOperation">
<soap:operation soapAction="http://www.ws4d.org/interface/NewOperation"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="Switch">
<wsdl:port binding="tns:SwitchSOAP" name="SwitchSOAP">
<soap:address location="http://www.example.org/"/>
</wsdl:port>
</wsdl:service>
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:tns="http://www.ws4d.org/interface" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" name="Switch"
targetNamespace="http://www.ws4d.org/interface">
<wsdl:types>
<xs:schema targetNamespace="http://www.ws4d.org/interface">
<xs:element name="State" type="xs:boolean" />
</xs:schema>
</wsdl:types>
<wsdl:message name="GetStateRequest" />
<wsdl:message name="GetStateResponse">
<wsdl:part element="tns:State" name="parameters" />
</wsdl:message>
<wsdl:message name="SetStateRequest">
<wsdl:part element="tns:State" name="parameters" />
</wsdl:message>
<wsdl:message name="ToggleRequest" />
<wsdl:portType name="Switch">
<wsdl:operation name="GetState">
<wsdl:input message="tns:GetStateRequest" wsam:Action="http://www.ws4d.org/interface/Switch/GetState"/>
<wsdl:output message="tns:GetStateResponse" wsam:Action="http://www.ws4d.org/interface/Switch/GetStateResponse"/>
</wsdl:operation>
<wsdl:operation name="SetState">
<wsdl:input message="tns:SetStateRequest" wsam:Action="http://www.ws4d.org/interface/Switch/SetState"/>
</wsdl:operation>
<wsdl:operation name="Toggle">
<wsdl:input message="tns:ToggleRequest" wsam:Action="http://www.ws4d.org/interface/Switch/Toggle"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="SwitchInterface" type="tns:Switch">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="GetState">
<soap:operation soapAction="http://www.ws4d.org/interface/Switch/GetState" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="SetState">
<soap:operation soapAction="http://www.ws4d.org/interface/Switch/SetState" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
</wsdl:operation>
<wsdl:operation name="Toggle">
<soap:operation soapAction="http://www.ws4d.org/interface/Switch/Toggle" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="Switch">
<wsdl:port binding="tns:SwitchInterface" name="SwitchInterface">
<soap:address location="http://www.ws4d.org/interface" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
......@@ -11,21 +11,23 @@ import org.ws4d.java.service.parameter.ParameterValue;
import org.ws4d.java.service.parameter.ParameterValueManagement;
import org.ws4d.java.types.QName;
import com.pi.lightbulb.configuration.Constants;
public class SwitchOperation extends Operation {
private GetStateOperation getOperation;
public SwitchOperation() {
super("Switch", new QName(LightBulbService.SERVICE_TYPE, LightBulbDevice.NAMESPACE));
super("Switch", new QName(LightBulbService.SERVICE_TYPE, Constants.NAMESPACE));
// create element of type TemperatureType
Element switchElement = new Element(new QName("switch", LightBulbDevice.NAMESPACE), SchemaUtil.TYPE_STRING);
Element switchElement = new Element(new QName("switch", Constants.NAMESPACE), SchemaUtil.TYPE_STRING);
// set the input of the operation
setInput(switchElement);
// create reply element
Element reply = new Element(new QName("status", LightBulbDevice.NAMESPACE), SchemaUtil.TYPE_STRING);
Element reply = new Element(new QName("status", Constants.NAMESPACE), SchemaUtil.TYPE_STRING);
// set this element as output
setOutput(reply);
......
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