Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
I3csstatus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Jiří Kalvoda
I3csstatus
Commits
52cc7843
Commit
52cc7843
authored
2 years ago
by
Jiří Kalvoda
Browse files
Options
Downloads
Patches
Plain Diff
Module: OBB speed and next_stop
parent
7550b6ac
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Parsers.cs
+44
-0
44 additions, 0 deletions
Parsers.cs
sample.conf
+23
-0
23 additions, 0 deletions
sample.conf
with
67 additions
and
0 deletions
Parsers.cs
+
44
−
0
View file @
52cc7843
...
@@ -386,3 +386,47 @@ class ParserCDNextStop: Parser
...
@@ -386,3 +386,47 @@ class ParserCDNextStop: Parser
}
}
#
pragma
warning
restore
8602
#
pragma
warning
restore
8602
}
}
[
ParserName
(
"OBB_speed"
)]
class
ParserOBBSpeed
:
Parser
{
#
pragma
warning
disable
8602
public
void
Init
(
ModuleParent
_bar
,
Module
_module
,
ConfigSection
section
)
{
}
public
IEnumerable
<
Block
>
Parse
(
string
data
)
{
return
new
Block
[]{
new
Block
(
$"
{
data
}
km/h"
,
Color
:
Color
.
White
)};
}
#
pragma
warning
restore
8602
}
[
ParserName
(
"OBB_next_stop"
)]
class
ParserOBBNextStop
:
Parser
{
#
pragma
warning
disable
8602
public
void
Init
(
ModuleParent
_bar
,
Module
_module
,
ConfigSection
section
)
{
}
public
IEnumerable
<
Block
>
Parse
(
string
data
)
{
try
{
JsonObject
json
=
JsonObject
.
Parse
(
data
).
AsObject
();
JsonObject
nextStop
=
json
[
"currentStation"
].
AsObject
();
string
nextStopName
=
nextStop
[
"name"
].
AsObject
()[
"all"
].
GetValue
<
string
>();
DateTime
nextStopArrival
=
DateTime
.
Parse
(
nextStop
.
AsObject
()[
"arrivalForecast"
]?.
GetValue
<
string
>());
DateTime
nextStopArrivalScheudled
=
DateTime
.
Parse
(
nextStop
.
AsObject
()[
"arrivalSchedule"
]?.
GetValue
<
string
>());
long
arrivalIn
=
(
long
)(
nextStopArrival
-
DateTime
.
Now
).
TotalSeconds
;
int
delay_s
=
(
int
)(
nextStopArrival
-
nextStopArrivalScheudled
).
TotalSeconds
;
string
delayStr
=
delay_s
==
0
?
""
:
$" (
{
TimeShow
.
WithSign
(
delay_s
)}
)"
;
return
new
Block
[]{
new
Block
(
$"
{
nextStopName
}
in
{
TimeShow
.
Show
(
arrivalIn
)}
"
+
delayStr
,
Color
:
Color
.
White
)};
}
catch
(
Exception
e
)
{
Console
.
Error
.
WriteLine
(
e
);
return
new
Block
[]{
new
Block
(
"OBB PE"
,
Color
:
Color
.
Red
)};
}
}
#
pragma
warning
restore
8602
}
This diff is collapsed.
Click to expand it.
sample.conf
+
23
−
0
View file @
52cc7843
...
@@ -441,3 +441,26 @@ period = 20
...
@@ -441,3 +441,26 @@ period = 20
show_old
=
60
show_old
=
60
max_old
=
300
max_old
=
300
_
exec
=
chromium
http
://
cdwifi
.
cz
_
exec
=
chromium
http
://
cdwifi
.
cz
# Parser: OBB_speed and OBB_next_stop
# -----------------------------------
# Show information about the speed or next stop and delay for Österreichische Bundesbahnen trains.
# Example usage:
[
OBB_speed
]
_
type
=
http
url
=
https
://
railnet
.
oebb
.
at
/
api
/
speed
period
=
5
show_old
=
20
max_old
=
120
error_handler
=
no_data_handler
=
_
exec
=
chromium
http
://
railnet
.
oebb
.
at
/
[
OBB_next_stop
]
_
type
=
http
url
=
https
://
railnet
.
oebb
.
at
/
assets
/
modules
/
fis
/
combined
.
json
error_handler
=
period
=
20
show_old
=
60
max_old
=
300
_
exec
=
chromium
http
://
railnet
.
oebb
.
at
/
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