Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
monitoring
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cylab
monitoring
Commits
bfadb42b
Commit
bfadb42b
authored
4 years ago
by
Jan Cantaert
Browse files
Options
Downloads
Patches
Plain Diff
Temper class + USBTemper class programmed (1st try)
parent
cf5df584
No related branches found
Branches containing commit
No related tags found
2 merge requests
!8
Fix TEMPer
,
!7
WIP: Multi CPU + Temper usb (not working yet)
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/Sensor/Temper.php
+12
-1
12 additions, 1 deletion
app/Sensor/Temper.php
app/Sensor/USBtemperature.php
+60
-0
60 additions, 0 deletions
app/Sensor/USBtemperature.php
app/Server.php
+2
-1
2 additions, 1 deletion
app/Server.php
with
74 additions
and
2 deletions
app/Sensor/Temper.php
+
12
−
1
View file @
bfadb42b
...
...
@@ -9,5 +9,16 @@ namespace App\Sensor;
*/
class
Temper
{
public
$value
=
""
;
//eg : T° value
public
$part1
=
""
;
//eg : 0a
public
$part2
=
""
;
//eg : 6c
public
$temp
=
array
();
//eg : [26,28]
public
function
conversion
()
{
$hexatemp
=
$this
->
part1
.
$this
->
part2
;
//eg : 0a6c
$decitemp
=
hexdec
(
$hexatemp
);
//eg : 2628
$this
->
temp
[
1
]
=
substr
(
$decitemp
,
0
,
-
2
);
//eg : 26
$this
->
temp
[
2
]
=
substr
(
$decitemp
,
-
2
);
//eg : 28
return
$this
->
temp
;
//T° is 26.28°C
}
}
This diff is collapsed.
Click to expand it.
app/Sensor/USBtemperature.php
0 → 100644
+
60
−
0
View file @
bfadb42b
<?php
namespace
App\Sensor
;
/**
* Description of USBTemperature
*
* @author helha
*/
class
USBtemperature
extends
\App\AbstractSensor
{
//get device responce (8 bytes) :
const
REGEXP
=
"^(80 80)\s*([A-z\/0-9]+) \s*([A-z\/0-9]+)/m"
;
public
function
report
()
{
$record
=
$this
->
getLastRecord
(
"TEMPer"
);
if
(
$record
==
null
)
{
return
"<p>No data available...</p>"
.
"<p>Maybe <code>TEMPer</code> is not installed.</p>"
.
"<p>You can install it following the tutorial on the Gitlab repository</p>"
;
}
$temper
=
self
::
parse
(
$record
[
'TEMPer'
]);
$return
=
"<p>Ambient temperature (USB TEMPer) : "
.
$temper
[
1
]
.
"."
.
$temper
[
2
]
.
" °C "
.
"</p>"
;
return
$return
;
}
public
function
status
()
{
$record
=
$this
->
getLastRecord
(
"TEMPer"
);
if
(
$record
==
null
)
{
return
self
::
STATUS_UNKNOWN
;
}
$all_status
=
[];
foreach
(
self
::
parse
(
$record
[
'TEMPer'
])
as
$USBTemp
)
{
/* @var $USBTemp Temper */
$status
=
self
::
STATUS_OK
;
if
(
$USBTemp
->
temperature
[
1
]
>
75
)
{
$status
=
self
::
STATUS_WARNING
;
}
$all_status
[]
=
$status
;
}
return
max
(
$all_status
);
}
public
static
function
parse
(
string
$string
)
{
$values
=
array
();
preg_match_all
(
self
::
REGEXP
,
$string
,
$values
);
//get 8 bytes response from TEMPerUSB device
$temperatures
=
array
();
$USBTemp
=
new
Temper
();
$USBTemp
->
part1
=
$values
[
2
];
$USBTemp
->
part2
=
$values
[
3
];
$temper
[]
=
$USBTemp
->
conversion
();
//1st element = integer part, 2th = decimal part
return
$temper
;
}
}
This diff is collapsed.
Click to expand it.
app/Server.php
+
2
−
1
View file @
bfadb42b
...
...
@@ -32,7 +32,8 @@ class Server extends Model
\App\Sensor\ClientVersion
::
class
,
\App\Sensor\Heartbeat
::
class
,
\App\Sensor\DiskEvolution
::
class
,
\App\Sensor\CPUtemperature
::
class
\App\Sensor\CPUtemperature
::
class
,
\App\Sensor\USBtemperature
::
class
];
public
function
__construct
(
array
$attributes
=
array
())
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment