Skip to content

Commit

Permalink
Merge pull request #2 from bruno-vignola/master
Browse files Browse the repository at this point in the history
Management of the noserver configuration
  • Loading branch information
consoftenergyathome committed Dec 15, 2014
2 parents 50155be + 6796e0a commit 723f4ae
Show file tree
Hide file tree
Showing 36 changed files with 586 additions and 154 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
*.orig*
*.classpath*
*.project
*.settings/*
*/.settings/*
*/target/*
**/m2m/*
**/.m2m*
*.gitignore*
*.bat*
2 changes: 1 addition & 1 deletion jemma.launch/javagal Windows.launch
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<stringAttribute key="pde.version" value="3.3"/>
<setAttribute key="selected_features"/>
<booleanAttribute key="show_selected_only" value="false"/>
<stringAttribute key="target_bundles" value="com.google.gson@default:default,com.sun.enterprise.stax-osgi@default:default,com.sun.xml.bind@default:default,edu.emory.mathcs.backport.java.util.concurrent@default:default,javax.servlet@default:default,javax.xml@default:default,jssc@default:default,log4j@1:default,org.apache.commons.codec@default:default,org.apache.commons.fileupload@default:default,org.apache.commons.httpclient@default:default,org.apache.commons.io@default:default,org.apache.commons.lang3@default:default,org.apache.felix.bundlerepository@default:default,org.apache.felix.webconsole.plugins.event@default:default,org.apache.felix.webconsole.plugins.memoryusage@default:default,org.apache.felix.webconsole.plugins.upnp@default:default,org.apache.felix.webconsole@default:default,org.apache.httpcomponents.httpclient@default:default,org.apache.httpcomponents.httpcore@default:default,org.apache.xerces@default:default,org.apache.xml.resolver@default:default,org.apache.xml.serializer@default:default,org.eclipse.core.jobs@default:default,org.eclipse.equinox.cm@default:default,org.eclipse.equinox.common@1:true,org.eclipse.equinox.device@default:default,org.eclipse.equinox.ds@1:true,org.eclipse.equinox.event@default:default,org.eclipse.equinox.http.jetty@default:default,org.eclipse.equinox.http.registry@default:default,org.eclipse.equinox.http.servlet@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.equinox.servletbridge@default:default,org.eclipse.equinox.useradmin@default:default,org.eclipse.equinox.util@default:default,org.eclipse.osgi.services@default:default,org.eclipse.osgi.util@default:default,org.eclipse.osgi@-1:true,org.json.simple@default:default,org.json@default:default,org.mortbay.jetty.server@default:default,org.mortbay.jetty.util@default:default,org.ops4j.pax.configmanager@1:default,org.ops4j.pax.logging.pax-logging-api@1:default,org.ops4j.pax.logging.pax-logging-service@1:default,org.ow2.chameleon.commons.jabsorb@default:default,org.restlet.ext.xml@default:default,org.restlet@default:default,osgi.core@default:default,slf4j.api@1:default,slf4j.log4j12@default:false,target@default:default"/>
<stringAttribute key="target_bundles" value="com.google.gson@default:default,com.sun.enterprise.stax-osgi@default:default,com.sun.xml.bind@default:default,edu.emory.mathcs.backport.java.util.concurrent@default:default,javax.servlet*2.5.0.v200806031605@default:default,javax.servlet*3.0.0.v201112011016@default:default,javax.xml@default:default,jssc@default:default,log4j@1:default,org.apache.commons.codec@default:default,org.apache.commons.fileupload@default:default,org.apache.commons.httpclient@default:default,org.apache.commons.io@default:default,org.apache.commons.lang3@default:default,org.apache.felix.bundlerepository@default:default,org.apache.felix.webconsole.plugins.event@default:default,org.apache.felix.webconsole.plugins.memoryusage@default:default,org.apache.felix.webconsole.plugins.upnp@default:default,org.apache.felix.webconsole@default:default,org.apache.httpcomponents.httpclient@default:default,org.apache.httpcomponents.httpcore@default:default,org.apache.xerces@default:default,org.apache.xml.resolver@default:default,org.apache.xml.serializer@default:default,org.eclipse.core.jobs@default:default,org.eclipse.equinox.cm@default:default,org.eclipse.equinox.common@1:true,org.eclipse.equinox.device@default:default,org.eclipse.equinox.ds@1:true,org.eclipse.equinox.event@default:default,org.eclipse.equinox.http.jetty@default:default,org.eclipse.equinox.http.servlet@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.equinox.useradmin@default:default,org.eclipse.equinox.util@default:default,org.eclipse.osgi.services@default:default,org.eclipse.osgi.util@default:default,org.eclipse.osgi@-1:true,org.json.simple@default:default,org.json@default:default,org.ops4j.pax.configmanager@1:default,org.ops4j.pax.logging.pax-logging-api@1:default,org.ops4j.pax.logging.pax-logging-service@1:default,org.ow2.chameleon.commons.jabsorb@default:default,org.restlet.ext.xml@default:default,org.restlet@default:default,osgi.core@default:default,slf4j.api@1:default,slf4j.log4j12@default:false,target@default:default"/>
<booleanAttribute key="tracing" value="false"/>
<booleanAttribute key="useCustomFeatures" value="false"/>
<booleanAttribute key="useDefaultConfigArea" value="true"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.Vector;

