|
Ron. Have a look at this program. See attached. I believe it does what you are looking for. I don’t know is this is what you mean by “easy”…it’s just what I did. ------------------------------------------------------------------------------------------------------ Paul Reid Application Developer III Erb Group of Companies | 290 Hamilton Road | New Hamburg, Ontario | N3A 1A2 Phone: 519.662.6133 ext. 2363 From:
ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx]
On Behalf Of Ron Koontz Is there an easy way to decode a field from BASE64 ? ( IBM API maybe that I cannot find ) I have tried Scott’s example but get a “Definition not found for symbol 'BASE64_ENCODE'. “ after I compile my program. I did all the compile options in the BASE64R4 documentation. I tried an example online as well and got the same error just to make sure it was not my main pgm.. Any Ideas? Its probably something easy I’m not doing I would guess.
Example off the web : /copy BASE64_H
D Input S 6a D Output S 8A
/free
input = x'61626b3735'; Output = *blanks;
base64_encode( %addr(Input)
: %len(%trimr(Input))
: %addr(Output)
: %size(Output) );
dsply Output;
*inlr = *on;
/end-free
Thanks Ron
|
H BNDDIR('DSBNDDIR':'HTTPAPI':'QC2LE':'UTBNDDIR')
*------------------------------------------------------------------------*
* DSRPERFMON - Download Performance Monitoring data from SHAW. *
* Created by : Paul Reid *
* Created on : Jan 08,2014 *
* Currently this program receives two differnt transactions from the web *
* service: 1 : T.4.01.0 - PM Performance Data Transaction Type. *
* 2 : T.3.02.0 - Critical Event Reporting (CER). *
* The data from both of these transactions is written out to file *
* DSPPERFMON. *
*------------------------------------------------------------------------*
* Prototype call to this program: *
*------------------------------------------------------------------------*
*
D DSRPERFMON PR extpgm('DSRPERFMON')
*
D DSRPERFMON PI
*
*------------------------------------------------------------------------*
* Prototypes: *
*------------------------------------------------------------------------*
*
* Scott Klement's HTTPAPI.
/include qrpglesrc,HTTPAPI_H
*
* Scott Klement's Base64 encoder/decoder.
/include qrpglesrc,BASE64_H
*
* Write out performance monitoring data to out database.
/include qcopysrc,DSTPERFUP
*
* For sending email notifications.
/include qcopysrc,UTTEMAIL
*
*------------------------------------------------------------------------*
* incoming - Parse response from SHAW. *
*------------------------------------------------------------------------*
*
D incoming...
D PR
D userData...
D 8F
D nestingDepth...
D 10I 0 value
D elementName...
D 1024A varying const
D elementPath...
D 24576A varying const
D elementValue...
D likeds(Xmlstring_t)
D attributes...
D * dim(32767)
D const options(*varsize)
*
*------------------------------------------------------------------------*
* embedded - Parse the embedded XML. *
*------------------------------------------------------------------------*
*
D embedded...
D PR
D userData...
D * value
D nestingDepth...
D 10I 0 value
D elementName...
D 1024A varying const
D elementPath...
D 24576A varying const
D elementValue...
D 65535A varying const
D attributes...
D * dim(32767)
D const options(*varsize)
*
*------------------------------------------------------------------------*
* All data required to write a record to DSPPERFMON. *
*------------------------------------------------------------------------*
*
D allPerfDataDS...
D DS likeDS(DSRMPERFUP_allPerfDataDS)
*
*------------------------------------------------------------------------*
* Errors on procedure call when writing to DSPPERFMON. *
*------------------------------------------------------------------------*
*
D errorInfo...
D DS likeDS(UTTERRDS_errorDS)
*
*------------------------------------------------------------------------*
* Receive data with pointers into a data structure. *
*------------------------------------------------------------------------*
*
D XmlString_t...
D DS qualified Template
D data *
D len 10I 0
*
*------------------------------------------------------------------------*
* Last transaction ID. *
*------------------------------------------------------------------------*
*
D ##PERFMON...
D S 17 0 dtaara(##PERFMON)
*
*------------------------------------------------------------------------*
* Local variables in alphabetical order: *
*------------------------------------------------------------------------*
*
D decodedData...
D S A len(2000000) varying
D decodedLength...
D S 10I 0
D errorMessage...
D S 100A inz(*blanks)
D parserLog...
D S 1000A varying
D peErrorNo...
D S 10I 0 inz(*zeros)
D rc1...
D S 10I 0
D rc2...
D S 10I 0
D responseLog...
D S 1000A varying
D scMsg...
D S 102A inz(*blanks)
D sndGroup...
D S 10A inz('OPSSUPPORT')
D sndMessage...
D S 1000A inz(*blanks)
D sndSubject...
D S 50A inz(*blanks)
D soapRequest...
D S 32767A varying
D soapHeader...
D S 32767A varying
D soapBody...
D S 32767A varying
D subscriberId...
D S 9A varying
D transCount...
D S 5P 0 inz(*zeros)
D transIdIn...
D S 17A varying
D transIdOut...
D S 17 0 inz(*zeros)
D userData...
D S 8F
D var...
D S 50A based(p_var)
*
*------------------------------------------------------------------------*
* Mainline: *
*------------------------------------------------------------------------*
*
/free
// Assemble an XML SOAP request to be posted to SHAW's Web Service.
exsr assembleSOAPheader;
exsr assembleSOAPbody;
soapRequest = %trim(soapHeader) + %trim(soapBody);
// Turn on the debugger before the post.
responseLog = '/PerformanceMonitoring/responseLog.txt';
http_debug(*on : responseLog);
// Change the way the XML parser returns the data. We need
// to return pointers because the amount of data is so large.
http_XmlReturnPtr(*on);
// Post XML SOAP request.
rc1 = http_url_post_xml(
'https://www.myshawtracking.ca:443/otsWebWS/services/OTSWebSvcs'
: %addr(soapRequest) + 2
: %len(soapRequest)
: *NULL
: %paddr(incoming)
: %addr(userData)
: HTTP_TIMEOUT
: HTTP_USERAGENT
: 'text/xml'
: 'http://www.qualcomm.com/dequeue2');
// Change the XML parser so that no longer just returns pointers.
http_XmlReturnPtr(*off);
// Turn off the debugger.
http_debug(*off);
// When we recieve a valid response rc1 = 1.
if rc1 = 1;
// Only continue process if data was returned (transCount > 0).
if transCount > 0;
// Parse the decoded XML eturned from SHAW.
exsr parseDecodedXML;
endif;
// If an error occured while consuming the Web Service then send
// a message to OPS support.
else;
scMsg = http_error(peErrorNo);
sndSubject = 'Error retrieving performace data from SHAW. #1';
sndMessage = 'SHAW Web Service dequeue2 returned an error' +
' &N ' +
'Run date . . . :' +
%trim(%char(%date())) +
' &N ' +
'Run time . . . :' +
%trim(%char(%time())) +
' &N ' +
'transCount . . :' +
%trim(%char(transCount)) +
' &N ' +
'transIdOut . . :' +
%trim(%char(transIdOut)) +
' &N ' +
'Error returned :' +
%trim(errorMessage) +
' &N ' +
'http_error() . :' +
%trim(scMsg) +
' &N ' +
'peErrorNo. . . :' +
%trim(%char(peErrorNo)) +
' &N ' +
'Please Investigate!' +
' &N ' +
'Program name = DSRPERFMON' +
' &N ' +
'See log /PerformanceMonitoring/responseLog.txt';
exsr eMailErrorMessage;
endif;
// The End.
*inlr = *on;
return;
//-----------------------------------------------------------------------*
// Parse the decoded XML. *
//-----------------------------------------------------------------------*
begsr parseDecodedXML;
// Initialize all data fields in file DSPPERFMON.
clear allPerfDataDS;
// Turn on the dubugger before parsing the embedded XML.
parserLog = '/PerformanceMonitoring/parserLog.txt';
http_debug(*on : parserLog);
// Parse the XML repsponse embedded in the "transactions" element.
rc2 = http_parse_xml_string(%addr(decodedData: *DATA)
: %len(decodedData)
: 819
: *NULL
: %paddr(embedded)
: *NULL);
// turn off the debugger.
http_debug(*off);
// If the parsing was not successful send an error to Ops support.
if rc2 <> 0;
scMsg = http_error(peErrorNo);
sndSubject = 'Error parsing performace data from SHAW. #2';
sndMessage = 'SHAW Web Service dequeue2 parsing error' +
' &N ' +
'Run date . . . :' +
%trim(%char(%date())) +
' &N ' +
'Run time . . . :' +
%trim(%char(%time())) +
' &N ' +
'transCount . . :' +
%trim(%char(transCount)) +
' &N ' +
'transIdOut . . :' +
%trim(%char(transIdOut)) +
' &N ' +
'Error returned :' +
%trim(errorMessage) +
' &N ' +
'http_error() . :' +
%trim(scMsg) +
' &N ' +
'peErrorNo. . . :' +
%trim(%char(peErrorNo)) +
' &N ' +
'Please Investigate!' +
' &N ' +
'Program name = DSRPERFMON' +
' &N ' +
'See log /PerformanceMonitoring/parserLog.txt';
exsr eMailErrorMessage;
// Output the last transaction ID to the data area. The next time
// we run this process we will start at this transaction number.
else;
##PERFMON = transIdOut + 1;
out ##PERFMON;
endif;
endsr;
//-----------------------------------------------------------------------*
// Assemble SOAP header XML request. Username and password have been *
// hard coded as they are not expected to change. *
//-----------------------------------------------------------------------*
begsr assembleSOAPheader;
soapHeader =
'<?xml version="1.0" encoding="utf-8"?>'
+' <soap:Envelope'
+' xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"'
+' xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing"'
+' xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-'
+'wss-wssecurity-secext-1.0.xsd"'
+' xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-'
+'wss-wssecurity-utility-1.0.xsd"'
+' xmlns:xsd="http://www.w3.org/2001/XMLSchema"'
+' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'
+'<soap:Header>'
+'<wsse:Security soap:mustUnderstand="1" >'
+'<wsse:UsernameToken>'
+'<wsse:Username>yourUserName</wsse:Username>'
+'<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/'
+'oasis-200401-wss-username-token-profile-1.0#'
+'PasswordText">yourPassword</wsse:Password>'
+'</wsse:UsernameToken>'
+'</wsse:Security>'
+'</soap:Header>';
endsr;
//-----------------------------------------------------------------------*
// Assemble SOAP body XML request. Subsciber ID has been hard coded as *
// is not expected to change. *
//-----------------------------------------------------------------------*
begsr assembleSOAPbody;
subscriberId = 'yourSubcriberId';
in *lock ##PERFMON;
transIdIn = %trim(%char(##PERFMON));
soapBody =
'<soap:Body>'
+'<dequeue2>'
+'<subscriberId>'
+ subscriberId
+'</subscriberId>'
+'<transactionIdIn>'
+ transIdIn
+'</transactionIdIn>'
+'</dequeue2>'
+'</soap:Body>'
+'</soap:Envelope>';
endsr;
//-----------------------------------------------------------------------*
// eMail error message. *
//-----------------------------------------------------------------------*
begsr eMailErrorMessage;
UTRMEMAIL_sendSimpleToGroup(sndGroup
: sndSubject
: sndMessage);
endsr;
/end-free
*
*------------------------------------------------------------------------*
* incoming - Parse XML response from SHAW. *
*------------------------------------------------------------------------*
*
P incoming...
P B
*
D incoming...
D PI
D userData...
D 8F
D nestingDepth...
D 10I 0 value
D elementName...
D 1024A varying const
D elementPath...
D 24576A varying const
D elementValue...
D likeds(XmlString_t)
D attributes...
D * dim(32767)
D const options(*varsize)
*
/free
// The number of transcations returbed on this run.
if elementName = 'count';
p_var = elementValue.data;
transCount = %dec(%subst(var:1:elementValue.len):5:0);
// The data in the 'transactions' element
// is a base64 encoded XML document.
elseif elementName = 'transactions';
%len(decodedData) = %len(decodedData : *MAX);
decodedLength = base64_decode( elementValue.data
: elementValue.len
: %addr(decodedData : *data)
: %len(decodedData : *MAX) );
%len(decodedData) = decodedLength;
// The last transaction ID that was returned.
elseif elementName = 'transactionIdOut';
p_var = elementValue.data;
transIdOut = %dec(%subst(var:1:elementValue.len):17:0);
elseif elementName = 'soap:Text';
p_var = elementValue.data;
errorMessage = %subst(var:1:elementValue.len);
endif;
/end-free
*
P incoming E
*
*------------------------------------------------------------------------*
* embedded - Parse the embedded XML and write to our database. *
*------------------------------------------------------------------------*
*
P embedded...
P B
*
D embedded...
D PI
D userData...
D * value
D nestingDepth...
D 10I 0 value
D elementName...
D 1024A varying const
D elementPath...
D 24576A varying const
D elementValue...
D 65535A varying const
D attributes...
D * dim(32767)
D const options(*varsize)
*
* Local variables:
D attributeCount...
D S 10I 0
D attributeName...
D S 1024A varying
D attributeValue...
D S 65535A varying
*
* General work fields.
D mobileType...
D S 2A inz(*blanks)
D posType...
D S 1A inz(*blanks)
D ignitionStatus...
D S 1A inz(*blanks)
D tripStatus...
D S 1A inz(*blanks)
D faultFlag...
D S 1A inz(*blanks)
D registeredDriver...
D S 1A inz(*blanks)
*
* Work fields used to covert GMT (Greenwich Mean Time) to
* EST (Eastern Standard Time).
D gmtDateTime...
D S 20A inz(*blanks)
D isoAlphaDateTime...
D S 26A inz(*blanks)
D timeStamp...
D S Z inz(Z'0001-01-01-00.00.00.000000')
D isoDate...
D S D inz(*loval)
D isoTime...
D S T inz(*loval)
*
* Work fields for a Proximity location:
D proxCity...
D S 10A inz(*blanks)
D proxDist...
D S 7A inz(*blanks)
D proxDir...
D S 3A inz(*blanks)
D proxPlac...
D S 10A inz(*blanks)
D proxPlTp...
D S 4A inz(*blanks)
D proxStPr...
D S 2A inz(*blanks)
D proxPost...
D S 6A inz(*blanks)
D proxCoun...
D S 2A inz(*blanks)
*
/free
// Transaction ID - Container for a single transaction (aka: event)
// of any type.
select;
when elementName = 'tran';
attributeCount = 1;
dow http_nextXmlAttr(attributes
: attributeCount
: attributeName
: attributeValue);
if attributeName = 'ID';
allPerfDataDS.pmTransID# = %trim(attributeValue);
endif;
enddo;
// Write a new record for each T.4.01.0 or
// T.3.02.0 transaction received.
if allPerfDataDS.pmTranType = 'T.4.01.0' or
allPerfDataDS.pmTranType = 'T.3.02.0';
DSRMPERFUP_writeAllPerformanceData(
allPerfDataDS :
errorInfo);
endif;
// Clear fields used to write DSPPERFMON records.
clear allPerfDataDS;
// Clear general work fields.
mobileType = *blanks;
posType = *blanks;
ignitionStatus = *blanks;
tripStatus = *blanks;
faultFlag = *blanks;
registeredDriver = *blanks;
// T.4.01.0 - PM Performance Data Transaction Type.
// T.3.02.0 - Critical Event Reporting (CER) Data Transaction Type.
when elementName = 'T.4.01.0';
allPerfDataDS.pmTranType = 'T.4.01.0';
when elementName = 'T.3.02.0';
allPerfDataDS.pmTranType = 'T.3.02.0';
// Date and Time when the event took place.
when elementName = 'eventTS';
gmtDateTime = *blanks;
gmtDateTime = %trim(elementValue);
exsr convertGMTtoEST;
allPerfDataDS.pmEvntDate = isoDate;
allPerfDataDS.pmEvntTime = isoTime;
// Uniquely define a piece of equipment (truck).
when elementName = 'equipment';
attributeCount = 1;
dow http_nextXmlAttr(attributes
: attributeCount
: attributeName
: attributeValue);
// Unique customer-defined equipment identifier.
// In our system this is our truck number.
select;
when attributeName = 'ID';
allPerfDataDS.pmEqpID = %trim(attributeValue);
// Unique manufacture-assigned address of the
// equipment's mobile communication unit.
when attributeName = 'unitAddress';
allPerfDataDS.pmEqpAddr = %trim(attributeValue);
// Indicates the type of equipment, "trailer" or "tractor".
when attributeName = 'equipType';
allPerfDataDS.pmEqpType = %trim(attributeValue);
// Indicates the type of mobile communication device.
when attributeName = 'mobileType';
mobileType = %trim(attributeValue);
select;
when mobileType = '0 ';
allPerfDataDS.pmEqpMobTp = 'Unknown ';
when mobileType = '1 ';
allPerfDataDS.pmEqpMobTp = 'MCT ';
when mobileType = '2 ';
allPerfDataDS.pmEqpMobTp = 'TMCT ';
when mobileType = '3 ';
allPerfDataDS.pmEqpMobTp = 'OmniOne ';
when mobileType = '4 ';
allPerfDataDS.pmEqpMobTp = 'MCP ';
when mobileType = '5 ';
allPerfDataDS.pmEqpMobTp = 'MCP100 ';
when mobileType = '6 ';
allPerfDataDS.pmEqpMobTp = 'MCP110 ';
when mobileType = '7 ';
allPerfDataDS.pmEqpMobTp = 'MCP200 ';
when mobileType = '8 ';
allPerfDataDS.pmEqpMobTp = 'MCP50 ';
when mobileType = '10';
allPerfDataDS.pmEqpMobTp = 'UTT ';
when mobileType = '11';
allPerfDataDS.pmEqpMobTp = 'Tethered';
when mobileType = '12';
allPerfDataDS.pmEqpMobTp = 'Stingray';
endsl;
// On-board device identifier.
when attributeName = 'deviceID';
allPerfDataDS.pmEqpDevID = %trim(attributeValue);
endsl;
enddo;
// Driver I.D.
when elementName = 'driverID';
allPerfDataDS.pmDriverID = %trim(elementValue);
// Geographical coordinates at a point in time.
when elementName = 'position';
attributeCount = 1;
dow http_nextXmlAttr(attributes
: attributeCount
: attributeName
: attributeValue);
select;
// Longitude expressed in signed degrees with
// floating-point decimal precision.
when attributeName = 'lon';
allPerfDataDS.pmLongitud = %trim(attributeValue);
// Latitude expressed in signed degrees with
// floating-point decimal precision.
when attributeName = 'lat';
allPerfDataDS.pmLatitud = %trim(attributeValue);
// Position timestamp in GMT.
when attributeName = 'posTS';
gmtDateTime = *blanks;
gmtDateTime = %trim(attributeValue);
exsr convertGMTtoEST;
allPerfDataDS.pmPosnDate = isoDate;
allPerfDataDS.pmPosnTime = isoTime;
endsl;
enddo;
// Identifies the hardware that was used to determine the position
// information contained in the tranaction.
when elementName = 'posType';
posType = %trim(elementValue);
select;
when posType = '0';
allPerfDataDS.pmPosnType = 'Unknown';
when posType = '1';
allPerfDataDS.pmPosnType = 'LORAN ';
when posType = '2';
allPerfDataDS.pmPosnType = 'QASPR ';
when posType = '3';
allPerfDataDS.pmPosnType = 'GPS ';
endsl;
// Ignition Status of the truck. "On" or "Off".
when elementName = 'ignitionStatus';
ignitionStatus = %trim(elementValue);
select;
when ignitionStatus = '1';
allPerfDataDS.pmIgnStat = 'On ';
when ignitionStatus = '2';
allPerfDataDS.pmIgnStat = 'Off';
endsl;
// The Trip status of the truck. "In" or "Out" of Trip. Note:
// The trip status feature requires tha SensorTRACS service
// to be enabled. and configured.
when elementName = 'tripStatus';
tripStatus = %trim(elementValue);
select;
when tripStatus = 'I';
allPerfDataDS.pmTripStat = 'In ';
when tripStatus = 'O';
allPerfDataDS.pmTripStat = 'Out';
endsl;
// Date and time recording started for this Driver.
// (Since last extraction reset).
when elementName = 'dataStartTS';
gmtDateTime = *blanks;
gmtDateTime = %trim(elementValue);
exsr convertGMTtoEST;
allPerfDataDS.pmStrtDate = isoDate;
allPerfDataDS.pmStrtTime = isoTime;
// Date and time that recording ended for this Driver.
// (Time of this extraction reset).
when elementName = 'dataEndTS';
gmtDateTime = *blanks;
gmtDateTime = %trim(elementValue);
exsr convertGMTtoEST;
allPerfDataDS.pmEndDate = isoDate;
allPerfDataDS.pmEndTime = isoTime;
// Distance travelled in miles or kilometers.
when elementName = 'distance';
allPerfDataDS.pmDistance = %trim(elementValue);
// The number of minutes recorded for this Driver while ignition was
// on but excluding intertrip idle time (includes idle time during
// trip but not between trips).
when elementName = 'driveTime';
allPerfDataDS.pmDrivTime = %trim(elementValue);
// The number of minutes recorded for this Driver while the ignition
// was on.
when elementName = 'engineTime';
allPerfDataDS.pmEngTime = %trim(elementValue);
// The number of minutes when the vehicle speed was greater than zero.
when elementName = 'moveTime';
allPerfDataDS.pmMoveTime = %trim(elementValue);
// The number of minutes idling between trips (excess idle time for
// this Driver).
when elementName = 'intertripIdleTime';
allPerfDataDS.pmIntIdle = %trim(elementValue);
// The number of minutes idling when the duration of the idling period
// was longer than the end of trip (EOT) threshold, but shorter than
// the short idle threshold. Note MCT firmware version 14.02 or higher
// is required.
when elementName = 'shortIdleTime';
allPerfDataDS.pmShrtIdle = %trim(elementValue);
// The number of minutes the Driver has exceeded the settable RPM
// threshold.
when elementName = 'overRPMTime';
allPerfDataDS.pmOverRPMT = %trim(elementValue);
// The number of times the settable RPM threshold was exceeded in
// one minute.
when elementName = 'overRPMCount';
allPerfDataDS.pmOverRPMC = %trim(elementValue);
// The longest duration exceeding the settable RPM threshold (rounded
// up to the next minute).
when elementName = 'overRPMMax';
allPerfDataDS.pmOverRPMM = %trim(elementValue);
// The number of minutes the Driver exceeded the settable speed
// threshold.
when elementName = 'overSpdTime';
allPerfDataDS.pmOverSpdT = %trim(elementValue);
// The number of times the settable speed threshold exceeded 1 min.
when elementName = 'overSpdCount';
allPerfDataDS.pmOverSpdC = %trim(elementValue);
// The longest duration exceeded the settable speed threshold (rounded
// up to the next minute).
when elementName = 'overSpdMax';
allPerfDataDS.pmOverSpdM = %trim(elementValue);
// The number of minutes the driver has exceeded the settable
// excessive speed threshold. Note: MCT firmware version > 10.51
// required.
when elementName = 'excessSpdTime';
allPerfDataDS.pmExceSpdT = %trim(elementValue);
// The total amount of fuel burned by this Driver in gallons, liters,
// or imperial gallons based on the customer's preference. Note: MCT
// firmware version above 10.51 is required.
when elementName = 'totalFuelUsed';
allPerfDataDS.pmTotlFuel = %trim(elementValue);
// The total amount of fuel burned by this Driver while the vehicle
// was not moving and a PTO was not active. Units are in gallons,
// liters, or imperial gallons based on the company's preference.
// Note MCT firmware version above 10.51 is required.
when elementName = 'idleFuelUsed';
allPerfDataDS.pmIdleFuel = %trim(elementValue);
// The total amount of fuel burned by this Driver while the parking
// brake was applied. Units are in gallons, liters, or imperial
// gallons based on the company's preference. Note: MCT firmware
// version above 10.51 is required.
when elementName = 'parkIdleFuelUsed';
allPerfDataDS.pmParkIdle = %trim(elementValue);
// Indicates whether or not any fault conditions were present.
when elementName = 'faultFlag';
faultFlag = %trim(elementValue);
select;
when faultFlag = '0';
allPerfDataDS.pmFaultFlg = 'No Faults ';
when faultFlag = '1';
allPerfDataDS.pmFaultFlg = 'Faults detected';
endsl;
// Indicates whether or not the Driver is registered.
when elementName = 'registeredDriver';
registeredDriver = %trim(elementValue);
select;
when registeredDriver = '0';
allPerfDataDS.pmRegiDriv = 'Unregistered';
when registeredDriver = '1';
allPerfDataDS.pmRegiDriv = 'Registered ';
endsl;
// The number of minutes cruise control was active and a speed was
// set.
when elementName = 'cruiseCtrlTime';
allPerfDataDS.pmCruiseCt = %trim(elementValue);
// The number of minutes vehicle was in top gear.
when elementName = 'topGearTime';
allPerfDataDS.pmTopGear = %trim(elementValue);
// The method or source used to acquire gear data for determining time
// in top gear. Possible values are: "Vehicle data bus (J1939) is the
// sole source", "Hybrid combination of data bus and onboard
// algorithmic sources", or "Onboard algorithm is the sole source".
when elementName = 'gearDataSource';
allPerfDataDS.pmGearData = %trim(elementValue);
// Either "MPH" or "KPH".
when elementName = 'spdRpmTimes';
attributeCount = 1;
dow http_nextXmlAttr(attributes
: attributeCount
: attributeName
: attributeValue);
select;
when attributeName = 'spdUnits';
allPerfDataDS.pmSpeedUOM = %trim(attributeValue);
endsl;
enddo;
// Proximity - Location information expressed as a reference to a
// nearby place.
when elementName = 'proximity';
attributeCount = 1;
dow http_nextXmlAttr(attributes
: attributeCount
: attributeName
: attributeValue);
select;
// Proximity City name.
when attributeName = 'city';
proxCity = %trim(attributeValue);
// The distance to the (proximity) place in miles or kms.
when attributeName = 'distance';
proxDist = %trim(attributeValue);
// Direction to the (proximity) place using a compass notation
// notation containing a maximum of 3 characters.
// (e.g. N, SE, NNW).
when attributeName = 'direction';
proxDir = %trim(attributeValue);
// The unique customer-defined name of the (proximity) place, if
// the place type is not CITY or TOWN.
when attributeName = 'placeName';
proxPlac = %trim(attributeValue);
// Proximity Place Type such as CITY or TOWN.
when attributeName = 'placeType';
proxPlTp = %trim(attributeValue);
// Proximity State or Province code.
when attributeName = 'stateProv';
proxStPr = %trim(attributeValue);
// Proximity Postal code - 12 character maximum.
when attributeName = 'postal';
proxPost = %trim(attributeValue);
// Proximity Country code, possible values are US, CA, MX.
when attributeName = 'country';
proxCoun = %trim(attributeValue);
endsl;
enddo;
// If this is a TOWN then populate the Proximity Town fields.
if proxPlTp = 'TOWN';
allPerfDataDS.pmPrxTCity = proxCity;
allPerfDataDS.pmPrxTDist = proxDist;
allPerfDataDS.pmPrxTDir = proxDir;
allPerfDataDS.pmPrxTPlac = proxPlac;
allPerfDataDS.pmPrxTPlTp = proxPlTp;
allPerfDataDS.pmPrxTStPr = proxStPr;
allPerfDataDS.pmPrxTPost = proxPost;
allPerfDataDS.pmPrxTCoun = proxCoun;
// If this is a CITY then populate the Proximity City fields.
elseif proxPlTp = 'CITY';
allPerfDataDS.pmPrxCCity = proxCity;
allPerfDataDS.pmPrxCDist = proxDist;
allPerfDataDS.pmPrxCDir = proxDir;
allPerfDataDS.pmPrxCPlac = proxPlac;
allPerfDataDS.pmPrxCPlTp = proxPlTp;
allPerfDataDS.pmPrxCStPr = proxStPr;
allPerfDataDS.pmPrxCPost = proxPost;
allPerfDataDS.pmPrxCCoun = proxCoun;
endif;
// Reset the proximity work fields.
proxCity = *blanks;
proxDist = *blanks;
proxDir = *blanks;
proxPlac = *blanks;
proxPlTp = *blanks;
proxStPr = *blanks;
proxPost = *blanks;
proxCoun = *blanks;
// T.3.02.0 - Critical Event Reporting (CER)
// A unique identifier for this incident.
when elementName = 'eventKey';
allPerfDataDS.pmCerEvtKy = %trim(elementValue);
// Date and Time that this event was sent in.
when elementName = 'sentTS';
gmtDateTime = *blanks;
gmtDateTime = %trim(elementValue);
exsr convertGMTtoEST;
allPerfDataDS.pmCerSntDt = isoDate;
allPerfDataDS.pmCerSntTm = isoTime;
// The event that triggered this incident.
when elementName = 'eventTrigger';
allPerfDataDS.pmCerEvent = %trim(elementValue);
// Trigger specific data for the incident.
when elementName = 'triggerData';
allPerfDataDS.pmCerTrgDa = %trim(elementValue);
// Purpose of this is similar to the Event Trigger element. But,
// this will be used specifically for EVIMS with value EVIMS.
when elementName = 'eventType';
allPerfDataDS.pmCerEvtTp = %trim(elementValue);
// Speed.
when elementName = 'speed';
allPerfDataDS.pmCerSpeed = %trim(elementValue);
// Parking Brake Status.
when elementName = 'parkBrakeStatus';
allPerfDataDS.pmCerParBk = %trim(elementValue);
// Message location, date and time.
when elementName = 'messageLocation';
allPerfDataDS.pmCerMLon = allPerfDataDS.pmLongitud;
allPerfDataDS.pmCerMLat = allPerfDataDS.pmLatitud;
allPerfDataDS.pmCerMDate = allPerfDataDS.pmPosnDate;
allPerfDataDS.pmCerMTime = allPerfDataDS.pmPosnTime;
allPerfDataDS.pmLongitud = *blanks;
allPerfDataDS.pmLatitud = *blanks;
allPerfDataDS.pmPosnDate = *loval;
allPerfDataDS.pmPosnTime = *loval;
// Proximity to the nearest town.
allPerfDataDS.pmCerTDist = allPerfDataDS.pmPrxTDist;
allPerfDataDS.pmCerTDir = allPerfDataDS.pmPrxTDir;
allPerfDataDS.pmCerTPlac = allPerfDataDS.pmPrxTPlac;
allPerfDataDS.pmCerTPlTp = allPerfDataDS.pmPrxTPlTp;
allPerfDataDS.pmCerTCity = allPerfDataDS.pmPrxTCity;
allPerfDataDS.pmCerTStPr = allPerfDataDS.pmPrxTStPr;
allPerfDataDS.pmCerTPost = allPerfDataDS.pmPrxTPost;
allPerfDataDS.pmCerTCoun = allPerfDataDS.pmPrxTCoun;
allPerfDataDS.pmPrxTDist = *blanks;
allPerfDataDS.pmPrxTDir = *blanks;
allPerfDataDS.pmPrxTPlac = *blanks;
allPerfDataDS.pmPrxTPlTp = *blanks;
allPerfDataDS.pmPrxTCity = *blanks;
allPerfDataDS.pmPrxTStPr = *blanks;
allPerfDataDS.pmPrxTPost = *blanks;
allPerfDataDS.pmPrxTCoun = *blanks;
// Proximity to the nearest city.
allPerfDataDS.pmCerCDist = allPerfDataDS.pmPrxCDist;
allPerfDataDS.pmCerCDir = allPerfDataDS.pmPrxCDir;
allPerfDataDS.pmCerCPlac = allPerfDataDS.pmPrxCPlac;
allPerfDataDS.pmCerCPlTp = allPerfDataDS.pmPrxCPlTp;
allPerfDataDS.pmCerCCity = allPerfDataDS.pmPrxCCity;
allPerfDataDS.pmCerCStPr = allPerfDataDS.pmPrxCStPr;
allPerfDataDS.pmCerCPost = allPerfDataDS.pmPrxCPost;
allPerfDataDS.pmCerCCoun = allPerfDataDS.pmPrxCCoun;
allPerfDataDS.pmPrxCDist = *blanks;
allPerfDataDS.pmPrxCDir = *blanks;
allPerfDataDS.pmPrxCPlac = *blanks;
allPerfDataDS.pmPrxCPlTp = *blanks;
allPerfDataDS.pmPrxCCity = *blanks;
allPerfDataDS.pmPrxCStPr = *blanks;
allPerfDataDS.pmPrxCPost = *blanks;
allPerfDataDS.pmPrxCCoun = *blanks;
// Message location, date and time.
when elementName = 'incidentLocation';
allPerfDataDS.pmCerILon = allPerfDataDS.pmLongitud;
allPerfDataDS.pmCerILat = allPerfDataDS.pmLatitud;
allPerfDataDS.pmCerIDate = allPerfDataDS.pmPosnDate;
allPerfDataDS.pmCerITime = allPerfDataDS.pmPosnTime;
allPerfDataDS.pmLongitud = *blanks;
allPerfDataDS.pmLatitud = *blanks;
allPerfDataDS.pmPosnDate = *loval;
allPerfDataDS.pmPosnTime = *loval;
// CER URL.
when elementName = 'eventUrl';
allPerfDataDS.pmCerUrl = %trim(elementValue);
endsl;
//-----------------------------------------------------------------------*
// Convert a GMT Date/Time Stamp to EST in ISO format. *
//-----------------------------------------------------------------------*
begsr convertGMTtoEST;
isoDate = *loval;
isoTime = *loval;
isoAlphaDateTime = *blanks;
timeStamp = *loval;
isoAlphaDateTime = %subst(gmtDateTime:1:4) +
'-' +
%subst(gmtDateTime:6:2) +
'-' +
%subst(gmtDateTime:9:2) +
'-' +
%subst(gmtDateTime:12:2) +
'.' +
%subst(gmtDateTime:15:2) +
'.' +
%subst(gmtDateTime:18:2) +
'.' +
'000000';
test(ZE) *ISO isoAlphaDateTime;
if not %error;
timeStamp = %timestamp(isoAlphaDateTime:*ISO)
- %hours(5); // Convert GMT to EST.
isoDate = %date(%subst(%char(timeStamp):1:10));
isoTime = %time(%subst(%char(timeStamp):12:8));
endif;
endsr;
/end-free
*
P embedded...
P E
*-- _______________________________________________ Ftpapi mailing list Ftpapi@xxxxxxxxxxxxxxxxxxxxxx http://scottklement.com/mailman/listinfo/ftpapi