mirror of
https://github.com/antos-rde/antosdk-apps.git
synced 2024-12-26 04:08:21 +01:00
Add Jarvis monitoring
This commit is contained in:
parent
0841cbce77
commit
c5b9064764
17
JarvisControl/README.md
Normal file
17
JarvisControl/README.md
Normal file
@ -0,0 +1,17 @@
|
||||
# JarvisControl
|
||||
This is an example project, generated by AntOS Development Kit
|
||||
|
||||
## Howto
|
||||
Use the CodePad command palette to access to the SDK functionalities:
|
||||
|
||||
1. Create new project
|
||||
2. Init the project from the current folder located in side bar
|
||||
3. Build and run the project
|
||||
4. Release the project in zip package
|
||||
|
||||
## Set up build target
|
||||
|
||||
Open the `project.json` file from the current project tree and add/remove
|
||||
build target entries. Save the file
|
||||
|
||||
|
22
JarvisControl/assets/scheme.html
Normal file
22
JarvisControl/assets/scheme.html
Normal file
@ -0,0 +1,22 @@
|
||||
<afx-app-window apptitle="Jarvis monitoring" width="600" height="400" data-id="JarvisControl">
|
||||
<afx-vbox >
|
||||
<afx-hbox>
|
||||
<afx-vbox>
|
||||
<afx-label data-id="bat-text" data-height="22" text="__(Battery Usage:)"></afx-label>
|
||||
<div data-id="battery-area" class="epoch category10"></div>
|
||||
<afx-label data-id="temp-text" data-height="22" text="__(CPU temperature:)"></afx-label>
|
||||
<div data-id="temp-area" class="epoch category10" ></div>
|
||||
</afx-vbox>
|
||||
<afx-vbox data-width="160">
|
||||
<afx-label data-id="mem-text" data-height="22" text="__(Memory:)"></afx-label>
|
||||
<div data-height="90" data-id="mem-area" class="epoch gauge-tiny"></div>
|
||||
<afx-label data-id="disk-text" data-height="22" text="__(Disk:)"></afx-label>
|
||||
<div data-height="90" data-id="disk-area" class="epoch gauge-tiny" ></div>
|
||||
<afx-label data-id="cpu-text" data-height="22" text="__(CPU:)"></afx-label>
|
||||
<div data-height="90" data-id="cpu-area" class="epoch gauge-tiny" ></div>
|
||||
<div></div>
|
||||
</afx-vbox>
|
||||
</afx-hbox>
|
||||
|
||||
</afx-vbox>
|
||||
</afx-app-window>
|
17
JarvisControl/build/debug/README.md
Normal file
17
JarvisControl/build/debug/README.md
Normal file
@ -0,0 +1,17 @@
|
||||
# JarvisControl
|
||||
This is an example project, generated by AntOS Development Kit
|
||||
|
||||
## Howto
|
||||
Use the CodePad command palette to access to the SDK functionalities:
|
||||
|
||||
1. Create new project
|
||||
2. Init the project from the current folder located in side bar
|
||||
3. Build and run the project
|
||||
4. Release the project in zip package
|
||||
|
||||
## Set up build target
|
||||
|
||||
Open the `project.json` file from the current project tree and add/remove
|
||||
build target entries. Save the file
|
||||
|
||||
|
1495
JarvisControl/build/debug/main.css
Normal file
1495
JarvisControl/build/debug/main.css
Normal file
File diff suppressed because it is too large
Load Diff
1
JarvisControl/build/debug/main.js
Normal file
1
JarvisControl/build/debug/main.js
Normal file
File diff suppressed because one or more lines are too long
15
JarvisControl/build/debug/package.json
Normal file
15
JarvisControl/build/debug/package.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"pkgname": "JarvisControl",
|
||||
"app":"JarvisControl",
|
||||
"name":"JarvisControl",
|
||||
"description":"JarvisControl",
|
||||
"info":{
|
||||
"author": "",
|
||||
"email": ""
|
||||
},
|
||||
"version":"0.0.1-a",
|
||||
"category":"Other",
|
||||
"iconclass":"fa fa-android",
|
||||
"mimes":["none"],
|
||||
"locale": {}
|
||||
}
|
22
JarvisControl/build/debug/scheme.html
Normal file
22
JarvisControl/build/debug/scheme.html
Normal file
@ -0,0 +1,22 @@
|
||||
<afx-app-window apptitle="Jarvis monitoring" width="600" height="400" data-id="JarvisControl">
|
||||
<afx-vbox >
|
||||
<afx-hbox>
|
||||
<afx-vbox>
|
||||
<afx-label data-id="bat-text" data-height="22" text="__(Battery Usage:)"></afx-label>
|
||||
<div data-id="battery-area" class="epoch category10"></div>
|
||||
<afx-label data-id="temp-text" data-height="22" text="__(CPU temperature:)"></afx-label>
|
||||
<div data-id="temp-area" class="epoch category10" ></div>
|
||||
</afx-vbox>
|
||||
<afx-vbox data-width="160">
|
||||
<afx-label data-id="mem-text" data-height="22" text="__(Memory:)"></afx-label>
|
||||
<div data-height="90" data-id="mem-area" class="epoch gauge-tiny"></div>
|
||||
<afx-label data-id="disk-text" data-height="22" text="__(Disk:)"></afx-label>
|
||||
<div data-height="90" data-id="disk-area" class="epoch gauge-tiny" ></div>
|
||||
<afx-label data-id="cpu-text" data-height="22" text="__(CPU:)"></afx-label>
|
||||
<div data-height="90" data-id="cpu-area" class="epoch gauge-tiny" ></div>
|
||||
<div></div>
|
||||
</afx-vbox>
|
||||
</afx-hbox>
|
||||
|
||||
</afx-vbox>
|
||||
</afx-app-window>
|
BIN
JarvisControl/build/release/JarvisControl.zip
Normal file
BIN
JarvisControl/build/release/JarvisControl.zip
Normal file
Binary file not shown.
68
JarvisControl/coffees/JarvisService.coffee
Normal file
68
JarvisControl/coffees/JarvisService.coffee
Normal file
@ -0,0 +1,68 @@
|
||||
class JarvisService extends OS.application.BaseService
|
||||
constructor: (args) ->
|
||||
super "JarvisService", args
|
||||
@text = __("Jarvis({0}%)", 0.toString())
|
||||
@iconclass = "fa fa-android"
|
||||
|
||||
@nodes = [
|
||||
{text: __("Status"), id: 1},
|
||||
{text: __("Exit"), id: 2}
|
||||
]
|
||||
@onchildselect = (e) => @action e
|
||||
|
||||
init: () ->
|
||||
checklib = () =>
|
||||
if not Antunnel.tunnel
|
||||
@error __("The Antunnel service is not started, please start it first")
|
||||
@_gui.pushService("Antunnel/AntunnelService")
|
||||
.catch (e) =>
|
||||
@error e.toString(), e
|
||||
@quit()
|
||||
else
|
||||
@tunnel = Antunnel.tunnel
|
||||
@sub = new Antunnel.Subscriber("notification")
|
||||
@sub.onopen = () =>
|
||||
#@sub.send Antunnel.Msg.DATA, new TextEncoder("utf-8").encode("Hello")
|
||||
console.log("Subscribed to notification channel")
|
||||
|
||||
@sub.onerror = (e) =>
|
||||
@error __("Error: {0}", new TextDecoder("utf-8").decode(e.data)), e
|
||||
#@sub = undefined
|
||||
|
||||
@sub.onmessage = (e) =>
|
||||
obj = JSON.parse(new TextDecoder("utf-8").decode(e.data)) if e.data
|
||||
# update the battery
|
||||
@text = __("Jarvis({0}%)", Math.round(obj.battery_percent).toString())
|
||||
@update()
|
||||
|
||||
@sub.onclose = () =>
|
||||
@sub = undefined
|
||||
@notify __("Unsubscribed to the notification service")
|
||||
@quit()
|
||||
Antunnel.tunnel.subscribe @sub
|
||||
|
||||
if not window.Antunnel
|
||||
console.log "require Antunnel"
|
||||
@_api.requires("pkg://Antunnel/main.js").then () =>
|
||||
checklib()
|
||||
.catch (e) =>
|
||||
@error __("Unable to load Antunnel: {0}",e.toString()), e
|
||||
@quit()
|
||||
else
|
||||
checklib()
|
||||
|
||||
|
||||
action: (e) ->
|
||||
switch e.data.item.data.id
|
||||
when 1
|
||||
@_gui.launch "JarvisControl", []
|
||||
when 2
|
||||
@quit()
|
||||
|
||||
awake: () ->
|
||||
|
||||
cleanup: () ->
|
||||
@sub.close() if @sub
|
||||
|
||||
|
||||
this.OS.register "JarvisService", JarvisService
|
99
JarvisControl/coffees/main.coffee
Normal file
99
JarvisControl/coffees/main.coffee
Normal file
@ -0,0 +1,99 @@
|
||||
|
||||
|
||||
class JarvisControl extends this.OS.application.BaseApplication
|
||||
constructor: ( args ) ->
|
||||
super "JarvisControl", args
|
||||
|
||||
main: () ->
|
||||
@batterychart = $(@find("battery-area")).epoch({
|
||||
type: 'time.line',
|
||||
axes: ['bottom', 'left', "right"],
|
||||
range: [2500, 4300]
|
||||
data: [{
|
||||
label: "Battery",
|
||||
values: []
|
||||
}]
|
||||
})
|
||||
@tempchart = $(@find("temp-area")).epoch({
|
||||
type: 'time.line',
|
||||
axes: ['bottom', 'left', "right"],
|
||||
range: [0, 100],
|
||||
data: [{
|
||||
label: "Temperature",
|
||||
values: []
|
||||
}]
|
||||
})
|
||||
@memchart = $(@find("mem-area")).epoch({
|
||||
type: 'time.gauge',
|
||||
value: 0
|
||||
})
|
||||
@diskchart = $(@find("disk-area")).epoch({
|
||||
type: 'time.gauge',
|
||||
value: 0
|
||||
})
|
||||
@cpuchart = $(@find("cpu-area")).epoch({
|
||||
type: 'time.gauge',
|
||||
value: 0
|
||||
})
|
||||
checklib = () =>
|
||||
if not Antunnel.tunnel
|
||||
@error __("The Antunnel service is not started, please start it first")
|
||||
.catch (e) =>
|
||||
@error e.toString(), e
|
||||
@quit()
|
||||
else
|
||||
@tunnel = Antunnel.tunnel
|
||||
@sub = new Antunnel.Subscriber("notification")
|
||||
@sub.onopen = () =>
|
||||
#@sub.send Antunnel.Msg.DATA, new TextEncoder("utf-8").encode("Hello")
|
||||
console.log("Subscribed to notification channel")
|
||||
@_gui.pushService("JarvisControl/JarvisService")
|
||||
|
||||
@sub.onerror = (e) =>
|
||||
@error __("Error: {0}", new TextDecoder("utf-8").decode(e.data)), e
|
||||
#@sub = undefined
|
||||
|
||||
@sub.onmessage = (e) =>
|
||||
obj = JSON.parse(new TextDecoder("utf-8").decode(e.data)) if e.data
|
||||
# update the battery
|
||||
@display obj
|
||||
|
||||
@sub.onclose = () =>
|
||||
@sub = undefined
|
||||
@notify __("Unsubscribed to the notification service")
|
||||
@quit()
|
||||
Antunnel.tunnel.subscribe @sub
|
||||
@on "resize", () =>
|
||||
el = @find("battery-area")
|
||||
@batterychart.option("width", $(el).width())
|
||||
@batterychart.option("height", $(el).height())
|
||||
el = @find("temp-area")
|
||||
@tempchart.option("width", $(el).width())
|
||||
@tempchart.option("height", $(el).height())
|
||||
checklib()
|
||||
|
||||
display: (data) ->
|
||||
mem_percent = parseFloat(data.mem.match(/([0-9\.]+)%/)[1])
|
||||
@memchart.push mem_percent / 100.0
|
||||
@find("mem-text").text = data.mem
|
||||
|
||||
disk_percent = parseFloat(data.disk.match(/([0-9\.]+)%/)[1])
|
||||
@diskchart.push disk_percent / 100.0
|
||||
@find("disk-text").text = data.disk
|
||||
|
||||
cpu_percent = parseFloat(data.cpu.match(/([0-9\.]+)$/)[1])
|
||||
@cpuchart.push cpu_percent / 100.0
|
||||
@find("cpu-text").text = data.cpu
|
||||
|
||||
@batterychart.push [{time: (new Date()).timestamp(), y: data.battery}]
|
||||
@find("bat-text").text = __("Battery Usage: {0} mv ({1}%)", data.battery, Math.round(data.battery_percent))
|
||||
|
||||
@tempchart.push [{time: (new Date()).timestamp(), y: data.temp}]
|
||||
@find("temp-text").text = __("CPU temperature: {0} C", data.temp)
|
||||
cleanup: () ->
|
||||
return unless @sub
|
||||
@sub.close()
|
||||
|
||||
JarvisControl.singleton = true
|
||||
|
||||
this.OS.register "JarvisControl", JarvisControl
|
1494
JarvisControl/css/epoch.css
Normal file
1494
JarvisControl/css/epoch.css
Normal file
File diff suppressed because it is too large
Load Diff
9554
JarvisControl/javascripts/d3.v3.js
vendored
Normal file
9554
JarvisControl/javascripts/d3.v3.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
18568
JarvisControl/javascripts/d3.v5.js
vendored
Normal file
18568
JarvisControl/javascripts/d3.v5.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
3924
JarvisControl/javascripts/epoch.js
Normal file
3924
JarvisControl/javascripts/epoch.js
Normal file
File diff suppressed because it is too large
Load Diff
15
JarvisControl/package.json
Normal file
15
JarvisControl/package.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"pkgname": "JarvisControl",
|
||||
"app":"JarvisControl",
|
||||
"name":"JarvisControl",
|
||||
"description":"JarvisControl",
|
||||
"info":{
|
||||
"author": "",
|
||||
"email": ""
|
||||
},
|
||||
"version":"0.0.1-a",
|
||||
"category":"Other",
|
||||
"iconclass":"fa fa-android",
|
||||
"mimes":["none"],
|
||||
"locale": {}
|
||||
}
|
8
JarvisControl/project.json
Normal file
8
JarvisControl/project.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "JarvisControl",
|
||||
"root": "home://workspace/antosdk-apps/JarvisControl",
|
||||
"css": ["css/epoch.css"],
|
||||
"javascripts": ["javascripts/d3.v3.js", "javascripts/epoch.js"],
|
||||
"coffees": ["coffees/JarvisService.coffee", "coffees/main.coffee"],
|
||||
"copies": ["assets/scheme.html", "package.json", "README.md"]
|
||||
}
|
@ -80,6 +80,15 @@
|
||||
"version": "0.0.5-a",
|
||||
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/GraphEditor/build/release/GraphEditor.zip"
|
||||
},
|
||||
{
|
||||
"pkgname": "JarvisControl",
|
||||
"name": "JarvisControl",
|
||||
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/JarvisControl/README.md",
|
||||
"category": "Other",
|
||||
"author": "",
|
||||
"version": "0.0.1-a",
|
||||
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/JarvisControl/build/release/JarvisControl.zip"
|
||||
},
|
||||
{
|
||||
"pkgname": "LuaPlayground",
|
||||
"name": "LuaPlayground",
|
||||
|
Loading…
Reference in New Issue
Block a user