import org.energy_home.jemma.ah.hac.ApplianceException;
import org.energy_home.jemma.ah.hac.ApplianceValidationException;
Expand All @@ -32,7 +31,6 @@
import org.energy_home.jemma.ah.hac.ILocation;
import org.energy_home.jemma.ah.hac.ServiceClusterException;
import org.energy_home.jemma.ah.hac.lib.AttributeValue;
import org.json.JSONException;

public interface GreenAtHomeApplianceService {

Expand All @@ -57,6 +55,8 @@ public AttributeValue getAttribute(String peerAppliancePid, String name) throws
//public Boolean setAllPropConfiguration(String jsonVar) throws JSONException, IOException;

public ArrayList getAppliancesConfigurations() throws ApplianceException, ServiceClusterException;

public ArrayList<Hashtable<String, String>> getNoServerCustomDevice() throws ApplianceException, ServiceClusterException;

//public Hashtable getInfo(IAppliance peerAppliance) throws ApplianceException, ServiceClusterException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@
*/
package org.energy_home.jemma.ah.internal.greenathome;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
Expand Down Expand Up @@ -119,11 +115,7 @@
import org.energy_home.jemma.hac.adapter.http.AhHttpAdapter;
import org.energy_home.jemma.hac.adapter.http.HttpImplementor;
import org.energy_home.jemma.m2m.ContentInstance;
import org.json.JSONException;
import org.json.JSONObject;
import org.omg.CORBA.CTX_RESTRICT_SCOPE;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleReference;
import org.osgi.framework.Constants;
import org.osgi.service.cm.ConfigurationAdmin;
import org.osgi.service.cm.ConfigurationException;
Expand Down Expand Up @@ -1900,7 +1892,7 @@ protected synchronized void start(ComponentContext ctx){
this.componentContext = ctx;

//register this component as ManagedService
Dictionary serviceProps=new Hashtable();
Dictionary<String, String> serviceProps=new Hashtable<String, String>();
serviceProps.put(Constants.SERVICE_PID,getServicePID());
this.componentContext.getBundleContext().registerService(ManagedService.class.getName(), this, serviceProps);

Expand Down Expand Up @@ -2023,6 +2015,60 @@ public ArrayList getAppliancesConfigurations() throws ApplianceException, Servic
return infos;
}
}

