V2_0.java [src/java/m/example/simpleservice] Revision: default Date:
/*
* 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 m.example.simpleservice;
import csip.api.server.ServiceException;
import javax.ws.rs.Path;
import static csip.annotations.State.*;
import csip.annotations.*;
@Name("conv #2")
@Description("Example of an simple service")
@Documentation("https://alm.engr.colostate.edu/csip")
@State(PROTOTYPE)
@License(License.GPL3)
@VersionInfo("$Id$")
@Author(name = "od", email = "<odavid@colostate.edu>", org = "CSU")
@Category("Examples")
@Category("Climate")
@Path("m/simpleservice/2.0")
@Polling(first = 1000, next = 1000)
public class V2_0 extends csip.ModelDataService {
@Override
protected void doProcess() throws Exception {
System.out.println(config().getServiceKey());
int sleep = parameter().getInt("sleep", 25);
boolean b = parameter().getBoolean("b", true);
System.out.println("Value " + sleep + " " + b);
double temp = parameter().getDouble("temp");
String un = parameter().getUnit("temp");
if (un.equals("C")) {
results().put("temp", temp * 9 / 5 + 32, "temperature", "F");
return;
}
throw new ServiceException("missing unit.");
}
}