-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial work to support UPS reading This is the initial work to support readings from the UPS (duration). * Change device_type to seconds Rename the type field in a few spots so that the readings from synse contain `device_type="seconds"` and `device="duration"`, to match the output of the snmp plugin. * Update comment * Update comment
- Loading branch information
1 parent
f64f6f8
commit c35abab
Showing
4 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
version: 3 | ||
devices: | ||
- type: seconds | ||
context: | ||
model: emul8-ups | ||
instances: | ||
- info: Seconds on battery power | ||
data: | ||
id: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package devices | ||
|
||
import ( | ||
"github.com/vapor-ware/synse-emulator-plugin/pkg/utils" | ||
"github.com/vapor-ware/synse-sdk/v2/sdk" | ||
"github.com/vapor-ware/synse-sdk/v2/sdk/output" | ||
) | ||
|
||
// UPS is the handler for the emulated ups device. | ||
var UPS = sdk.DeviceHandler{ | ||
Name: "seconds", | ||
Read: secondsRead, | ||
Write: minMaxCurrentWrite, | ||
} | ||
|
||
// secondsRead is the read handler for the emulated ups device. | ||
func secondsRead(device *sdk.Device) ([]*output.Reading, error) { | ||
emitter := utils.GetEmitter(device.GetID()) | ||
ec, err := output.Seconds.MakeReading(emitter.Next()) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return []*output.Reading{ | ||
ec, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters