Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
IoT Platform
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IoT
IoT Platform
Commits
fe7a7210
Commit
fe7a7210
authored
6 months ago
by
Rodrigo Goncalves
Browse files
Options
Downloads
Patches
Plain Diff
Unit conversion for ingress from TikiWiki
parent
3056b8c3
No related branches found
No related tags found
2 merge requests
!23
Resolve "SI Units for Ingress data from TikiWiki"
,
!22
Resolve "Unstructured SmartDataContext storage"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ingress/app/command/tikiwiki/ImportCommand.php
+14
-8
14 additions, 8 deletions
ingress/app/command/tikiwiki/ImportCommand.php
ingress/app/services/smartdataapi/SmartDataUnits.php
+10
-0
10 additions, 0 deletions
ingress/app/services/smartdataapi/SmartDataUnits.php
with
24 additions
and
8 deletions
ingress/app/command/tikiwiki/ImportCommand.php
+
14
−
8
View file @
fe7a7210
...
...
@@ -7,6 +7,7 @@ use Exception;
use
Ingress\Command\BaseCommand
;
use
Ingress\Services\Logger
;
use
Ingress\Services\smartdataapi\SmartDataContextApiClient
;
use
Ingress\Services\smartdataapi\SmartDataUnits
;
use
Ingress\Services\tikiwiki\TikiWIkiConfig
;
use
Ingress\Services\tikiwiki\TikiWikiDB
;
...
...
@@ -118,8 +119,8 @@ class ImportCommand extends BaseCommand
];
private
static
function
convertKM
(
$value
)
{
//
TODO implement conversion to SI
return
[
"value"
=>
$value
];
//
Convert the kilometers values to meters
return
[
"value
I32
"
=>
$value
*
1000
,
"unit"
=>
SmartDataUnits
::
METER
];
}
private
static
function
convertOwnerCount
(
$value
)
{
...
...
@@ -127,13 +128,13 @@ class ImportCommand extends BaseCommand
}
private
static
function
convertDate
(
$value
)
{
//
TODO implement conversion to SI
return
[
"value"
=>
$value
];
//
Saves the epoch value as a time
return
[
"value
I64
"
=>
$value
,
"unit"
=>
SmartDataUnits
::
TIME
];
}
private
static
function
convertKMLiter
(
$value
)
{
//
TODO implement conversion
to
SI
return
[
"value"
=>
$value
];
//
Convert KM/L
to
M/L
return
[
"value
D32
"
=>
$value
,
"unit"
=>
SmartDataUnits
::
METER
];
}
private
static
function
convertValueMap
(
$value
,
$map
)
{
...
...
@@ -158,8 +159,13 @@ class ImportCommand extends BaseCommand
private
static
function
convertServiceFrequency
(
$key
,
$value
)
{
// TODO calculate frequency
return
[
"kind"
=>
$key
,
'internal'
=>
[
'value'
=>
$value
]];
$numericValue
=
preg_replace
(
'/\D/'
,
''
,
$value
);
if
(
str_contains
(
$value
,
"km"
))
{
return
[
"kind"
=>
$key
,
'internal'
=>
[
'unit'
=>
SmartDataUnits
::
METER
,
'valueI32'
=>
$numericValue
*
1000
]];
}
else
{
return
[
"kind"
=>
$key
,
'internal'
=>
[
'unit'
=>
SmartDataUnits
::
TIME
,
'valueI32'
=>
$numericValue
*
SmartDataUnits
::
MONTH_TO_TIME_MULTIPLIER
]];
}
}
private
static
function
persistMaintenanceReport
(
$tikiwikiid
,
$api
,
$data
)
...
...
This diff is collapsed.
Click to expand it.
ingress/app/services/smartdataapi/SmartDataUnits.php
0 → 100644
+
10
−
0
View file @
fe7a7210
<?php
namespace
Ingress\Services\smartdataapi
;
class
SmartDataUnits
{
public
const
METER
=
0x84964924
;
public
const
TIME
=
0x84925924
;
public
const
MONTH_TO_TIME_MULTIPLIER
=
1
*
30
*
24
*
3600
;
}
\ No newline at end of file
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