Changeset 439 in tmcsimulator
- Timestamp:
- 07/11/2019 02:45:25 PM (7 years ago)
- Location:
- trunk/webapps/unifiedlogger
- Files:
-
- 2 added
- 2 deleted
- 3 edited
-
CMS watcher design.txt (deleted)
-
__main__.py (added)
-
cad_watcher.py (modified) (3 diffs)
-
cms_watcher.py (modified) (7 diffs)
-
logger design.txt (deleted)
-
logging_service.py (modified) (3 diffs)
-
wing_project.wpr (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/webapps/unifiedlogger/cad_watcher.py
r436 r439 3 3 4 4 # CAD comment log Watcher 5 # Look for changes in the CAD comment log 5 # Look for changes in the CAD comment log. 6 # The CADserver will append new comments to the log as they arrive 7 # from clients. We only need to keep track of the log length in order to 8 # determine if a new comment has been added. We will output the 9 # new messages that arrived during the last wait interval. 6 10 # jdalbey 7/6/2019 7 11 … … 14 18 return not isEmpty(cmsitem) 15 19 16 # Read the c ms message file20 # Read the cad comments log 17 21 def readFile(): 18 22 lines = [] 19 23 try: 20 text_file = open(" ../../CADcomments.log", "r")24 text_file = open("CADcomments.log", "r") 21 25 except IOError: 22 26 print "Error: missing CADcomments.log file." … … 39 43 return currList 40 44 45 # Local main for unit testing 41 46 def main(): 42 47 setup() 43 # Loop Forever 48 # Loop Forever, checking every five seconds 44 49 while True: 45 # Look for changedmessages50 # Look for new messages 46 51 answer = getLogEntries() 47 52 # Output results -
trunk/webapps/unifiedlogger/cms_watcher.py
r433 r439 8 8 prevList = [] # previous messages 9 9 currList = [] # current messages 10 locationMap = {} 10 locationMap = {} # map of CMS ID's to locations 11 11 12 12 # Utility functions … … 18 18 # Read the cms message file 19 19 def readFile(): 20 with open (" ../dynamicdata/cms_messages.json",'r') as myfile:20 with open ("webapps/dynamicdata/cms_messages.json",'r') as myfile: 21 21 jsonData=myfile.read() 22 22 … … 25 25 # Read the static file of cms locations and create a lookup map 26 26 def 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: 28 28 jsonData=myfile.read() 29 29 … … 40 40 for idx in range(0,len(msgList)): 41 41 idList.append(msgList[idx]['cms']['index']) 42 prevList.append(" ,,,,,")42 prevList.append(":::::") 43 43 return msgList 44 44 … … 49 49 for idx in range(0,len(msgList)): 50 50 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'] + ':' + 56 56 msgList[idx]['cms']['message']['phase2']['Line3']) 57 57 … … 71 71 # Is a new message activated? 72 72 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] +"'") 74 74 # Is an existing message turned off? 75 75 if isEmpty(currList[idx]) and isFull(prevList[idx]): 76 results.append("CMS Deactivated. " + locationMap[idList[idx]])76 results.append("CMS Deactivated., " + locationMap[idList[idx]]) 77 77 # Did a message change? 78 78 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] +"'") 80 80 81 81 # Save the current list as previous … … 83 83 return results 84 84 85 # Local main for unit testing 85 86 def main(): 86 87 global currList -
trunk/webapps/unifiedlogger/logging_service.py
r433 r439 1 import cms_watcher, cad_watcher, time, json 1 import cms_watcher, cad_watcher, time, json, ConfigParser 2 2 # Unified Logging Service 3 3 # jdalbey 7/6/2019 4 4 5 outputFilename = "unifiedlog.csv" 5 6 6 7 # Load the sim time file and extract the seconds */ 7 8 def getSimTime(): 8 with open (" ../dynamicdata/sim_elapsedtime.json", 'r') as myfile:9 with open ("webapps/dynamicdata/sim_elapsedtime.json", 'r') as myfile: 9 10 jsonData=myfile.read() 10 11 … … 15 16 return "%d:%02d:%02d" % (h, m, s) 16 17 17 def main(): 18 def startup(): 19 # get path to output file from configuration 20 config = ConfigParser.ConfigParser() 21 config.read('config/logging_service.cfg') 22 logfilepath = config.get('Paths', 'UnifiedLogPath') 23 18 24 # Delete any previously existing output file 19 f = open("../dynamicdata/unifiedlog.html", "w") 20 startHTML = "<HTML><HEAD><meta http-equiv=\"refresh\" content=\"5\" /></HEAD><BODY><PRE>" 21 f.write(startHTML); 25 f = open(logfilepath + outputFilename, "w") 22 26 f.close() 23 27 # List of the available plugin modules … … 51 55 trimmed_item = item.strip() 52 56 if len(trimmed_item) > 0: 53 output += timeStamp + " " + trimmed_item + "\n"57 output += timeStamp + ", " + trimmed_item + "\n" 54 58 # END LOOP 55 59 # IF the Output Buffer has any contents THEN 56 60 if len(output) > 0: 57 # Write (append) Output Buffer to unified log file 61 # Write (append) Output Buffer to unified log file as CSV 62 # Assumes fields don't contain commas 58 63 print output, 59 f = open( "../dynamicdata/unifiedlog.html", "a")64 f = open(logfilepath + outputFilename, "a") 60 65 f.write(output) 61 66 f.close() 62 67 # END IF 63 # Wait one second64 time.sleep( 1)68 # Wait five seconds 69 time.sleep(5) 65 70 66 71 #END DO 67 if __name__ == "__main__": 68 main() 72 73 if __name__ == '__main__': 74 startup()
Note: See TracChangeset
for help on using the changeset viewer.
