new
Simply creates a parser object so that the methods can be called on it.
my $tl1_parser = new TL1ng::Parser;
parse_string
Parses a scalar string containing the lines of a TL1 message (as returned by $tl1->_read_msg()) and returns a reference to a hash-based data structure representing the TL1 data fields for that message.
my $msg = $self->parse_string($lines);
If the parsing fails somewhere along the line, whatever we've already done will be returned in the $msh hash and the 'success' hash entry will be missing. Also, an 'error' hash entry may be set.
parse_array
Just like parse_string(), but it's arguments are a list of strings containing the lines of the TL1 message. See parse_string() for more info.
my $msg = $self->parse_array(@lines);
parse_arrayref
Just like parse_string(), but it's argument is a reference to an array of strings containing the lines of the TL1 message. See parse_string() for more info.
my $msg = $self->parse_arrayref(\@lines);
_process_msg
See parse_string() and parse_array() above. Is called by those methods. It's argument should be a reference to an array of strings.
my $msg = $self->_process_msg($msg);
_process_ack_msg
Parses the header and any data lines of a TL1 Command Acknowledgement message (stored in the $msg->{lines}) to populate the appropriate fields in the $msg data structure.
my $status = $self->_process_ack_msg($msg);
_process_cmd_msg
Parses the header and any data lines of a TL1 Command Response message (stored in the $msg->{lines}) to populate the appropriate fields in the $msg data structure.
my $status = $self->_process_cmd_msg($msg);
_process_aut_msg
Parses the header and any data lines of a TL1 Autonomous Response message (stored in the $msg->{lines}) to populate the appropriate fields in the $msg data structure.
my $status = $self->_process_aut_msg($msg);
_process_unk_msg
For messages handling where the type is unknown. Right now this method simply sets an error in the $msg data structure and then returns true.
my $status = $self->_process_unk_msg($msg);
_parse_msg_data
Parses out the data payload and comments from a TL1 message and populates the fields in the $msg data structure. Returns true on success. If parsing fails, sets an "error" field in $msg and returns false. The first parameter is a reference to the $msg data structure. The second is the index of the position in the $msg->{lines} array where the headers end and the data begins. This is done because different types of messages have a different number of header lines and I decided to avoid putting that intelligence in a method that could probably be used elsewhere.
my $FISRT_DATA_LINE = 2;
my $status = $tl1->_parse_msg_data($msg, $FISRT_DATA_LINE);
THIS METHOD PROBABLY NEEDS WORK - IT'S MESSY AND A LITTLE CONFUSING!!!
_parse_payload_lines
Parse the payload data lines into 'fields' delimited by : and 'sections' delimited by , and save the results in an array of arrays in $msg->{payload}
The AoAoA structure reflects: $payload[] = @lines $lines[] = @sections $sections[] = @fields
Usage:
my $status = $self->_parse_payload_lines($msg);
_split_quoted
Splits a line on a delimiter, but ignores delimiters inside quotes... This is the sort of thing that is useful for parsing CSV with quoted fields that may contain the delimiter. Takes two scalar arguments just like split()
my $delim = ':';
my $string = 'FAC-14-9:CL,RAI,NSA,,,,:"Remote Alarm Indication",DS1-14';
my @fields = $self->_split_quoted($delim, $string);
_parse_msg_header
Parses the header line of CMD and AUT response messages and populates the apropriate fields of the $msg data structure. Returns true on success. If parsing fails, sets an "error" field in $msg and returns false.
my $status = $tl1->_parse_msg_header($msg);
_match_msg_type
Parse an array of lines composing a TL1 message to determine the type. Return values can be one of:
ACK - Acknowledgement of receipt of a command
CMD - Response to a command
AUT - Autonomous message (not in response to a command)
UNK - Unknown. Probably bogus, non-standard, or my code messed up
Returns false if the lines array is empty or the header is incomplete.
my $msg_type = $tl1->_match_msg_type(\@lines);
_datetime2utcunix
Timestamps in TL1 messages are formatted for human-readability, in the form YYYY-MM-DD HH:mm:ss (hour is 0-23, no AM/PM)<br> <br> This method turns those text timestamps into programmer-friendly Unix timestamps adjusted to UTC (number of seconds since the Epoch at GMT/UTC)<br> <br> The first parameter is the TL1 date in YYYY-MM-DD, and the second parameter is the TL1 time in HH:mm:ss. By default, this is assumed to be local time and so the returned Unix timestamp is adjusted to UTC. To prevent that (if, for example, your TL1 timestamps are already using UTC,) pass a third argument as any true value.
my $utc_unix_time = $tl1->_datetime2utcunix($local_tl1_date, $local_tl1_time);
my $NO_ADJ_TZ=1;
my $utc_unix_time = $tl1->_datetime2utcunix($utc_tl1_date, $utc_tl1_time, $NO_ADJ_TZ);