Skip to content

Commit

Permalink
Merge pull request #1 from LucianRadul/roomControlAttempt
Browse files Browse the repository at this point in the history
Room control attempt
  • Loading branch information
TeodorLungu authored Dec 16, 2022
2 parents 064c3ea + 4039b88 commit b4e7877
Show file tree
Hide file tree
Showing 47 changed files with 731 additions and 436 deletions.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion leshan-client-cf/target/classes/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Manifest-Version: 1.0
Bnd-LastModified: 1670861529939
Bnd-LastModified: 1671049511996
Build-Jdk-Spec: 19
Bundle-Description: A transport implementation for leshan client based o
n CoAP Californium
Expand Down
Binary file modified leshan-client-cf/target/leshan-client-cf-2.0.0-SNAPSHOT.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion leshan-client-core/target/classes/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Manifest-Version: 1.0
Bnd-LastModified: 1670861529703
Bnd-LastModified: 1671049511731
Build-Jdk-Spec: 19
Bundle-Description: A LWM2M client implementation which abstracts transp
ort layer. A transport implementation like "leshan-client-cf" is needed
Expand Down
Binary file modified leshan-client-core/target/leshan-client-core-2.0.0-SNAPSHOT.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -42,95 +42,96 @@ public class DemandResponse extends BaseInstanceEnabler {
// Static values for resource items
private static final int RES_TOTAL_ALLOWED_PEAK_ROOM_POWER = 30005;
private static final List<Integer> supportedResources =
Arrays.asList(
RES_TOTAL_ALLOWED_PEAK_ROOM_POWER
);
Arrays.asList(
RES_TOTAL_ALLOWED_PEAK_ROOM_POWER
);
// Variables storing current values.

// 0..500
// 0..500
private int vTotalAllowedPeakRoomPower = 300;
private JLabel glTotalAllowedPeakRoomPower;
private JLabel gvTotalAllowedPeakRoomPower;
private JTextField tfTotalAllowedPeakRoomPower;
private JFrame guiFrame;

public DemandResponse() {
// Automatically generated GUI code.
guiFrame = new JFrame();
guiFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
guiFrame.setTitle("Demand Response");

// Total Allowed Peak Room Power
glTotalAllowedPeakRoomPower = new JLabel();
glTotalAllowedPeakRoomPower.setText("Total Allowed Peak Room Power");
gvTotalAllowedPeakRoomPower = new JLabel();
gvTotalAllowedPeakRoomPower.setText(Integer.toString(vTotalAllowedPeakRoomPower));
tfTotalAllowedPeakRoomPower = new JTextField();
tfTotalAllowedPeakRoomPower.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
String sValue = (String)tfTotalAllowedPeakRoomPower.getText();
setTotalAllowedPeakRoomPower(Integer.valueOf(sValue));
}
});

// Create layout of labels, inputs and values.
GridLayout layout = new GridLayout(0,3,10,10);
guiFrame.getContentPane().setLayout(layout);
Container guiPane = guiFrame.getContentPane();
guiPane.add(glTotalAllowedPeakRoomPower);
guiPane.add(tfTotalAllowedPeakRoomPower);
guiPane.add(gvTotalAllowedPeakRoomPower);
guiFrame.pack();
// Code to make the frame visible.
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
guiFrame.setVisible(true);
}
});
}

@Override
public synchronized ReadResponse read(ServerIdentity identity, int resourceId) {
switch (resourceId) {
case RES_TOTAL_ALLOWED_PEAK_ROOM_POWER:
return ReadResponse.success(resourceId, vTotalAllowedPeakRoomPower);
default:
return super.read(identity, resourceId);
private JLabel glTotalAllowedPeakRoomPower;
private JLabel gvTotalAllowedPeakRoomPower;
private JTextField tfTotalAllowedPeakRoomPower;
private JFrame guiFrame;

public DemandResponse() {
// Automatically generated GUI code.
guiFrame = new JFrame();
guiFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
guiFrame.setTitle("Demand Response");

// Total Allowed Peak Room Power
glTotalAllowedPeakRoomPower = new JLabel();
glTotalAllowedPeakRoomPower.setText("Total Allowed Peak Room Power");
gvTotalAllowedPeakRoomPower = new JLabel();
gvTotalAllowedPeakRoomPower.setText(Integer.toString(vTotalAllowedPeakRoomPower));
tfTotalAllowedPeakRoomPower = new JTextField();
tfTotalAllowedPeakRoomPower.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
String sValue = (String) tfTotalAllowedPeakRoomPower.getText();
setTotalAllowedPeakRoomPower(Integer.valueOf(sValue));
}
});

// Create layout of labels, inputs and values.
GridLayout layout = new GridLayout(0, 3, 10, 10);
guiFrame.getContentPane().setLayout(layout);
Container guiPane = guiFrame.getContentPane();
guiPane.add(glTotalAllowedPeakRoomPower);
guiPane.add(tfTotalAllowedPeakRoomPower);
guiPane.add(gvTotalAllowedPeakRoomPower);
guiFrame.pack();
// Code to make the frame visible.
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
guiFrame.setVisible(true);
}
});
}
}

@Override
public WriteResponse write(ServerIdentity identity, boolean replace, int resourceId, LwM2mResource value) {
switch (resourceId) {
default:
return super.write(identity, replace, resourceId,value);
@Override
public synchronized ReadResponse read(ServerIdentity identity, int resourceId) {
switch (resourceId) {
case RES_TOTAL_ALLOWED_PEAK_ROOM_POWER:
return ReadResponse.success(resourceId, vTotalAllowedPeakRoomPower);
default:
return super.read(identity, resourceId);
}
}
}

@Override
public synchronized ExecuteResponse execute(ServerIdentity identity, int resourceId, Arguments arguments) {
switch (resourceId) {
default:
return super.execute(identity, resourceId,arguments);
@Override
public WriteResponse write(ServerIdentity identity, boolean replace, int resourceId, LwM2mResource value) {
switch (resourceId) {
default:
return super.write(identity, replace, resourceId, value);
}
}
}

@Override
public List<Integer> getAvailableResourceIds(ObjectModel model) {
return supportedResources;
}

// Called before the object is registered, don't fire.
public void configure(int peakroompower) {
vTotalAllowedPeakRoomPower = peakroompower;
gvTotalAllowedPeakRoomPower.setText(Integer.toString(vTotalAllowedPeakRoomPower)); }

private synchronized void setTotalAllowedPeakRoomPower(int value) {
if (vTotalAllowedPeakRoomPower != value) {
vTotalAllowedPeakRoomPower = value;
gvTotalAllowedPeakRoomPower.setText(Integer.toString(vTotalAllowedPeakRoomPower));
fireResourceChange(RES_TOTAL_ALLOWED_PEAK_ROOM_POWER);

@Override
public synchronized ExecuteResponse execute(ServerIdentity identity, int resourceId, Arguments arguments) {
switch (resourceId) {
default:
return super.execute(identity, resourceId, arguments);
}
}

@Override
public List<Integer> getAvailableResourceIds(ObjectModel model) {
return supportedResources;
}

// Called before the object is registered, don't fire.
public void configure(int peakroompower) {
vTotalAllowedPeakRoomPower = peakroompower;
gvTotalAllowedPeakRoomPower.setText(Integer.toString(vTotalAllowedPeakRoomPower));
}

private synchronized void setTotalAllowedPeakRoomPower(int value) {
if (vTotalAllowedPeakRoomPower != value) {
vTotalAllowedPeakRoomPower = value;
gvTotalAllowedPeakRoomPower.setText(Integer.toString(vTotalAllowedPeakRoomPower));
fireResourceChange(RES_TOTAL_ALLOWED_PEAK_ROOM_POWER);
}
}
}

}
}
Loading

0 comments on commit b4e7877

Please sign in to comment.