Skip to content

Commit

Permalink
parsePidFiltersTree [todo]
Browse files Browse the repository at this point in the history
  • Loading branch information
derhuerst committed Feb 22, 2022
1 parent d9a99a8 commit 0ab1ee5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,8 @@ const createClient = (profile, userAgent, opt = {}) => {
},
})

if (!Array.isArray(res.jnyTreeNodeL)) return null

const ctx = {profile, opt, common, res}
return profile.parsePidFiltersTree(ctx, res.jnyTreeNodeL)
}
Expand Down
10 changes: 9 additions & 1 deletion parse/pid-filters-tree.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
'use strict'

const nodeKinds = new Map()
// todo: are these correct?
nodeKinds.set('P', 'product') // usually level 0, pid filter begins with `P:` "Produkt"?
nodeKinds.set('C', 'category') // usually level 1, pid filter begins with `G:` "Gruppe"?
nodeKinds.set('O', 'operator') // usually level 2, pid filter begins with `B:` "Betreiber"?
nodeKinds.set('L', 'line') // usually level 3, pid filter begins with `L:` "Linie"?
nodeKinds.set('D', 'direction') // usually level 4, pid filter begins with `R:` "Richtung"?

const parsePidFiltersTree = (ctx, jnyTreeNodeL) => {
const parsedNodes = new WeakMap() // raw node -> parsed node
const parseNode = (idx) => {
const _ = jnyTreeNodeL[idx]
if (!_) throw new Error(`missing node ${idx}`) // todo: don't let this happen
if (parsedNodes.has(_)) return parsedNodes.get(_)

// todo: what is _.type?
// todo: what is _.stat.rt? nr of children with realtime data?
// todo: what is _.stat.ont?
// todo: what is _.stat.cncl? nr of canceled children?
// todo: what is _.stat.delGrpL & _.stat.delCntL?
// todo: what is _.stat.him? nr of children with HIM messages?
const node = {
kind: nodeKinds.has(_.type) ? nodeKinds.get(_.type) : null,
name: _.name,
pidFilter: _.pid, // todo [breaking]: rename field?
// todo [breaking]: rename field?
Expand Down

0 comments on commit 0ab1ee5

Please sign in to comment.