The following document contains the results of PMD's CPD 5.6.1.
| File | Project | Line |
|---|---|---|
| org/universAAL/lddi/manager/gui/GUI.java | universAAL Samples LDDI Continua Manager Client (unix OS version) | 153 |
| org/universAAL/lddi/manager/win/gui/GUI.java | universAAL Samples LDDI Continua Manager Client (windows OS version) | 153 |
radiobuttonPanel.setBounds(20, 100, 400, 50);
radioButtonsGroup = new ButtonGroup();
realMeasurementButton = createJRadioButton("Real measurement");
realMeasurementButton.setToolTipText("Continua devices should be paired first");
simulatedMeasurementButton = createJRadioButton("Simulated measurement");
simulatedMeasurementButton
.setToolTipText("Random values will be published to universAAL context bus (Continua devices not required)");
radiobuttonPanel.add(realMeasurementButton);
radiobuttonPanel.add(simulatedMeasurementButton);
mainPanel.add(radiobuttonPanel);
// Buttons
bloodPressureButton = createJButton(bloodPressureImage, 214, 160, 218, 145, "bloodPressure");
mainPanel.add(bloodPressureButton);
weighingScaleButton = createJButton(weighingScaleImage, 18, 154, 178, 157, "weighingScale");
mainPanel.add(weighingScaleButton);
}
/** Create JPanel */
public JPanel createJPanel() {
JPanel output = null;
output = new JPanel();
output.setLayout(null);
output.setBorder(new EmptyBorder(5, 5, 5, 5));
output.setBackground(Color.WHITE);
return output;
}
/** Create JButtons */
public JButton createJButton(String image, int x, int y, int weight, int height, String name) {
JButton output = null;
output = new JButton("");
output.setBackground(Color.WHITE);
if (image != null)
output.setIcon(new ImageIcon(ctx.getBundle().getResource(image)));
output.setBounds(x, y, weight, height);
output.setActionCommand(name);
output.addActionListener(this);
return output;
}
/** Create JRadioButtons */
public JRadioButton createJRadioButton(String name) {
JRadioButton output = null;
output = new JRadioButton(name, false);
output.setActionCommand(name);
output.setBackground(Color.WHITE);
output.addActionListener(this);
radioButtonsGroup.add(output);
return output;
}
/** Close GUI frame */
public void closeGUI() {
dispose();
}
/** Action listener for radio buttons and jbuttons */
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("bloodPressure")) {
// Blood pressure device
if (realMeasurementButton.isSelected()) {
realMeasurement = true;
createPublisher("bloodPressure", "real");
} else if (simulatedMeasurementButton.isSelected()) {
realMeasurement = false;
createPublisher("bloodPressure", "simulated");
}
} else if (e.getActionCommand().equals("weighingScale")) {
// Weighing scale device
if (realMeasurementButton.isSelected()) {
realMeasurement = true;
createPublisher("weighingScale", "real");
} else if (simulatedMeasurementButton.isSelected()) {
realMeasurement = false;
createPublisher("weighingScale", "simulated");
}
} else if (e.getActionCommand().equals("publishData")) {
// Publish data to universAAL context bus. Ensure that values are not NULL
X73Publisher = new Publisher(ctx);
if (realMeasurement) {
// Real values
if (remoteDeviceType.equals("WeightingScale")) {
if (finalMeasuredWeightData != -1.0) {
double temp_1 = shortDecimalNumber(finalMeasuredWeightData) * 1000;
int temp = (int) temp_1;
X73Publisher.publishWeightEvent(temp);
// stopPublisherGUI();
}
} else {
if ((finalDiaBloodPressureData != -1) && (finalHrBloodPressureData != -1)
&& (finalSysBloodPressureData != -1)) {
int temp_0 = (int) finalSysBloodPressureData;
int temp_1 = (int) finalDiaBloodPressureData;
int temp_2 = (int) finalHrBloodPressureData;
X73Publisher.publishBloodPressureEvent(temp_0, temp_1, temp_2);
// stopPublisherGUI();
}
}
} else {
// Random values
if (remoteDeviceType.equals("WeightingScale")) {
X73Publisher.publishWeightEvent(Integer.parseInt(publisherWeightValueTextfield.getText()));
// stopPublisherGUI();
} else {
X73Publisher.publishBloodPressureEvent(
Integer.parseInt(publisherBloodPressureSysValueTextfield.getText()),
Integer.parseInt(publisherBloodPressureDiaValueTextfield.getText()),
Integer.parseInt(publisherBloodPressurePulValueTextfield.getText()));
// stopPublisherGUI();
}
}
}
}
/** Create and show universAAL publisher frame */
public void createPublisher(String device, String type) {
// Hide main GUI
setVisible(false);
// Create dialog frame
publisher = new JDialog(this, "universAAL publisher", true);
publisher.setResizable(false);
publisher.setBounds(100, 100, 650, 325); | ||
| File | Project | Line |
|---|---|---|
| org/universAAL/lddi/manager/gui/GUI.java | universAAL Samples LDDI Continua Manager Client (unix OS version) | 280 |
| org/universAAL/lddi/manager/win/gui/GUI.java | universAAL Samples LDDI Continua Manager Client (windows OS version) | 278 |
stopPublisherGUI();
}
});
// Main panel
mainPublisherPanel = createJPanel();
publisher.getContentPane().add(mainPublisherPanel, BorderLayout.CENTER);
// Main text label
publisherMainLabel = createJLabel("", 200, 5, 350, 50, Font.BOLD, 24);
// Image icon
publisherLogoLabel = new JLabel("");
publisherLogoLabel.setBounds(25, 75, 218, 145);
// Check Continua agent selected
if (device.equals("bloodPressure")) {
publisherMainLabel.setText("Blood pressure monitor");
publisherLogoLabel.setIcon(new ImageIcon(ctx.getBundle().getResource(bloodPressureImage)));
publisherBloodPressureSysValueLabel = createJLabel("SYS(mmHg)", 250, 100, 100, 50, Font.PLAIN, 16);
publisherBloodPressureSysValueTextfield = createJTextfield(400, 100, 100, 50, Font.PLAIN, 16);
publisherBloodPressureDiaValueLabel = createJLabel("DIA(mmHg)", 250, 150, 100, 50, Font.PLAIN, 16);
publisherBloodPressureDiaValueTextfield = createJTextfield(400, 150, 100, 50, Font.PLAIN, 16);
publisherBloodPressurePulValueLabel = createJLabel(" BPM", 250, 200, 100, 50, Font.PLAIN, 16);
publisherBloodPressurePulValueTextfield = createJTextfield(400, 200, 100, 50, Font.PLAIN, 16);
} else {
publisherMainLabel.setText("Weighing scale");
publisherLogoLabel.setIcon(new ImageIcon(ctx.getBundle().getResource(weighingScaleImage)));
publisherWeightValueLabel = createJLabel("Weight value", 250, 100, 150, 50, Font.PLAIN, 16);
publisherWeightValueTextfield = createJTextfield(400, 100, 100, 50, Font.PLAIN, 16);
publisherWeightUnitLabel = createJLabel(" Weight unit", 250, 150, 150, 50, Font.PLAIN, 16);
publisherWeightUnitTextfield = createJTextfield(400, 150, 100, 50, Font.PLAIN, 16);
}
publisherButton = createJButton(null, 250, 275, 200, 25, "publishData");
publisherButton.setText("Publish to universAAL");
publisherButton.setToolTipText("Public measured data to universAAL context bus");
// Check type of measurement
if (type.equals("real")) {
// Run hdp manager and wait for agent values
if (device.equals("bloodPressure")) {
remoteDeviceType = "BloodPressureMonitor";
instantiateHdpManager();
} else {
remoteDeviceType = "WeightingScale";
instantiateHdpManager();
}
} else {
// Generate random values
if (device.equals("bloodPressure")) {
remoteDeviceType = "BloodPressureMonitor";
publisherBloodPressureSysValueTextfield.setText("" + getRandomValue(90, 119));
publisherBloodPressureDiaValueTextfield.setText("" + getRandomValue(60, 79));
publisherBloodPressurePulValueTextfield.setText("" + getRandomValue(49, 198));
} else {
remoteDeviceType = "WeightingScale";
publisherWeightValueTextfield.setText("" + getRandomValue(50, 110));
publisherWeightUnitTextfield.setText("kg");
}
}
// Add components to the panel
mainPublisherPanel.add(publisherMainLabel);
mainPublisherPanel.add(publisherLogoLabel);
addJLabelComponent(publisherBloodPressureSysValueLabel);
addJLabelComponent(publisherBloodPressureSysValueTextfield);
addJLabelComponent(publisherBloodPressureDiaValueLabel);
addJLabelComponent(publisherBloodPressureDiaValueTextfield);
addJLabelComponent(publisherBloodPressurePulValueLabel);
addJLabelComponent(publisherBloodPressurePulValueTextfield);
addJLabelComponent(publisherWeightValueLabel);
addJLabelComponent(publisherWeightValueTextfield);
addJLabelComponent(publisherWeightUnitLabel);
addJLabelComponent(publisherWeightUnitTextfield);
mainPublisherPanel.add(publisherButton);
// Show
publisher.setVisible(true); | ||
| File | Project | Line |
|---|---|---|
| org/universAAL/lddi/manager/publisher/hdpManager.java | universAAL Samples LDDI Continua Manager Client (unix OS version) | 333 |
| org/universAAL/lddi/weighingscale/publisher/hdpManager.java | universAAL Samples LDDI Weighing scale agent publisher | 319 |
}
/** Java methods */
// Init method
public void init() {
// Create the objects related to ISO/IEEE 11073 Manager interpreter
eventmanager = new EventIEEEManager();
x73manager = new Manager(eventmanager);
fsm = x73manager.getFSM();
rmp = x73manager.getMessageProcessor();
// First (mandatory) step: DBUS platform should be successfully
// initialized (otherwise JVM will return fatal errors)
if (startDbusPlatform()) {
// Get and show the object path of the DEFAULT adapter (in GNU/Linux
// environments should be 'hci0')
String defaultDevicePathTemp = getLocalBluetoothAdapterPath();
System.out.println("Default bluetooth adapter path: " + defaultDevicePathTemp);
if (defaultDevicePathTemp == null) {
System.out.println("Unable to detect bluetooth adapters");
System.exit(0);
}
// Show the object path of ALL the local bluetooth adapters
// available at our PC
System.out.println("List of local bluetooth adapters:");
showLocalBluetoothAdaptersPath();
// Show some properties of the DEFAULT adapter: address, name,
// class, powered, discoverable, pairable, discoverable timeout,
// pairable timeout,
// discovering, devices and UUIDs. Check bluetooth manuals to
// understand the meaning of each
System.out.println("Local bluetooth properties:");
showDefaultLocalBluetoothAdaptersProperties();
// Object path of a remote device
remoteDevicePath = getRemoteBluetoothAdapterPath(macAddressRemoteDevice);
System.out.println("Remote bluetooth adapter path: " + remoteDevicePath);
// Remote device properties (from its own path)
System.out.println("Remote device properties (BEFORE):");
showRemoteBluetoothAdapterProperties(remoteDevicePath);
// Prior to start any communication process, we need to ensure that
// the remote device appears as a 'Trusted' (true value) device (by
// default
// it should appear as false (not trusted) so we need to change this
// property
setPropertyRemoteDevice(remoteDevicePath, trustedProperty, true);
// Show the properties of the remote device to verify that the
// 'Trusted' value has been successfully changed (false -> true)
System.out.println("Remote device properties (AFTER):");
showRemoteBluetoothAdapterProperties(remoteDevicePath);
// We need to create an HDP application before any HDP data frames
// exchange between agents/sources and managers/sinks. IMPORTANT:
// the app
// created will be only valid for the data types and roles passed as
// arguments. For instance, this HDP channel will be created only if
// the
// remote device is a weight scale acting as a source. So, here we
// go...
String hdpApplicationIdTemp = createHDPApplication(dataTypeValue, roleValue, shortDescriptionValue,
channelTypeValue);
System.out.println("HDP application identifier: " + hdpApplicationIdTemp);
// HDP app successfully created
if (hdpApplicationIdTemp != null) {
// We have the option to destroy/close any HDP application. For
// security reason, only the owner of this process will be able
// to destroy it
destroyHDPApplication(hdpApplicationIdTemp);
// New HDP application (again)
hdpApplicationIdTemp = createHDPApplication(dataTypeValue, roleValue, shortDescriptionValue,
channelTypeValue);
System.out.println("HDP application identifier: " + hdpApplicationIdTemp);
// A good practice should be check the availability of the DBUS
// system (is it still alive?)
System.out.println("DBUS sytem status: " + (getDbusSystemAvailability() ? "Up" : "Down"));
// Remember that those PHD devices with compatible data type and
// role (weight scales and sources) are able to find our
// applicattion through
// bluetooth connections. At this case: we are a sink so we need
// to wait for input connections (handle signals). First step:
// we need to
// subscribe our application to HDP events in the DBUS system.
if (!enableHDPListener()) {
System.out.println("Unable to listen HDP messages inside DBUS");
System.exit(0);
} else {
System.out.println(fsm.getStringTransportState() + " " + fsm.getStringChannelState());
waitHDPConnections();
}
}
} else {
System.out.println(
"Ups. Bad news, the monkey who has developed this application ran out of nuts. Try again later...");
}
}
/* HDP channel available. x073 state machine at connected status */
public void onChannelConnected() {
// Get the object path of the just created HDP channel
if (remoteDevicePath != null) {
hdpDataChannelPath = getHDPDataChannelPath(remoteDevicePath);
System.out.println("HDP channel path: " + hdpDataChannelPath); | ||
| File | Project | Line |
|---|---|---|
| org/universAAL/lddi/manager/publisher/Publisher.java | universAAL Samples LDDI Continua Manager Client (unix OS version) | 51 |
| org/universAAL/lddi/manager/win/publisher/Publisher.java | universAAL Samples LDDI Continua Manager Client (windows OS version) | 51 |
public class Publisher {
// Atributes
// Default context publisher
private ContextPublisher cp;
// Context provider info (provider type)
ContextProvider cpInfo = new ContextProvider();
// Module context
ModuleContext mc;
// URI prefix
public static final String PUBLISHER_URI_PREFIX = "http://http://ontology.universAAL.org/PersonalHealtDeviceSimulator.owl#";
// Constructor
/**
* Publisher contructor
*
* @param context
* - framework bundle context
*/
public Publisher(BundleContext context) {
// Instantiate the context provider info with a valid provider URI
cpInfo = new ContextProvider(PUBLISHER_URI_PREFIX + "PersonalHealthDeviceContextProvider");
mc = OSGiContainer.THE_CONTAINER.registerModule(new Object[] { context });
// Set to type gauge (only publishes data information it senses)
cpInfo.setType(ContextProviderType.gauge);
// Set the provided events to unknown with an empty pattern
cpInfo.setProvidedEvents(new ContextEventPattern[] { new ContextEventPattern() });
// Create and register the context publisher
cp = new DefaultContextPublisher(mc, cpInfo);
}
// Methods
/** Publish weighting scale events to universAAL bus */
public void publishWeightEvent(int weight) {
WeighingScale ws = new WeighingScale(PUBLISHER_URI_PREFIX + "WeighingScale");
PersonWeight m_ws = new PersonWeight(PUBLISHER_URI_PREFIX + "Measurement_Weight");
m_ws.setProperty(Measurement.PROP_VALUE, Float.valueOf((float) weight));
ws.setValue(m_ws);
cp.publish(new ContextEvent(ws, WeighingScale.PROP_HAS_VALUE));
}
/** Publish blood pressure events to universAAL bus */
public void publishBloodPressureEvent(int sys, int dia, int hr) {
BloodPressure value = new BloodPressure(PUBLISHER_URI_PREFIX + "BloodPressureMeasurement");
Measurement systolic = new Measurement();
systolic.setValue(Float.valueOf(sys));
Measurement diastolic = new Measurement();
diastolic.setValue(Float.valueOf(dia));
value.setSyst(systolic);
value.setDias(diastolic);
BloodPressureSensor sensor = new BloodPressureSensor(PUBLISHER_URI_PREFIX + "continuaBTBloodPressureSensor");
sensor.setValue(value);
cp.publish(new ContextEvent(sensor, BloodPressureSensor.PROP_HAS_VALUE));
HeartRate hrvalue = new HeartRate();
hrvalue.setProperty(Measurement.PROP_VALUE, Integer.valueOf(hr));
HeartRateSensor hrsensor = new HeartRateSensor(PUBLISHER_URI_PREFIX + "continuaBTHeartRateSensor");
hrsensor.setValue(hrvalue);
cp.publish(new ContextEvent(hrsensor, BloodPressureSensor.PROP_HAS_VALUE));
}
} | ||
| File | Project | Line |
|---|---|---|
| org/universAAL/samples/lighting/server_regular/MyLightingOntologified.java | universAAL Samples AAPI Regular Lighting Server | 30 |
| org/universAAL/samples/lighting/server_simple/MyLightingOntologified.java | universAAL Samples AAPI Lighting Server Simplified | 30 |
public class MyLightingOntologified {
/**
* Real implementation controlling light sources.
*/
private MyLighting realLighting = new MyLighting();
public MyLightingOntologified(String namespace) {
/* Initializing fields with ontological constants */
this.LAMP_URI_PREFIX = namespace + "controlledLamp";
this.LOCATION_URI_PREFIX = "urn:space:myHome#";
}
/*
* Fields and methods for mapping real implementation onto ontology.
*/
private final String LAMP_URI_PREFIX;
private final String LOCATION_URI_PREFIX;
private String constructLampURIfromLocalID(int localID) {
return LAMP_URI_PREFIX + localID;
}
private String constructLocationURIfromLocalID(String localID) {
return LOCATION_URI_PREFIX + localID;
}
private int extractLocalIDfromLampURI(String lampURI) {
return Integer.parseInt(lampURI.substring(LAMP_URI_PREFIX.length()));
}
/*
* Implementation of ontological interface
*/
public LightSource[] getControlledLamps() {
ArrayList<LightSource> al = new ArrayList<LightSource>();
Integer[] controlledLamps = realLighting.getControlledLamps();
for (int i = 0; i < controlledLamps.length; i++) {
LightSource ls = new LightSource(constructLampURIfromLocalID(i));
ls.setLightType(ElectricLight.lightBulb);
al.add(ls);
}
return al.toArray(new LightSource[0]);
}
public Object[] getLampInfo(LightSource lamp) {
int lampID = extractLocalIDfromLampURI(lamp.getURI());
int state = realLighting.getState(lampID);
String loc = realLighting.getLampLocation(lampID);
Room ontologyLoc = new Room(constructLocationURIfromLocalID(loc));
return new Object[] { state, ontologyLoc };
}
public void turnOff(LightSource lamp) {
int lampID = extractLocalIDfromLampURI(lamp.getURI());
realLighting.turnOff(lampID);
}
public void turnOn(LightSource lamp) {
int lampID = extractLocalIDfromLampURI(lamp.getURI());
realLighting.turnOn(lampID);
}
} | ||
| File | Project | Line |
|---|---|---|
| org/universAAL/samples/lighting/server_regular/unit_impl/MyLighting.java | universAAL Samples AAPI Regular Lighting Server | 28 |
| org/universAAL/samples/lighting/server_simple/unit_impl/MyLighting.java | universAAL Samples AAPI Lighting Server Simplified | 23 |
public class MyLighting {
private class Lamp {
String loc;
boolean isOn;
Lamp(String loc, boolean isOn) {
this.loc = loc;
this.isOn = isOn;
}
}
private Lamp[] myLampDB = new Lamp[] { new Lamp("loc1", false), new Lamp("loc2", false), new Lamp("loc3", false),
new Lamp("loc4", false) };
public String getLampLocation(int lampID) {
return myLampDB[lampID].loc;
}
public int getState(int lampID) {
return myLampDB[lampID].isOn ? 100 : 0;
}
public Integer[] getControlledLamps() {
Integer[] ids = new Integer[myLampDB.length];
for (int i = 0; i < myLampDB.length; i++)
ids[i] = i;
return ids;
}
public Object[] getLampInfo(int lampID) {
String loc = getLampLocation(lampID);
int state = getState(lampID);
return new Object[] { state, loc };
}
public void turnOff(int lampID) {
if (myLampDB[lampID].isOn) {
myLampDB[lampID].isOn = false;
}
}
public void turnOn(int lampID) {
if (!myLampDB[lampID].isOn) {
myLampDB[lampID].isOn = true;
}
}
} | ||
| File | Project | Line |
|---|---|---|
| org/universAAL/lddi/manager/gui/GUI.java | universAAL Samples LDDI Continua Manager Client (unix OS version) | 350 |
| org/universAAL/lddi/manager/win/gui/GUI.java | universAAL Samples LDDI Continua Manager Client (windows OS version) | 349 |
publisher.setVisible(true);
}
/** Create JLabel */
public JLabel createJLabel(String name, int x, int y, int weight, int height, int fontType, int fontSize) {
JLabel output = null;
output = new JLabel(name);
output.setBounds(x, y, weight, height);
output.setFont(new Font("Courier", fontType, fontSize));
output.setHorizontalTextPosition(SwingConstants.CENTER);
return output;
}
/** Create JTextfield */
public JTextField createJTextfield(int x, int y, int weight, int height, int fontType, int fontSize) {
JTextField output = null;
output = new JTextField(10);
output.setBounds(x, y, weight, height);
output.setEditable(false);
output.setColumns(10);
output.setHorizontalAlignment(JTextField.CENTER);
output.setFont(new Font("Courier", fontType, fontSize));
return output;
}
/** Add components to panel */
public void addJLabelComponent(JComponent component) {
if (component != null)
mainPublisherPanel.add(component);
}
/** Reset components */
public void resetComponentsStatus() {
publisherWeightValueLabel = null;
publisherWeightValueTextfield = null;
publisherWeightUnitLabel = null;
publisherWeightUnitTextfield = null;
publisherBloodPressureSysValueLabel = null;
publisherBloodPressureSysValueTextfield = null;
publisherBloodPressureDiaValueLabel = null;
publisherBloodPressureDiaValueTextfield = null;
publisherBloodPressurePulValueLabel = null;
publisherBloodPressurePulValueTextfield = null;
remoteDeviceType = null;
realMeasurement = false;
finalMeasuredWeightData = -1.0;
finalSysBloodPressureData = -1;
finalDiaBloodPressureData = -1;
finalHrBloodPressureData = -1;
}
/** Shorten number of decimals */
public double shortDecimalNumber(double d) { | ||
| File | Project | Line |
|---|---|---|
| org/universAAL/samples/ctxtbus/HistoryCaller.java | universAAL Samples Context bus tester | 76 |
| org/universAAL/samples/ctxtbus/HistoryCaller.java | universAAL Samples Context bus tester | 171 |
ServiceResponse response = caller.call(getGetEventsRequest(matchEvent, tstFrom, tstTo));
if (response.getCallStatus() == CallStatus.succeeded) {
// Object value = getReturnValue(response.getOutputs(),
// OUTPUT_LIST_OF_EVENTS);
Object value = response.getOutput(OUTPUT_LIST_OF_EVENTS, true);
if (value instanceof Resource) {
if (((Resource) value).getURI().contains("#nil")) {
log.info("History Client - result is empty");
return 0;
}
} else {
try {
ContextEvent[] events = (ContextEvent[]) ((List) value)
.toArray(new ContextEvent[((List) value).size()]);
for (int j = 0; j < events.length; j++) {
count++;
log.info("Retrieved context event from CHe:\n" + " Subject =" + events[j].getSubjectURI()
+ "\n" + " Subject type=" + events[j].getSubjectTypeURI() + "\n"
+ " Predicate =" + events[j].getRDFPredicate() + "\n" + " Object ="
+ events[j].getRDFObject());
log.info(Activator.ser.serialize(events[j]));
}
} catch (Exception e) {
log.info("History Client: List of events corrupt!", e);
}
}
} else
log.info("History Client - status of getEvents(): " + response.getCallStatus());
return count;
}
private ServiceRequest getGetEventsRequest(org.universAAL.ontology.che.ContextEvent matchEvent, long tstFrom, | ||
| File | Project | Line |
|---|---|---|
| org/universAAL/lddi/manager/publisher/hdpManager.java | universAAL Samples LDDI Continua Manager Client (unix OS version) | 107 |
| org/universAAL/lddi/weighingscale/publisher/hdpManager.java | universAAL Samples LDDI Weighing scale agent publisher | 103 |
private String remoteDeviceType = null;
/** Native functions */
/**
* Start dbus platform for message interchanging within processes in Linux
* OS.
*
* @return if the Dbus platform is correctly initialized.
*/
private native boolean startDbusPlatform();
/**
* Get the path for the local Bluetooth adapter which is in use at the
* moment.
*
* @return local bluetooth adapter path
*/
private native String getLocalBluetoothAdapterPath();
/**
* Show path of all local bluetooth adapters available at PC (may be more
* than one).
*/
private native void showLocalBluetoothAdaptersPath();
/**
* Show all properties of the DEFAULT local bluetooth adapter. In case a
* computer has more than one Bluetooth adapter, there will be one in use by
* default.
*/
private native void showDefaultLocalBluetoothAdaptersProperties();
/**
* Get the object path of a remote device given a MAC address
* (format:XX:XX:XX:XX:XX:XX).
*
* @param macAddressRemoteDevice
* the MAC address of the desired remote device (the format of
* the MAC is XX:XX:XX:XX:XX:XX).
* @return the path for the remote Bluetooth device in the local machine.
*/
private native String getRemoteBluetoothAdapterPath(String macAddressRemoteDevice);
/**
* Show all properties of a remote device (it should be first created with
* getRemoteBluetoothAdapterPath method).
*
* @param remoteDevicePath
* the path for the remote Bluetooth device in the local machine.
* @see showDefaultLocalBluetoothAdaptersProperties()
*/
private native void showRemoteBluetoothAdapterProperties(String remoteDevicePath);
/**
* Modify a property of a remote device. This will be used for enabling the
* "Trusted" property in a remote Health Device Profile capable device for
* being establish a connection.
*
* @param remoteDevicePath
* the path for the remote Bluetooth device in the local machine.
* @param propertyKey
* the name of the property to be modified.
* @param propertyValue
* the new value for the property.
*/
private native void setPropertyRemoteDevice(String remoteDevicePath, String propertyKey, boolean propertyValue);
/**
* Create a new HDP application and gets the object path of the new created
* application.
*
* @param dataTypeValue
* which kind of a HDP capable device will be used.
* @param roleValue
* set the role of the HDP role that the local machine will be
* playing. Usually, "Sink"
* @param shortDescriptionValue
* custom string for helping the remote devices to identify the
* local machine they are connected to.
* @param channelTypeValue
* set whether the channel is working with trusted or streaming
* mode.
* @return the path of the new Health Device Profile application newly
* created in the local machine.
*/
private native String createHDPApplication(String dataTypeValue, String roleValue, String shortDescriptionValue,
String channelTypeValue);
/**
* Destroy an HDP application.
*
* @param objectPathHDPApplication
* the path of the Health Device Profile application to be
* destroyed.
*/
private native void destroyHDPApplication(String objectPathHDPApplication);
/**
* Checks DBUS system availability.
*
* @return true if the Dbus system is available, or false if not.
*/
private native boolean getDbusSystemAvailability();
/**
* Add a specific rule to follow HDP messages inside DBUS.
*
* @return true if the local application is subscribed to HDP messages in
* DBus.
*/
private native boolean enableHDPListener();
/**
* Wait for new incoming HDP connections.
*/
private native void waitHDPConnections();
/**
* Get the object path of the HDP channel ready to send/receive data to/from
* Continua devices.
*
* @param remoteDevicePath
* the path for the remote Bluetooth device in the local machine.
* @return the path of the data channel from a Health Device Profile
* application.
*/
private native String getHDPDataChannelPath(String remoteDevicePath);
/**
* Show the properties of a HDP data channel previously created.
*
* @param hdpDataChannelPath
* the path of the data channel from a Health Device Profile
* application.
*/
private native void showHDPDataChannelProperties(String hdpDataChannelPath);
/**
* Get the file descriptor associated to a HDP data channel
*
* @param hdpDataChannelPath
* the path of the data channel from a Health Device Profile
* application.
* @return the number that identifies the file descriptor in a Linux OS.
*/
private native int getHDPDataChannelFileDescriptor(String hdpDataChannelPath);
/**
* Release the file descriptor associated to this HDP data channel (HDP
* application will be closed).
*
* @param hdpDataChannelPath
* the path of the data channel from a Health Device Profile
* application.
*/
private native void releaseHDPDataChannelFileDescriptor(String hdpDataChannelPath);
/**
* Wait for HDP data frames from Continua Health devices. These frames will
* be compliant with ISO/IEEE 11073 standard.
*
* @param hdpDataChannelFileDescriptor
* the file descriptor that identifies a HDP data channel.
*/
private native void waitHDPDataFrames(int hdpDataChannelFileDescriptor);
/**
* Get the input data frame from a Continua Health device. The data will be
* retrieved in raw format (byte array), and will be processed by the
* ISO/IEEE 11073 library included.
*
* @param hdpDataChannelFileDescriptor
* the file descriptor that identifies a HDP data channel.
* @return the data a remote device sent, in raw format.
*/
private native byte[] getHDPDataFrame(int hdpDataChannelFileDescriptor);
/**
* Get the number of bytes read from input data frames.
*
* @param hdpDataChannelFileDescriptor
* the file descriptor that identifies a HDP data channel.
* @return the size of the data frame received.
*/
private native int getSizeHDPDataFrame(int hdpDataChannelFileDescriptor);
/**
* Show HDP data frame received.
*
* @param hdpDataChannelFileDescriptor
* the file descriptor that identifies a HDP data channel.
*/
private native void showHDPDataFrame(int hdpDataChannelFileDescriptor);
/**
* Send HDP data frames to Continua Health devices after processing the ones
* previously received and generate the proper response to them.
*
* @param hdpDataChannelFileDescriptor
* the file descriptor that identifies a HDP data channel.
* @param hdpDataFrame
* the raw byte array of the data that will be sent back to a
* Continua device.
*/
private native void sendHDPDataToDevice(int hdpDataChannelFileDescriptor, byte[] hdpDataFrame);
/**
* Free all employed resources and end HDP manager in a well-known status
*
*/
private native void closeHDPManager();
/** Constructor */
public hdpManager(String str) { | ||
| File | Project | Line |
|---|---|---|
| org/universAAL/lddi/manager/gui/GUI.java | universAAL Samples LDDI Continua Manager Client (unix OS version) | 229 |
| org/universAAL/lddi/manager/win/gui/GUI.java | universAAL Samples LDDI Continua Manager Client (windows OS version) | 229 |
| org/universAAL/lddi/manager/win/gui/GUI.java | universAAL Samples LDDI Continua Manager Client (windows OS version) | 416 |
} else if (e.getActionCommand().equals("publishData")) {
// Publish data to universAAL context bus. Ensure that values are not NULL
X73Publisher = new Publisher(ctx);
if (realMeasurement) {
// Real values
if (remoteDeviceType.equals("WeightingScale")) {
if (finalMeasuredWeightData != -1.0) {
double temp_1 = shortDecimalNumber(finalMeasuredWeightData) * 1000;
int temp = (int) temp_1;
X73Publisher.publishWeightEvent(temp);
// stopPublisherGUI();
}
} else {
if ((finalDiaBloodPressureData != -1) && (finalHrBloodPressureData != -1)
&& (finalSysBloodPressureData != -1)) {
int temp_0 = (int) finalSysBloodPressureData;
int temp_1 = (int) finalDiaBloodPressureData;
int temp_2 = (int) finalHrBloodPressureData;
X73Publisher.publishBloodPressureEvent(temp_0, temp_1, temp_2);
// stopPublisherGUI();
}
}
} else {
// Random values
if (remoteDeviceType.equals("WeightingScale")) {
X73Publisher.publishWeightEvent(Integer.parseInt(publisherWeightValueTextfield.getText()));
// stopPublisherGUI();
} else {
X73Publisher.publishBloodPressureEvent(
Integer.parseInt(publisherBloodPressureSysValueTextfield.getText()),
Integer.parseInt(publisherBloodPressureDiaValueTextfield.getText()),
Integer.parseInt(publisherBloodPressurePulValueTextfield.getText()));
// stopPublisherGUI();
}
}
} | ||
| File | Project | Line |
|---|---|---|
| org/universAAL/samples/lighting/client_regular/LightClient.java | universAAL Samples AAPI Regular Lighting Client | 124 |
| org/universAAL/samples/lighting/client/LightClient.java | universAAL Samples Lighting Client (OSGi) | 167 |
start(d);
}
private void initGUI() {
try {
setPreferredSize(new Dimension(400, 300));
this.setLayout(null);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Auto-generated method for setting the popup menu for a component
*/
private void setComponentPopupMenu(final java.awt.Component parent, final javax.swing.JPopupMenu menu) {
parent.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent e) {
if (e.isPopupTrigger())
menu.show(parent, e.getX(), e.getY());
}
public void mouseReleased(java.awt.event.MouseEvent e) {
if (e.isPopupTrigger())
menu.show(parent, e.getX(), e.getY());
}
});
}
private AbstractAction getOn() {
if (On == null) {
On = new AbstractAction("On", null) { | ||
| File | Project | Line |
|---|---|---|
| org/universAAL/samples/uibus/OPublisher.java | universAAL Samples UI bus tester | 232 |
| org/universAAL/samples/uibus/OPublisher.java | universAAL Samples UI bus tester | 349 |
String PROP_TABLE = "http://ontology.persona.org/Tests.owl#table"; String PROP_COL = "http://ontology.persona.org/Tests.owl#column"; List rows = new ArrayList(); Resource cell = new Resource(); cell.setProperty(PROP_COL + "1", new Integer(1)); cell.setProperty(PROP_COL + "2", "two"); cell.setProperty(PROP_COL + "3", new Float(3)); rows.add(cell); // ... cell = new Resource(); cell.setProperty(PROP_COL + "1", new Integer(2)); cell.setProperty(PROP_COL + "2", "three"); cell.setProperty(PROP_COL + "3", new Float(4)); rows.add(cell); // ... cell = new Resource(); cell.setProperty(PROP_COL + "1", new Integer(3)); cell.setProperty(PROP_COL + "2", "four"); cell.setProperty(PROP_COL + "3", new Float(5)); rows.add(cell); Resource dataRoot = new Resource(); dataRoot.setProperty(PROP_TABLE, rows); | ||
| File | Project | Line |
|---|---|---|
| org/universAAL/lddi/samples/activityhub/client/ActivityHubClient.java | universAAL Samples Activity Hub Client | 156 |
| org/universAAL/lddi/samples/device/client/DeviceClient.java | universAAL Samples Device Client | 171 |
infoButton.setAction(getInfo());
}
{
label2 = new JLabel("Device Info");
frame.getContentPane().add(label2);
label2.setBounds(20, 150, 200, 20);
frame.getContentPane().add(jsp1);
jsp1.setBounds(20, 170, 900, 150);
}
{
label3 = new JLabel("Context Events");
frame.getContentPane().add(label3);
label3.setBounds(20, 330, 200, 20);
frame.getContentPane().add(jsp2);
jsp2.setBounds(20, 350, 900, 180);
}
{
label4 = new JLabel("Log");
frame.getContentPane().add(label4);
label4.setBounds(20, 540, 200, 20);
frame.getContentPane().add(jsp3);
jsp3.setBounds(20, 560, 900, 180);
}
}
/**
* AbstractAction for button getSensors initiates service call to parent
*
* @return
*/
private AbstractAction getSensors() { | ||
| File | Project | Line |
|---|---|---|
| org/universAAL/samples/lighting/server_regular/LightingProviderLevel1.java | universAAL Samples AAPI Regular Lighting Server | 49 |
| org/universAAL/samples/lighting/server_regular/LightingProviderLevel2.java | universAAL Samples AAPI Regular Lighting Server | 65 |
}
public ServiceResponse handleCall(ServiceCall call) {
if (call == null)
return null;
String operation = call.getProcessURI();
if (operation == null)
return null;
if (operation.startsWith(LightingServerURIs.GetControlledLamps.URI))
return getControlledLamps();
LightSource input = (LightSource) call.getInputValue(LightingServerURIs.GetLampInfo.Input.LAMP_URI);
if (input == null)
return null;
if (operation.startsWith(LightingServerURIs.GetLampInfo.URI))
return getLampInfo(input);
if (operation.startsWith(LightingServerURIs.TurnOff.URI))
return turnOff(input);
if (operation.startsWith(LightingServerURIs.TurnOn.URI))
return turnOn(input);
return null;
}
// create a service response that including all available light sources
private ServiceResponse getControlledLamps() {
AapiServiceResponse sr = new AapiServiceResponse(CallStatus.succeeded);
List al = new ArrayList(Arrays.asList(ontologifiedServer.getControlledLamps())); | ||
| File | Project | Line |
|---|---|---|
| org/universAAL/lddi/samples/activityhub/client/ActivityHubClient.java | universAAL Samples Activity Hub Client | 258 |
| org/universAAL/lddi/samples/device/client/DeviceClient.java | universAAL Samples Device Client | 258 |
}
/**
* send all text lines from the given array to addTextToDeviceArea
*
* @param multiple
* text lines for 1 device info response
*/
public void showDeviceInfo(String[] listData) {
for (String line : listData) {
addTextToDeviceArea(line);
}
}
/**
* Helper class that displays the given text on the deviceInfoArea on the
* GUI adding a line break and set focus always to the bottom of the
* textArea
*
* @param text
*/
public void addTextToDeviceArea(String text) {
deviceInfoArea.setText(deviceInfoArea.getText() + text + "\n");
deviceInfoArea.setCaretPosition(deviceInfoArea.getDocument().getLength());
}
/**
* send all text lines from the given array to addTextToContextArea
*
* @param multiple
* text lines for 1 context event
*/
public void showContextEvent(String[] listData) {
for (String line : listData) {
addTextToContextArea(line);
}
}
/**
* Helper class that displays the given text on the contextArea on the GUI
* adding a line break and set focus always to the bottom of the textArea
*
* @param text
*/
public void addTextToContextArea(String text) {
contextArea.setText(contextArea.getText() + text + "\n");
contextArea.setCaretPosition(contextArea.getDocument().getLength());
}
/**
* Helper class that displays the given text on the logArea on the GUI
* adding a line break
*
* @param text
*/
public void addTextToLogArea(String text) {
logArea.setText(logArea.getText() + text + "\n");
}
/**
*
*/
public void deleteGui() {
frame.dispose();
}
} | ||
| File | Project | Line |
|---|---|---|
| org/universAAL/lddi/manager/gui/GUI.java | universAAL Samples LDDI Continua Manager Client (unix OS version) | 58 |
| org/universAAL/lddi/manager/win/gui/GUI.java | universAAL Samples LDDI Continua Manager Client (windows OS version) | 58 |
public class GUI extends JDialog implements ActionListener {
// Attributes
/** Serializable object */
private static final long serialVersionUID = 1L;
/** universAAL publisher window */
private JDialog publisher = null;
/** Main and secondary panels */
public static JPanel mainPanel = null;
private JPanel radiobuttonPanel = null;
private JPanel mainPublisherPanel = null;
/** Components */
private JRadioButton realMeasurementButton = null;
private JRadioButton simulatedMeasurementButton = null;
private ButtonGroup radioButtonsGroup = null;
private JButton bloodPressureButton = null;
private JButton weighingScaleButton = null;
private JLabel logoLabel = null;
private JLabel publisherMainLabel = null;
private JLabel publisherLogoLabel = null;
private JLabel publisherWeightValueLabel = null;
public static JTextField publisherWeightValueTextfield = null;
private JLabel publisherWeightUnitLabel = null;
public static JTextField publisherWeightUnitTextfield = null;
private JLabel publisherBloodPressureSysValueLabel = null;
public static JTextField publisherBloodPressureSysValueTextfield = null;
private JLabel publisherBloodPressureDiaValueLabel = null;
public static JTextField publisherBloodPressureDiaValueTextfield = null;
private JLabel publisherBloodPressurePulValueLabel = null;
public static JTextField publisherBloodPressurePulValueTextfield = null;
private JButton publisherButton = null;
/** Constants */
private static final String weighingScaleImage = "ws.png";
private static final String bloodPressureImage = "bp.png";
private static final String logoImage = "uaal_logo_resized.jpg";
/** Bundle context object */
private BundleContext ctx = null; | ||
| File | Project | Line |
|---|---|---|
| org/universAAL/lddi/manager/publisher/hdpManager.java | universAAL Samples LDDI Continua Manager Client (unix OS version) | 435 |
| org/universAAL/lddi/weighingscale/publisher/hdpManager.java | universAAL Samples LDDI Weighing scale agent publisher | 421 |
showHDPDataChannelProperties(hdpDataChannelPath);
// We need a valid file descriptor prior sending or receiving
// data bytes between managers and agents. If the file
// descriptor getted is not
// valid a -1 value will be returned
hdpDataChannelFileDescriptor = getHDPDataChannelFileDescriptor(hdpDataChannelPath);
System.out.println("Number of file descriptor: " + hdpDataChannelFileDescriptor);
// Notify the connection to the FSM of the Manager
fsm = x73manager.getFSM();
fsm.transportActivate();
System.out.println(fsm.getStringTransportState());
// Wait until right HDP data frame will be available in our
// assigned file descriptor
waitHDPDataFrames(hdpDataChannelFileDescriptor);
} else
System.out.println("HDP channel not available");
}
}
/* HDP data received */
public void onDataReceived() {
// Show the received data frame (each byte in hex mode)
showHDPDataFrame(hdpDataChannelFileDescriptor);
// Get the number of bytes read (size of the buffer array with VALID
// data)
int numberBytes = getSizeHDPDataFrame(hdpDataChannelFileDescriptor);
System.out.println("Number of bytes received (call from native code): " + numberBytes);
// Get the input data frame as a whole
hdpReceivedDataFrame = getHDPDataFrame(hdpDataChannelFileDescriptor);
System.out.println("Number of bytes received (call from JAVA): " + hdpReceivedDataFrame.length);
System.out.println("Answering agent data frames");
rmp = x73manager.getMessageProcessor();
byte[] response = x73manager.getAPDU(hdpReceivedDataFrame);
sendHDPDataToDevice(hdpDataChannelFileDescriptor, response);
if (fsm.getStringChannelState().equals("ASSOCIATED - OPERATING")) {
if (remoteDeviceType.equals("BloodPressureMonitor")) { | ||
| File | Project | Line |
|---|---|---|
| org/universAAL/tutorials/service/bus/callee/MyServiceCallee.java | universAAL Tutorials Service Bus Callee | 40 |
| org/universAAL/tutorials/service/bus/tryout/MyServiceCallee.java | universAAL Tutorials Service Bus Tryout | 38 |
public class MyServiceCallee extends ServiceCallee {
// URI for the service
public static String SERVICE_TURN_ON = "urn:org.universAAL.tutorial:tut.callee#srvTurnOn";
// URI for an input parameter: we expect the URI of a LightActuator as a
// parameter identified by this URI
public static String INPUT_LIGHT_URI = "urn:org.universAAL.tutorial:tut.callee#inLampURI";
/**
* Create the service profile that describes what the service does.
*
* @return an array of service profiles.
*/
public static ServiceProfile[] getProfiles() {
// Create a device service. Subclasses of the class 'Service' are our
// 'entry points' in the ontology. Starting from this class we go along
// some property path and describe what we do, return, or expect at that
// path.
// A service can
// - do something: add, change, or remove a property
// - return something
// - expect something: an input parameter that the caller has to provide
// In this tutorial, we create a service that can turn on a light
// source (= setting the value of a LightActuator to 100%)
Service turnOn = new DeviceService(SERVICE_TURN_ON);
// We add a filtering input: at the path 'controls' we expect exactly
// one parameter of type LightActuator. When the service is called, we
// can query this parameter with the URI 'INPUT_LIGHT_URI'
turnOn.addFilteringInput(INPUT_LIGHT_URI, LightActuator.MY_URI, 1, 1,
new String[] { DeviceService.PROP_CONTROLS });
// We add a change effect: at the path 'controls-hasValue' the service
// can change the value to 100
turnOn.getProfile().addChangeEffect(new String[] { DeviceService.PROP_CONTROLS, ValueDevice.PROP_HAS_VALUE },
new Integer(100));
// We can create more profiles here and return everything in an array.
// Please note that there is a difference between
// - registering one calle with multiple profiles, and
// - registering multiple callees, each with one profile
// See also the section on service bus details in the Wiki
return new ServiceProfile[] { turnOn.getProfile() };
}
public MyServiceCallee(ModuleContext context) {
// The constructor register us to the service bus for some profiles
super(context, getProfiles());
}
/** @see ServiceCallee#handleCall(ServiceCall) */
public ServiceResponse handleCall(ServiceCall call) {
// If we have registered multiple profiles, we can distinguish the
// service by comparing the service URI with the process URI
String operation = call.getProcessURI();
if (operation.startsWith(SERVICE_TURN_ON)) {
// Get the parameter
Object input = call.getInputValue(INPUT_LIGHT_URI); | ||
| File | Project | Line |
|---|---|---|
| org/universAAL/tutorials/context/bus/subscriber/MyContextSubscriber.java | universAAL Tutorials Context Bus Subscriber | 46 |
| org/universAAL/tutorials/context/bus/subscriber/MyContextSubscriber.java | universAAL Tutorials Context Bus Tryout | 50 |
public static ContextEventPattern[] getContextSubscriptionParams() {
// I am interested in all events that the brightness of a light source
// has changed. According to the device ontology the event describes a
// triple of the form:
// LightActuator hasValue x
// We start with a general context event pattern that we will restrict
// further in the following lines..
ContextEventPattern cep = new ContextEventPattern();
// The subject of the event must be of type LightActuator
cep.addRestriction(
MergedRestriction.getAllValuesRestriction(ContextEvent.PROP_RDF_SUBJECT, LightActuator.MY_URI));
// The predicate of the event must be the value
// ValueDevice.PROP_HAS_VALUE
cep.addRestriction(MergedRestriction.getFixedValueRestriction(ContextEvent.PROP_RDF_PREDICATE,
ValueDevice.PROP_HAS_VALUE));
// We can create more patterns here and return everything in an array.
return new ContextEventPattern[] { cep };
}
public MyContextSubscriber(ModuleContext context) {
// The constructor register us to the context bus for some context event
// patterns.
super(context, getContextSubscriptionParams());
}
/** @see ContextSubscriber#handleContextEvent(ContextEvent) */
public void handleContextEvent(ContextEvent event) {
// This method is called when the desired context event is published by
// a context publisher. In this example, we simply log the event and its
// content.
LogUtils.logInfo(Activator.mc, MyContextSubscriber.class, "handleContextEvent",
new Object[] { "Received context event:\n", " Subject = ", event.getSubjectURI(), "\n",
" Subject type= ", event.getSubjectTypeURI(), "\n", " Predicate = ",
event.getRDFPredicate(), "\n", " Object = ", event.getRDFObject() },
null); | ||
| File | Project | Line |
|---|---|---|
| org/universAAL/samples/servbus/GUIPanel.java | universAAL Samples Service bus tester | 132 |
| org/universAAL/samples/servbus/GUIPanel.java | universAAL Samples Service bus tester | 182 |
private void sendButton1ActionPerformed(ActionEvent evt) {
this.label1p1.setText("Delay: ");
int siz = 0;
try {
siz = Integer.parseInt(this.text1p1.getText());
} catch (Exception e) {
this.label1p1.setText("Invalid size of burst");
return;
}
ServiceRequest srq = null;
switch (this.combo1p1.getSelectedIndex()) {
case 0:
srq = getGETLAMPSrequest();
break;
case 1:
srq = getGETLAMPINFOrequest();
break;
case 2:
srq = getSETreqest(100);
break;
case 3:
srq = getSETreqest(0);
break;
case 4:
srq = getSETreqest(50);
break;
default:
break;
}
long t0 = System.currentTimeMillis();
for (int i = 0; i < siz; i++) { | ||
| File | Project | Line |
|---|---|---|
| org/universAAL/samples/ctxtbus/CPublisher.java | universAAL Samples Context bus tester for Android | 64 |
| org/universAAL/samples/ctxtbus/CPublisher.java | universAAL Samples Context bus tester | 65 |
ContextProvider cpinfo = new ContextProvider(URIROOT + "TestMassAndContextProvider");
cpinfo.setType(ContextProviderType.gauge);
cpinfo.setProvidedEvents(new ContextEventPattern[] { new ContextEventPattern() });
return cpinfo;
}
public void communicationChannelBroken() {
// TODO Auto-generated method stub
}
public long sendBurst(int size) {
Random r = new Random();
long t0 = System.currentTimeMillis();
for (int i = 0; i < size; i++) {
this.publish(sampleEvents[r.nextInt(samples)]);
}
long t1 = System.currentTimeMillis();
return t1 - t0;
}
// to send burst of event with unique URIs (for CHe)
// may introduce more delay
public long sendUniqueBurst(int size) {
Random r = new Random();
long t0 = System.currentTimeMillis();
for (int i = 0; i < size; i++) { | ||
| File | Project | Line |
|---|---|---|
| org/universAAL/ontology/lighting/simple/LightingInterface.java | universAAL Samples AAPI Simplified Lighting Ontology | 48 |
| org/universAAL/ontology/lighting/simple/LightingInterfaceLevel1.java | universAAL Samples AAPI Simplified Lighting Ontology | 50 |
Resource.VOCABULARY_NAMESPACE + "hasLocation" }) })
public Object[] getLampInfo(@Input(name = "lampURI", propertyPaths = { Lighting.PROP_CONTROLS }) LightSource lamp);
@ServiceOperation
@ChangeEffect(propertyPaths = { Lighting.PROP_CONTROLS,
LightSource.PROP_SOURCE_BRIGHTNESS }, value = "0", valueType = Integer.class)
public void turnOff(@Input(name = "lampURI", propertyPaths = { Lighting.PROP_CONTROLS }) LightSource lamp);
@ServiceOperation
@ChangeEffect(propertyPaths = { Lighting.PROP_CONTROLS,
LightSource.PROP_SOURCE_BRIGHTNESS }, value = "100", valueType = Integer.class)
public void turnOn(@Input(name = "lampURI", propertyPaths = { Lighting.PROP_CONTROLS }) LightSource lamp);
} | ||
| File | Project | Line |
|---|---|---|
| org/universAAL/lddi/samples/activityhub/client/ActivityHubClient.java | universAAL Samples Activity Hub Client | 65 |
| org/universAAL/lddi/samples/device/client/DeviceClient.java | universAAL Samples Device Client | 61 |
private Activator myParent;
private static JFrame frame;
private static ListModel jListModel = new DefaultComboBoxModel(new Object[] { "Init..." });
static private JList jList1 = new JList(jListModel);
private static JScrollPane jsp0 = new JScrollPane(jList1);
// private static JTextArea deviceArea = new JTextArea();
private static JTextArea deviceInfoArea = new JTextArea();
private static JScrollPane jsp1 = new JScrollPane(deviceInfoArea);
private static JTextArea contextArea = new JTextArea();
private static JScrollPane jsp2 = new JScrollPane(contextArea);
private static JTextArea logArea = new JTextArea();
private static JScrollPane jsp3 = new JScrollPane(logArea);
private static JLabel label1;
private static JLabel label2;
private static JLabel label3;
private static JLabel label4;
private JButton infoButton; | ||
| File | Project | Line |
|---|---|---|
| org/universAAL/lddi/manager/gui/GUI.java | universAAL Samples LDDI Continua Manager Client (unix OS version) | 131 |
| org/universAAL/lddi/manager/win/gui/GUI.java | universAAL Samples LDDI Continua Manager Client (windows OS version) | 131 |
setBounds(100, 100, 450, 325);
setTitle("universAAL Continua manager client");
getContentPane().setLayout(new BorderLayout());
// Main panel (content pane)
mainPanel = createJPanel();
getContentPane().add(mainPanel, BorderLayout.CENTER);
// Create and add components
createComponents();
// Show
setVisible(true);
}
/** Create components */
public void createComponents() {
// Label (universAAL image icon)
logoLabel = new JLabel("");
logoLabel.setIcon(new ImageIcon(ctx.getBundle().getResource(logoImage)));
logoLabel.setBounds(75, 10, 300, 81);
mainPanel.add(logoLabel);
// Radio buttons group
radiobuttonPanel = new JPanel();
radiobuttonPanel.setLayout(new GridLayout(1, 0));
radiobuttonPanel.setBounds(20, 100, 400, 50); | ||
| File | Project | Line |
|---|---|---|
| org/universAAL/lddi/samples/activityhub/client/MyActivityHubContextListener.java | universAAL Samples Activity Hub Client | 93 |
| org/universAAL/lddi/samples/device/client/DeviceContextListener.java | universAAL Samples Device Client | 92 |
LogUtils.logInfo(Activator.mc, MyActivityHubContextListener.class, "handleContextEvent",
new Object[] { "\n*****************************\n", "Received context event:\n", " Subject = ",
event.getSubjectURI(), "\n", " Subject type= ", event.getSubjectTypeURI(), "\n",
" Predicate = ", event.getRDFPredicate(), "\n", " Object = ",
event.getRDFObject() },
null);
String[] log = new String[] {
"************ Last received context event: " + dfm.format(new Date(System.currentTimeMillis())),
" Subject = " + event.getSubjectURI(), " Subject type= " + event.getSubjectTypeURI(),
" Predicate = " + event.getRDFPredicate(), " Object = " + event.getRDFObject() };
this.ahc.showContextEvent(log); | ||
| File | Project | Line |
|---|---|---|
| org/universAAL/lddi/samples/activityhub/client/ActivityHubClient.java | universAAL Samples Activity Hub Client | 92 |
| org/universAAL/lddi/samples/device/client/DeviceClient.java | universAAL Samples Device Client | 92 |
public ActivityHubClient(Activator parent) {
super();
this.myParent = parent;
initGUI();
start();
}
private void initGUI() {
try {
setPreferredSize(new Dimension(1000, 800));
this.setLayout(null);
} catch (Exception e) {
e.printStackTrace();
}
}
// create the GUI
public void start() {
frame = new JFrame();
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); // doesn't
// stop
// the
// whole
// framework
// on
// close
frame.pack();
frame.setSize(1000, 800);
frame.setVisible(true);
frame.getContentPane().setLayout(null);
frame.setTitle("ActivityHub Client Example"); | ||
| File | Project | Line |
|---|---|---|
| org/universAAL/samples/ctxtbus/ProfileCaller.java | universAAL Samples Context bus tester | 519 |
| org/universAAL/samples/ctxtbus/ProfileCaller.java | universAAL Samples Context bus tester | 547 |
Profile.PROP_HAS_SUB_PROFILE }, PersonalInformationSubprofile.MY_URI);
req.addRequiredOutput(OUTPUT_GETSUBPROFILES, new String[] { ProfilingService.PROP_CONTROLS,
Profilable.PROP_HAS_PROFILE, Profile.PROP_HAS_SUB_PROFILE });
ServiceResponse resp = caller.call(req);
if (resp.getCallStatus() == CallStatus.succeeded) {
// Object
// out=getReturnValue(resp.getOutputs(),OUTPUT_GETSUBPROFILES);
Object out = resp.getOutput(OUTPUT_GETSUBPROFILES, true);
if (out != null) {
log.debug(out.toString());
return out.toString();
} else {
log.debug("NOTHING!");
return "nothing";
}
} else {
return resp.getCallStatus().name();
}
}
private String getSubprofiles(UserProfile profile) { | ||
| File | Project | Line |
|---|---|---|
| org/universAAL/samples/ctxtbus/ProfileCaller.java | universAAL Samples Context bus tester | 368 |
| org/universAAL/samples/ctxtbus/ProfileCaller.java | universAAL Samples Context bus tester | 489 |
req.addValueFilter(new String[] { ProfilingService.PROP_CONTROLS, Profilable.PROP_HAS_PROFILE }, profile);
req.addRequiredOutput(OUTPUT_GETPROFILE,
new String[] { ProfilingService.PROP_CONTROLS, Profilable.PROP_HAS_PROFILE });
ServiceResponse resp = caller.call(req);
if (resp.getCallStatus() == CallStatus.succeeded) {
// Object out=getReturnValue(resp.getOutputs(),OUTPUT_GETPROFILE);
Object out = resp.getOutput(OUTPUT_GETPROFILE, true);
if (out != null) {
log.debug(out.toString());
return out.toString();
} else {
log.debug("NOTHING!");
return "nothing";
}
} else {
return resp.getCallStatus().name();
}
}
// :::::::::::::SUBPROFILE GET/ADD/CHANGE/REMOVE:::::::::::::::::
private String removeSubProfile(SubProfile profile) { | ||
| File | Project | Line |
|---|---|---|
| org/universAAL/samples/ctxtbus/SpaceCaller.java | universAAL Samples Context bus tester | 553 |
| org/universAAL/samples/ctxtbus/SpaceCaller.java | universAAL Samples Context bus tester | 591 |
req.addValueFilter(new String[] { ProfilingService.PROP_CONTROLS }, service);
req.addRequiredOutput(OUTPUT, new String[] { ProfilingService.PROP_CONTROLS, Profilable.PROP_HAS_PROFILE });
ServiceResponse resp = caller.call(req);
if (resp.getCallStatus() == CallStatus.succeeded) {
// Object out=getReturnValue(resp.getOutputs(),OUTPUT);
Object out = resp.getOutput(OUTPUT, true);
if (out != null) {
log.debug(out.toString());
return out.toString();
} else {
log.debug("NOTHING!");
return "nothing";
}
} else {
return resp.getCallStatus().name();
}
}
private String addServprofToServ(AppService service, AppServiceProfile serviceProfile) { | ||
| File | Project | Line |
|---|---|---|
| org/universAAL/samples/context/reasoner/client/gui/QueryCreatorFrame.java | universAAL Samples Context Situation Reasoner Test Client | 265 |
| org/universAAL/samples/context/reasoner/client/gui/RuleCreatorFrame.java | universAAL Samples Context Situation Reasoner Test Client | 150 |
c.weightx = 1.0;
c.fill = GridBagConstraints.HORIZONTAL;
Box footerBox = Box.createHorizontalBox();
this.getContentPane().add(footerBox, c);
footerBox.add(Box.createHorizontalGlue());
saveCheck = new JCheckBox("Save permanent: ");
saveCheck.setSelected(true);
footerBox.add(saveCheck);
footerBox.add(Box.createHorizontalStrut(50));
JButton addButton = new JButton("Add");
addButton.setPreferredSize(new Dimension(80, 30));
addButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { | ||
| File | Project | Line |
|---|---|---|
| org/universAAL/samples/ctxtbus/ProfileCaller.java | universAAL Samples Context bus tester | 237 |
| org/universAAL/samples/ctxtbus/ProfileCaller.java | universAAL Samples Context bus tester | 520 |
| org/universAAL/samples/ctxtbus/ProfileCaller.java | universAAL Samples Context bus tester | 548 |
req.addSimpleOutputBinding(po, new String[] { ProfilingService.PROP_CONTROLS, Profilable.PROP_HAS_PROFILE,
Profile.PROP_HAS_SUB_PROFILE });
ServiceResponse resp = caller.call(req);
if (resp.getCallStatus() == CallStatus.succeeded) {
// Object
// out=getReturnValue(resp.getOutputs(),OUTPUT_GETSUBPROFILES);
Object out = resp.getOutput(OUTPUT_GETSUBPROFILES, true);
if (out != null) {
log.debug(out.toString());
return out.toString();
} else {
log.debug("NOTHING!");
return "nothing";
}
} else {
return resp.getCallStatus().name();
}
}
// :::::::::::::PROFILABLE GET/ADD/CHANGE/REMOVE:::::::::::::::::
private String removeProfilable(Resource profilable) { | ||