Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
mp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vaclab
mp
Commits
f883f8c7
Commit
f883f8c7
authored
10 years ago
by
Rolf Niepraschk
Browse files
Options
Downloads
Patches
Plain Diff
erste Tests; erstes Herantasten ...
parent
22bf0523
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+1
-1
1 addition, 1 deletion
README.md
bin/mp
+159
-0
159 additions, 0 deletions
bin/mp
with
160 additions
and
1 deletion
README.md
+
1
−
1
View file @
f883f8c7
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
## Kommandozeilenprogramm »mp«
## Kommandozeilenprogramm »mp«
Erste Orientierung mit js-Programm
(»node«)
...
Erste Orientierung
en
mit js-Programm
»mp.js«
...
Rolf Niepraschk, August 2014
Rolf Niepraschk, August 2014
This diff is collapsed.
Click to expand it.
bin/mp
0 → 100755
+
159
−
0
View file @
f883f8c7
#!/usr/bin/env node
/*
Rolf Niepraschk, Rolf.Niepraschk@ptb.de, 2014-08-28
*/
var
util
=
require
(
'
util
'
);
var
http
=
require
(
'
http
'
);
var
HOST
=
'
localhost
'
;
var
HOST
=
'
e73462.berlin.ptb.de
'
;
var
MP_PORT
=
8001
;
var
COUCH_PORT
=
5984
;
var
POLLING
=
100
;
var
ALL_MP
=
'
mp_db/_design/dbmp/_view/mps
'
;
// http://localhost:5984/mp_db/_design/dbmp/_view/mps?key=%22CE3%22
var
mps
=
{};
function
inspect
(
o
)
{
return
util
.
inspect
(
o
,
{
depth
:
null
,
colors
:
true
}
);
}
function
httpreq
(
con
,
success
,
error
){
var
req
=
http
.
request
(
con
,
function
(
res
)
{
var
data
=
''
;
res
.
setEncoding
(
'
utf8
'
);
res
.
on
(
'
data
'
,
function
(
chunk
)
{
data
+=
chunk
;
});
res
.
on
(
'
end
'
,
function
()
{
success
(
JSON
.
parse
(
data
));
});
res
.
on
(
'
error
'
,
error
);
});
req
.
on
(
'
error
'
,
error
);
return
req
;
};
function
get
(
path
,
success
,
port
){
var
con
=
{
hostname
:
HOST
,
port
:
port
||
MP_PORT
,
path
:
'
/
'
+
path
,
method
:
'
GET
'
,
headers
:
{
'
Content-Type
'
:
'
application/json
'
}
};
///console.log(inspect(con));
///console.log('url: http://' + con.hostname + ':' + con.port + con.path);
httpreq
(
con
,
success
,
function
(
e
)
{
console
.
log
(
'
FEHLER:
'
+
e
);
}).
end
();
}
function
step_5
(){
console
.
log
(
'
ENDE ...
'
);
}
function
step_4
(
id
){
function
waitUntil
(
sw
,
clbk
)
{
get
(
id
+
'
/state/0
'
,
function
(
d
)
{
var
flag
=
true
;
for
(
var
ser
=
0
;
ser
<
d
.
length
;
ser
++
)
{
for
(
var
par
=
0
;
par
<
d
[
ser
].
length
;
par
++
)
{
if
(
sw
)
{
if
(
d
[
ser
][
par
]
!=
'
ready
'
)
flag
=
false
;
}
else
{
if
(
d
[
ser
][
par
]
==
'
ready
'
)
flag
=
false
;
}
if
(
!
flag
)
break
;
}
if
(
!
flag
)
break
;
}
if
(
flag
)
{
clbk
();
}
else
{
setTimeout
(
function
()
{
waitUntil
(
sw
,
clbk
);
},
POLLING
);
}
});
}
function
step_4b
(
clbk
)
{
get
(
id
+
'
/exchange
'
,
function
(
d
)
{
for
(
key
in
d
)
{
if
(
key
!=
'
start_time
'
&&
key
!=
'
run_time
'
)
{
console
.
log
(
key
+
'
:
\t
'
+
d
[
key
].
Value
.
value
+
'
'
+
d
[
key
].
Unit
.
value
);
}
}
clbk
();
});
}
function
step_4a
()
{
// unnötig; einfaches polling ausreichend.
waitUntil
(
true
,
function
()
{
// Warten bis 'ready'
console
.
log
(
'
==================================================
'
);
step_4b
(
function
()
{
waitUntil
(
false
,
function
()
{
// Warten bis nicht mehr 'ready'
step_4a
();
});
});
});
}
step_4a
();
}
function
step_3
(){
var
any
;
for
(
var
key
in
mps
)
{
if
(
mps
[
key
])
{
any
=
key
;
break
;
}
}
step_4
(
any
);
}
function
step_2
(){
var
idx
=
0
,
ids
=
Object
.
keys
(
mps
);
function
step_2a
()
{
if
(
idx
==
ids
.
length
)
step_3
();
else
{
get
(
ids
[
idx
]
+
'
/frame
'
,
function
(
data
)
{
var
activ
=
mps
[
ids
[
idx
]]
=
!
data
.
error
;
var
str
=
(
activ
)
?
'
aktiv
'
:
'
inaktiv
'
;
console
.
log
(
idx
+
'
:
'
+
str
);
idx
++
;
step_2a
();
});
}
}
step_2a
();
}
function
step_1
(){
get
(
ALL_MP
,
function
(
data
)
{
//console.log(inspect(data));
var
id
;
console
.
log
(
'
Messprogramme
\n
=============
'
);
for
(
var
i
=
0
;
i
<
data
.
rows
.
length
;
i
++
)
{
id
=
data
.
rows
[
i
].
id
;
mps
[
id
]
=
false
;
console
.
log
(
i
+
'
:
'
+
id
+
'
(
'
+
(
data
.
rows
[
i
].
key
||
'
???
'
)
+
'
)
'
);
console
.
log
(
'
\t
-->
'
+
data
.
rows
[
i
].
value
.
Description
);
}
step_2
();
},
COUCH_PORT
);
}
step_1
();
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