/*
* Gets a dummy list of appliances, read from the properties file noserver.properties.
*
* the entries expected loook like:
*
* CustomDevice0_icona=plug
* CustomDevice0_nome=Forno
* CustomDevice0_consumo=1000
* CustomDevice0_location=location
* CustomDevice0_stato=1
* CustomDevice0_connessione=connection
* CustomDevice0_ah.app.type=org.energy_home.jemma.ah.zigbee.whitegood
* CustomDevice0_ah.category.pid=12
*
* @see org.energy_home.jemma.ah.greenathome.GreenAtHomeApplianceService#getNoServerCustomDevice()
*/

public ArrayList<Hashtable<String, String>> getNoServerCustomDevice() throws ApplianceException, ServiceClusterException {

ArrayList<Hashtable<String, String>> infos = new ArrayList<Hashtable<String, String>>();

try {
if(props==null)
loadPropFile();
} catch (IOException e) {
e.printStackTrace();
return null;
}

int i=0;

while(true)
{
String icon = (String) props.get("CustomDevice" + i + "_icona");

if (icon==null) break;

Hashtable<String, String> ht = new Hashtable<String, String>();
ht.put("icona", icon);
ht.put("nome", (String) props.get("CustomDevice" + i + "_nome"));
ht.put("potenza", (String) props.get("CustomDevice" + i + "_potenza"));
ht.put("consumo", (String) props.get("CustomDevice" + i + "_consumo"));
ht.put("location", (String) props.get("CustomDevice" + i + "_location"));
ht.put("stato", (String) props.get("CustomDevice" + i + "_stato"));
ht.put("connessione", (String) props.get("CustomDevice" + i + "_connessione"));
ht.put("ah.app.type", (String) props.get("CustomDevice" + i + "_ah.app.type"));
ht.put("ah.category.pid", (String) props.get("CustomDevice" + i + "_ah.category.pid"));
infos.add(ht);
i++;
}

return infos;
}

public void updateAppliance(Dictionary props) throws ApplianceException {

Expand Down
65 changes: 64 additions & 1 deletion jemma.osgi.ah.greenathome/src/main/resources/noserver.properties
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,67 @@ SuddivisioneConsumi3_val=0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
SICostMONTH=1.25 , 1.12 , 1.25 , 1.36 , 0.99 , 1.12 , 1.03 , 1.25 , 1.36 , 1.14 , 1.45 , 2.03 , 2.12 , 1.23 , 1.36 , 2.00 , 1.23 , 1.56 , 1.36 , 2.00 , 1.25 , 1.36 , 1.25 , 1.25 , 1.45 , 1.78 , 1.99 , 1.69 , 1.85 , 1.58 , 1.00
SIEnergyDAY=82 , 88 , 83 , 89 , 983 , 93 , 90 , 812 , 910 , 1060 , 973 , 1625 , 2360 , 1492 , 1450 , 801 , 921 , 1565 , 1643 , 2681 , 1652 , 332 , 310 , 78
SuddivisioneConsumi0_el=ah.app.3521399293210525833-8
ProducedPower=150
ProducedPower=150
CustomDevice0_icona=forno
CustomDevice0_nome=Forno
CustomDevice0_potenza=1000
CustomDevice0_consumo=100000
CustomDevice0_location=location
CustomDevice0_stato=1
CustomDevice0_connessione=connection
CustomDevice0_ah.app.type=org.energy_home.jemma.ah.zigbee.whitegood
CustomDevice0_ah.category.pid=38
CustomDevice1_icona=lvb2
CustomDevice1_nome=Lavatrice
CustomDevice1_potenza=600
CustomDevice1_consumo=60000
CustomDevice1_location=location
CustomDevice1_stato=1
CustomDevice1_connessione=connection
CustomDevice1_ah.app.type=org.energy_home.jemma.ah.zigbee.whitegood
CustomDevice1_ah.category.pid=11
CustomDevice2_icona=frigorifero
CustomDevice2_nome=Frigorifero
CustomDevice2_potenza=400
CustomDevice2_consumo=40000
CustomDevice2_location=location
CustomDevice2_stato=1
CustomDevice2_connessione=connection
CustomDevice2_ah.app.type=org.energy_home.jemma.ah.zigbee.whitegood
CustomDevice2_ah.category.pid=8
CustomDevice3_icona=tv
CustomDevice3_nome=Televisore
CustomDevice3_potenza=150
CustomDevice3_consumo=15000
CustomDevice3_location=location
CustomDevice3_stato=1
CustomDevice3_connessione=connection
CustomDevice3_ah.app.type=org.energy_home.jemma.ah.zigbee.smartplug
CustomDevice3_ah.category.pid=4
CustomDevice4_icona=plug
CustomDevice4_nome=plug
CustomDevice4_potenza=100
CustomDevice4_consumo=10000
CustomDevice4_location=location
CustomDevice4_stato=1
CustomDevice4_connessione=connection
CustomDevice4_ah.app.type=org.energy_home.jemma.ah.zigbee.smartplug
CustomDevice4_ah.category.pid=13
CustomDevice5_icona=plug
CustomDevice5_nome=SmartInfo
CustomDevice5_potenza=100
CustomDevice5_consumo=300000
CustomDevice5_location=location
CustomDevice5_stato=1
CustomDevice5_connessione=connection
CustomDevice5_ah.app.type=org.energy_home.jemma.ah.zigbee.metering
CustomDevice5_ah.category.pid=12
CustomDevice6_icona=plug
CustomDevice6_nome=SmartInfoProd
CustomDevice6_potenza=100
CustomDevice6_consumo=300000
CustomDevice6_location=location
CustomDevice6_stato=1
CustomDevice6_connessione=connection
CustomDevice6_ah.app.type=org.energy_home.jemma.ah.zigbee.metering
CustomDevice6_ah.category.pid=14
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-2
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2014.07.25 at 11:13:34 AM CEST
// Generated on: 2014.12.10 at 10:38:31 AM CET
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-2
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2014.07.25 at 11:13:34 AM CEST
// Generated on: 2014.12.10 at 10:38:31 AM CET
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-2
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2014.07.25 at 11:13:34 AM CEST
// Generated on: 2014.12.10 at 10:38:31 AM CET
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-2
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2014.07.25 at 11:13:34 AM CEST
// Generated on: 2014.12.10 at 10:38:31 AM CET
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-2
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2014.07.25 at 11:13:34 AM CEST
// Generated on: 2014.12.10 at 10:38:31 AM CET
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-2
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2014.07.25 at 11:13:34 AM CEST
// Generated on: 2014.12.10 at 10:38:31 AM CET
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-2
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2014.07.25 at 11:13:34 AM CEST
// Generated on: 2014.12.10 at 10:38:31 AM CET
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-2
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2014.07.25 at 11:13:34 AM CEST
// Generated on: 2014.12.10 at 10:38:31 AM CET
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-2
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2014.07.25 at 11:13:34 AM CEST
// Generated on: 2014.12.10 at 10:38:31 AM CET
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-2
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2014.07.25 at 11:13:34 AM CEST
// Generated on: 2014.12.10 at 10:38:31 AM CET
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-2
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2014.07.25 at 11:13:34 AM CEST
// Generated on: 2014.12.10 at 10:38:31 AM CET
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-2
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2014.07.25 at 11:13:34 AM CEST
// Generated on: 2014.12.10 at 10:38:31 AM CET
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-2
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2014.07.25 at 11:13:34 AM CEST
// Generated on: 2014.12.10 at 10:38:31 AM CET
//


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-2
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2014.07.25 at 11:13:34 AM CEST
// Generated on: 2014.12.10 at 10:38:31 AM CET
//


Expand Down
Loading

0 comments on commit 723f4ae

Please sign in to comment.