Changeset 439 in tmcsimulator for trunk/webapps/unifiedlogger/cms_watcher.py


Ignore:
Timestamp:
07/11/2019 02:45:25 PM (7 years ago)
Author:
jdalbey
Message:

setup wing project for logging service python files. Add config file for file paths.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/webapps/unifiedlogger/cms_watcher.py

    r433 r439  
    88prevList = []  # previous messages 
    99currList = []  # current messages 
    10 locationMap = {} 
     10locationMap = {} # map of CMS ID's to locations 
    1111 
    1212# Utility functions 
     
    1818# Read the cms message file 
    1919def readFile():      
    20      with open ("../dynamicdata/cms_messages.json",'r') as myfile: 
     20     with open ("webapps/dynamicdata/cms_messages.json",'r') as myfile: 
    2121          jsonData=myfile.read() 
    2222  
     
    2525# Read the static file of cms locations and create a lookup map 
    2626def loadLocations(): 
    27      with open ("../cptms/data_layers/cms_locations_D12.gjson",'r') as myfile: 
     27     with open ("webapps/cptms/data_layers/cms_locations_D12.gjson",'r') as myfile: 
    2828          jsonData=myfile.read() 
    2929  
     
    4040     for idx in range(0,len(msgList)): 
    4141          idList.append(msgList[idx]['cms']['index']) 
    42           prevList.append(",,,,,") 
     42          prevList.append(":::::") 
    4343     return msgList 
    4444 
     
    4949     for idx in range(0,len(msgList)): 
    5050          currList.append( 
    51                     msgList[idx]['cms']['message']['phase1']['Line1'] + ',' +  
    52                     msgList[idx]['cms']['message']['phase1']['Line2'] + ',' + 
    53                     msgList[idx]['cms']['message']['phase1']['Line3'] + ',' + 
    54                     msgList[idx]['cms']['message']['phase2']['Line1'] + ',' + 
    55                     msgList[idx]['cms']['message']['phase2']['Line2'] + ',' + 
     51                    msgList[idx]['cms']['message']['phase1']['Line1'] + ':' +  
     52                    msgList[idx]['cms']['message']['phase1']['Line2'] + ':' + 
     53                    msgList[idx]['cms']['message']['phase1']['Line3'] + ':' + 
     54                    msgList[idx]['cms']['message']['phase2']['Line1'] + ':' + 
     55                    msgList[idx]['cms']['message']['phase2']['Line2'] + ':' + 
    5656                    msgList[idx]['cms']['message']['phase2']['Line3']) 
    5757 
     
    7171          # Is a new message activated? 
    7272          if isEmpty(prevList[idx]) and isFull(currList[idx]): 
    73                results.append("CMS Activated. " + locationMap[idList[idx]] + " '" + currList[idx] +"'") 
     73               results.append("CMS Activated.," + locationMap[idList[idx]] + ", '" + currList[idx] +"'") 
    7474          # Is an existing message turned off? 
    7575          if isEmpty(currList[idx]) and isFull(prevList[idx]): 
    76                results.append("CMS Deactivated. " + locationMap[idList[idx]]) 
     76               results.append("CMS Deactivated., " + locationMap[idList[idx]]) 
    7777          # Did a message change? 
    7878          if isFull(currList[idx]) and isFull(prevList[idx]) and currList[idx] != prevList[idx]: 
    79                results.append("CMS Updated. " + locationMap[idList[idx]] + " '" + currList[idx] +"'") 
     79               results.append("CMS Updated., " + locationMap[idList[idx]] + ", '" + currList[idx] +"'") 
    8080 
    8181     # Save the current list as previous 
     
    8383     return results 
    8484 
     85# Local main for unit testing 
    8586def main(): 
    8687     global currList 
Note: See TracChangeset for help on using the changeset viewer.