Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
N
node-bigstream
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bs
node-bigstream
Commits
221e9b4e
Commit
221e9b4e
authored
Mar 11, 2017
by
project
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
a02953f6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
125 additions
and
116 deletions
+125
-116
image_parser.js
plugins/dt/dt-agritronics/parser/image_parser.js
+42
-51
simple_parser.js
plugins/dt/dt-agritronics/parser/simple_parser.js
+14
-15
wind_direction_parser.js
plugins/dt/dt-agritronics/parser/wind_direction_parser.js
+13
-15
perform.js
plugins/dt/dt-agritronics/perform.js
+56
-35
No files found.
plugins/dt/dt-agritronics/parser/image_parser.js
View file @
221e9b4e
...
...
@@ -15,62 +15,53 @@ exports.getValues = function(dataSet, cb){
let
values
=
[];
//console.log(dataSet.length);
var
i
=
0
;
async
.
whilst
(
function
()
{
return
i
<
dataSet
.
length
;},
function
(
callbackFn
)
{
let
json
=
parser
.
toJson
(
dataSet
[
i
],
{
object
:
true
});
i
++
;
dataTemplate
.
type
=
json
.
xhr
.
IO
.
Type
;
dataTemplate
.
unit
=
json
.
xhr
.
IO
.
Unit
;
dataTemplate
.
value_type
=
json
.
xhr
.
IO
.
ValueType
;
dataTemplate
.
image_type
=
json
.
xhr
.
IO
.
Name
;
let
json
=
parser
.
toJson
(
dataSet
,
{
object
:
true
});
if
(
parseInt
(
json
.
xhr
.
IO
.
Record
)
>
0
){
if
(
parseInt
(
json
.
xhr
.
IO
.
Record
)
===
1
){
getImage
(
json
.
xhr
.
IO
.
Data
.
Value
).
then
((
data
)
=>
{
values
.
push
({
"observeddatetime"
:
json
.
xhr
.
IO
.
Data
.
IODateTime
,
"value"
:
data
});
}).
catch
((
err
)
=>
{
cb
(
err
);
})
callbackFn
();
}
else
{
var
idx
=
0
;
async
.
whilst
(
function
()
{
return
idx
<
json
.
xhr
.
IO
.
Data
.
length
;},
function
(
callback
)
{
let
d
=
json
.
xhr
.
IO
.
Data
[
idx
];
idx
++
;
//console.log(d.Value);
getImage
(
d
.
Value
).
then
((
data
)
=>
{
values
.
push
({
"observeddatetime"
:
d
.
IODateTime
,
"value"
:
data
});
//var bitmap = new Buffer(data, 'base64');
//fs.writeFileSync("./result.jpg", bitmap);
callback
();
}).
catch
((
err
)
=>
{
callback
(
err
);
});
dataTemplate
.
type
=
json
.
xhr
.
IO
.
Type
;
dataTemplate
.
unit
=
json
.
xhr
.
IO
.
Unit
;
dataTemplate
.
value_type
=
json
.
xhr
.
IO
.
ValueType
;
dataTemplate
.
image_type
=
json
.
xhr
.
IO
.
Name
;
},
function
(
err
)
{
if
(
err
)
{
console
.
log
(
err
);
}
callbackFn
();
});
}
if
(
parseInt
(
json
.
xhr
.
IO
.
Record
)
>
0
){
if
(
parseInt
(
json
.
xhr
.
IO
.
Record
)
===
1
){
getImage
(
json
.
xhr
.
IO
.
Data
.
Value
).
then
((
data
)
=>
{
values
.
push
({
"observeddatetime"
:
json
.
xhr
.
IO
.
Data
.
IODateTime
,
"value"
:
data
});
}).
catch
((
err
)
=>
{
cb
(
err
);
})
}
else
callbackFn
();
else
{
var
idx
=
0
;
async
.
whilst
(
function
()
{
return
idx
<
json
.
xhr
.
IO
.
Data
.
length
;},
function
(
callback
)
{
let
d
=
json
.
xhr
.
IO
.
Data
[
idx
];
idx
++
;
//console.log(d.Value);
getImage
(
d
.
Value
).
then
((
data
)
=>
{
values
.
push
({
"observeddatetime"
:
d
.
IODateTime
,
"value"
:
data
});
//var bitmap = new Buffer(data, 'base64');
//fs.writeFileSync("./result.jpg", bitmap);
callback
();
}).
catch
((
err
)
=>
{
callback
(
err
);
});
},
function
(
err
)
{
if
(
err
)
{
console
.
log
(
err
);
}
else
{
if
(
values
.
length
>
0
){
dataTemplate
.
values
=
values
;
cb
(
dataTemplate
);
}
else
cb
(
null
);
},
function
(
err
)
{
if
(
err
)
{
console
.
log
(
err
);
}
if
(
values
.
length
>
0
){
dataTemplate
.
values
=
values
;
cb
(
dataTemplate
);
}
else
cb
(
null
);
});
}
});
}
else
cb
(
null
);
...
...
plugins/dt/dt-agritronics/parser/simple_parser.js
View file @
221e9b4e
...
...
@@ -11,26 +11,25 @@ exports.getValues = function(dataSet, callback){
let
values
=
[];
for
(
var
i
=
0
;
i
<
dataSet
.
length
;
i
++
)
{
let
json
=
parser
.
toJson
(
dataSet
[
i
]
,
{
object
:
true
});
dataTemplate
.
type
=
json
.
xhr
.
IO
.
Type
;
dataTemplate
.
unit
=
json
.
xhr
.
IO
.
Unit
;
dataTemplate
.
value_type
=
json
.
xhr
.
IO
.
ValueType
;
let
json
=
parser
.
toJson
(
dataSet
,
{
object
:
true
});
dataTemplate
.
type
=
json
.
xhr
.
IO
.
Type
;
dataTemplate
.
unit
=
json
.
xhr
.
IO
.
Unit
;
dataTemplate
.
value_type
=
json
.
xhr
.
IO
.
ValueType
;
if
(
parseInt
(
json
.
xhr
.
IO
.
Record
)
>
0
){
if
(
parseInt
(
json
.
xhr
.
IO
.
Record
)
===
1
){
values
.
push
({
"observeddatetime"
:
json
.
xhr
.
IO
.
Data
.
IODateTime
,
"value"
:
json
.
xhr
.
IO
.
Data
.
Value
});
}
else
{
for
(
var
j
=
0
;
j
<
json
.
xhr
.
IO
.
Data
.
length
;
j
++
)
{
let
d
=
json
.
xhr
.
IO
.
Data
[
j
];
values
.
push
({
"observeddatetime"
:
d
.
IODateTime
,
"value"
:
d
.
Value
});
}
if
(
parseInt
(
json
.
xhr
.
IO
.
Record
)
>
0
){
if
(
parseInt
(
json
.
xhr
.
IO
.
Record
)
===
1
){
values
.
push
({
"observeddatetime"
:
json
.
xhr
.
IO
.
Data
.
IODateTime
,
"value"
:
json
.
xhr
.
IO
.
Data
.
Value
});
}
else
{
for
(
var
j
=
0
;
j
<
json
.
xhr
.
IO
.
Data
.
length
;
j
++
)
{
let
d
=
json
.
xhr
.
IO
.
Data
[
j
];
values
.
push
({
"observeddatetime"
:
d
.
IODateTime
,
"value"
:
d
.
Value
});
}
}
}
if
(
values
.
length
>
0
){
dataTemplate
.
values
=
values
;
...
...
plugins/dt/dt-agritronics/parser/wind_direction_parser.js
View file @
221e9b4e
...
...
@@ -12,24 +12,22 @@ exports.getValues = function(dataSet, callback){
let
values
=
[];
for
(
var
i
=
0
;
i
<
dataSet
.
length
;
i
++
)
{
let
json
=
parser
.
toJson
(
dataSet
[
i
],
{
object
:
true
});
dataTemplate
.
type
=
json
.
xhr
.
IO
.
Type
;
dataTemplate
.
unit
=
json
.
xhr
.
IO
.
Unit
;
dataTemplate
.
value_type
=
json
.
xhr
.
IO
.
ValueType
;
if
(
parseInt
(
json
.
xhr
.
IO
.
Record
)
>
0
){
if
(
parseInt
(
json
.
xhr
.
IO
.
Record
)
===
1
){
values
.
push
({
"observeddatetime"
:
json
.
xhr
.
IO
.
Data
.
IODateTime
,
"value"
:
json
.
xhr
.
IO
.
Data
.
Value
,
"direction"
:
json
.
xhr
.
IO
.
Data
.
Direction
});
}
else
{
for
(
var
j
=
0
;
j
<
json
.
xhr
.
IO
.
Data
.
length
;
j
++
)
{
let
d
=
json
.
xhr
.
IO
.
Data
[
j
];
values
.
push
({
"observeddatetime"
:
d
.
IODateTime
,
"value"
:
d
.
Value
,
"direction"
:
d
.
Direction
});
}
let
json
=
parser
.
toJson
(
dataSet
,
{
object
:
true
});
dataTemplate
.
type
=
json
.
xhr
.
IO
.
Type
;
dataTemplate
.
unit
=
json
.
xhr
.
IO
.
Unit
;
dataTemplate
.
value_type
=
json
.
xhr
.
IO
.
ValueType
;
if
(
parseInt
(
json
.
xhr
.
IO
.
Record
)
>
0
){
if
(
parseInt
(
json
.
xhr
.
IO
.
Record
)
===
1
){
values
.
push
({
"observeddatetime"
:
json
.
xhr
.
IO
.
Data
.
IODateTime
,
"value"
:
json
.
xhr
.
IO
.
Data
.
Value
,
"direction"
:
json
.
xhr
.
IO
.
Data
.
Direction
});
}
else
{
for
(
var
j
=
0
;
j
<
json
.
xhr
.
IO
.
Data
.
length
;
j
++
)
{
let
d
=
json
.
xhr
.
IO
.
Data
[
j
];
values
.
push
({
"observeddatetime"
:
d
.
IODateTime
,
"value"
:
d
.
Value
,
"direction"
:
d
.
Direction
});
}
}
}
if
(
values
.
length
>
0
){
dataTemplate
.
values
=
values
;
callback
(
dataTemplate
);
...
...
plugins/dt/dt-agritronics/perform.js
View file @
221e9b4e
...
...
@@ -13,23 +13,35 @@ function perform_function(context,request,response){
var
output_type
=
"object/sds"
;
var
di_data
=
request
.
data
;
let
idx
=
0
;
let
result
=
{
"object_type"
:
'iBitz'
,
"station_id"
:
di_data
.
station_id
,
"latitude"
:
""
,
"longitude"
:
""
,
"altitude"
:
""
,
"data"
:[]
};
let
out
=
[];
async
.
whilst
(
function
()
{
return
idx
<
di_data
.
data
.
length
;},
function
(
callback
)
{
let
dtype
=
di_data
.
data
[
idx
].
data_types
;
//console.log('[DT] di_data length = ' + di_data.data[idx].value.length);
if
(
typeof
di_data
.
data
[
idx
].
value
.
length
!==
"undefined"
){
//console.log('data = ' + di_data.data[idx].value[0]);
let
json
=
parser
.
toJson
(
di_data
.
data
[
idx
].
value
[
0
],
{
object
:
true
});
agriParser
.
getParser
(
json
.
xhr
.
IO
.
Type
).
getValues
(
di_data
.
data
[
idx
].
value
,
function
(
values
)
{
var
dataKeySeries
=
Object
.
keys
(
di_data
.
data
);
// for (var i = 0; i < dataKeySeries.length; i++) {
// console.log(di_data.data[dataKeySeries[i]]);
// }
let
i
=
0
;
async
.
whilst
(
function
()
{
return
i
<
dataKeySeries
.
length
;},
function
(
cb
)
{
let
result
=
{
"object_type"
:
'iBitz'
,
"station_id"
:
di_data
.
station_id
,
"latitude"
:
""
,
"longitude"
:
""
,
"altitude"
:
""
,
"data"
:[]
};
let
vals
=
di_data
.
data
[
dataKeySeries
[
i
]];
i
++
;
let
idx
=
0
;
async
.
whilst
(
function
()
{
return
idx
<
vals
.
length
;},
function
(
callback
)
{
let
dtype
=
vals
[
idx
].
data_types
;
//console.log('[DT] di_data length = ' + vals[idx].value.length);
let
json
=
parser
.
toJson
(
vals
[
idx
].
value
,
{
object
:
true
});
//console.log('Type = ' + json.xhr.IO.Type);
agriParser
.
getParser
(
json
.
xhr
.
IO
.
Type
).
getValues
(
vals
[
idx
].
value
,
function
(
values
)
{
//console.log('data = ' + vals[idx].value);
idx
++
;
if
(
values
!==
null
){
result
.
latitude
=
json
.
xhr
.
IO
.
Latitude
;
...
...
@@ -37,32 +49,41 @@ function perform_function(context,request,response){
result
.
data
.
push
(
values
);
//console.log(`STAMP : ${di_data.station_id}-${dtype} = `+ values.values[values.values.length-1].observeddatetime);
memstore
.
setItem
(
`
${
di_data
.
station_id
}
-
${
dtype
}
`
,
values
.
values
[
values
.
values
.
length
-
1
].
observeddatetime
,
(
err
)
=>
{
if
(
err
)
throw
err
;
callback
(
err
);
if
(
err
){
throw
err
;
callback
(
err
);
}
else
callback
();
});
}
else
callback
();
});
}
else
{
idx
++
;
callback
();
}
},
function
(
err
)
{
if
(
err
)
{
console
.
log
(
err
);
cb
(
err
);
//response.error(err);
}
else
{
if
(
result
.
data
.
length
>
0
){
out
.
push
(
result
);
}
cb
();
}
});
},
function
(
err
)
{
if
(
err
)
{
console
.
log
(
err
);
//response.error(err);
}
else
{
//fs.writeFileSync("./result.json", JSON.stringify(resul
t));
//console.log(JSON.stringify(resul
t));
if
(
result
.
data
.
length
>
0
)
response
.
success
(
resul
t
,
output_type
);
else
response
.
reject
();
}
});
if
(
err
)
{
console
.
log
(
err
);
//response.error(err);
}
else
{
//fs.writeFileSync("./result.json", JSON.stringify(ou
t));
//console.log(JSON.stringify(ou
t));
if
(
out
.
length
>
0
)
response
.
success
(
ou
t
,
output_type
);
else
response
.
reject
();
}
});
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment