Changeset 429 in tmcsimulator for trunk/webapps/einotebook/scripts/LoadEvents.js


Ignore:
Timestamp:
07/05/2019 04:01:43 PM (7 years ago)
Author:
jdalbey
Message:

Add CMS Evaluations to LoadEvents? for EINotebook. Fixes #147.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/webapps/einotebook/scripts/LoadEvents.js

    r386 r429  
    8585                        var evalType = tagName.replace("_EVALUATION",""); 
    8686                        // Build the evaluation item 
    87                         var facEval = new Evaluation(evalType,  
     87                        var evalItem = new Evaluation(evalType,  
    8888                                 parseEvaluation(currEvt.childNodes[child]) );   
    89                         evalarray.push(facEval); 
     89                        evalarray.push(evalItem); 
    9090                        break; 
    9191                         
    9292                    case "CMS_EVALUATION": 
    93                         // TODO: Complete this partial implementation 
    94                         var result = new Array();    
    95                         result.push("Expected Action:"); 
    96                         result.push("Action will appear here."); 
    97                         var cmsEval = new Evaluation("CMS", result); 
     93                        var cmsEval = new Evaluation("CMS", parseCMSEvaluation(currEvt.childNodes[child])); 
    9894                        evalarray.push(cmsEval); 
    9995                        break; 
     
    184180    return result; 
    185181} 
    186  
     182function parseCMSEvaluation(element) 
     183{ 
     184    var result = new Array(); 
     185    var locations = element.getElementsByTagName("LOCATION"); 
     186    if (locations.length > 0) 
     187    { 
     188        result.push("Sign Location:"); 
     189        result.push(locations[0].textContent); 
     190    } 
     191    var details = element.getElementsByTagName("CMS_LINE"); 
     192    if (details.length > 0) 
     193    { 
     194        for (detail in details) 
     195        { 
     196            if (details[detail].textContent != undefined) 
     197            {                 
     198                result.push("Sample Message:"); 
     199                result.push(details[detail].textContent.trim()); 
     200            } 
     201        } 
     202    } 
     203    return result; 
     204} 
    187205// MAIN 
    188 console.log("starting LoadEvents"); 
     206//console.log("starting LoadEvents"); 
    189207try { 
    190208    // the script must be located where accessible by the web server 
    191209    var scriptFilename = "../dynamicdata/incident_script.xml"; 
    192     console.log("Attempting to load", scriptFilename); 
     210    console.log("Attempting to load ", scriptFilename); 
    193211    // Now load the Incident Script and go parse it 
    194212    loadJSON(scriptFilename, parseXml) 
Note: See TracChangeset for help on using the changeset viewer.