Changeset 466 in tmcsimulator for trunk/src


Ignore:
Timestamp:
07/27/2019 02:06:02 PM (7 years ago)
Author:
jdalbey
Message:

Add copyXMLfile method to Coordinator to fix #178.

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/python/unifiedlogger/cad_watcher.py

    r454 r466  
    3636     
    3737def setup(): 
    38     # nothing needed for setup 
     38    lastLineNum = 0 
    3939    return 
    4040 
  • trunk/src/python/unifiedlogger/logging_service.py

    r461 r466  
    4848    #    FOR each plugin LOOP 
    4949        for plugin in plugins: 
    50             # dynamically load the setup function for this plugin 
     50            # dynamically load the get log function for this plugin 
    5151            plugmodule = globals()[plugin] 
    5252            getfunc = getattr(plugmodule, 'getLogEntries') 
     
    5454    #        Run the plugin process returning new log entries 
    5555            results = getfunc()      
    56             #    Append simulation time and the log entries to the Output Buffer 
     56    #       Append simulation time and the log entries to the Output Buffer 
    5757            for item in results: 
    5858                trimmed_item = item.strip() 
  • trunk/src/python/unifiedlogger/wing_project.wpr

    r465 r466  
    183183                       'toolbox-percent': 1.0, 
    184184                       'toolbox-tree-sel': ''})], 
    185         'primary_view_state': {'editor_states': ({'bookmarks': ([[loc('activitylog_watcher.py'), 
    186         {'attrib-starts': [], 
    187          'code-line': '# Local main for unit testing\n', 
    188          'first-line': 48L, 
     185        'primary_view_state': {'editor_states': ({'bookmarks': ([[loc('logging_service.py'), 
     186        {'attrib-starts': [('startup|0|', 
     187                            20)], 
     188         'code-line': '                trimmed_item = item.strip()\n', 
     189         'first-line': 39L, 
    189190         'folded-linenos': [], 
    190          'sel-line': 50L, 
    191          'sel-line-start': 1431L, 
    192          'selection_end': 1460L, 
    193          'selection_start': 1460L, 
     191         'sel-line': 57L, 
     192         'sel-line-start': 1955L, 
     193         'selection_end': 1955L, 
     194         'selection_start': 1955L, 
    194195         'zoom': 0L}, 
    195         1563915276.741928], 
    196         [loc('../../../../../../../../usr/lib/python2.7/ConfigParser.py'), 
    197          {'attrib-starts': [('ConfigParser|0|', 
    198                              85), 
    199                             ('ConfigParser|0|.get|0|', 
    200                              589)], 
    201           'code-line': '                raise NoSectionError(section)\n', 
    202           'first-line': 601L, 
    203           'folded-linenos': [], 
    204           'sel-line': 606L, 
    205           'sel-line-start': 22028L, 
    206           'selection_end': 22028L, 
    207           'selection_start': 22028L, 
    208           'zoom': 0L}, 
    209          1563915287.423714], 
    210         [loc('activitylog_watcher.py'), 
    211          {'attrib-starts': [], 
    212           'code-line': '# Local main for unit testing\n', 
    213           'first-line': 18L, 
    214           'folded-linenos': [], 
    215           'sel-line': 50L, 
    216           'sel-line-start': 1431L, 
    217           'selection_end': 1460L, 
    218           'selection_start': 1460L, 
    219           'zoom': 0L}, 
    220          1563915319.659486], 
    221         [loc('../../../../../../../../usr/lib/python2.7/json/decoder.py'), 
    222          {'attrib-starts': [('JSONDecoder|0|', 
    223                              271), 
    224                             ('JSONDecoder|0|.raw_decode|0|', 
    225                              369)], 
    226           'code-line': '            obj, end = self.scan_once(s, idx)\n', 
    227           'first-line': 370L, 
    228           'folded-linenos': [], 
    229           'sel-line': 379L, 
    230           'sel-line-start': 13534L, 
    231           'selection_end': 13534L, 
    232           'selection_start': 13534L, 
    233           'zoom': 0L}, 
    234          1563915321.261377], 
    235         [loc('activitylog_watcher.py'), 
    236          {'attrib-starts': [], 
    237           'code-line': '# Local main for unit testing\n', 
    238           'first-line': 18L, 
    239           'folded-linenos': [], 
    240           'sel-line': 50L, 
    241           'sel-line-start': 1431L, 
    242           'selection_end': 1460L, 
    243           'selection_start': 1460L, 
    244           'zoom': 0L}, 
    245          1563915322.700758], 
    246         [loc('__main__.py'), 
    247          {'attrib-starts': [], 
    248           'code-line': 'import logging_service, os, ConfigParser\n', 
    249           'first-line': 0L, 
    250           'folded-linenos': [], 
    251           'sel-line': 0L, 
    252           'sel-line-start': 0L, 
    253           'selection_end': 40L, 
    254           'selection_start': 28L, 
    255           'zoom': 0L}, 
    256          1563915338.030142], 
    257         [loc('logging_service.py'), 
    258          {'attrib-starts': [('startup|0|', 
    259                              20)], 
    260           'code-line': '        # dynamically load the setup function for th'\ 
    261                        'is plugin        \n', 
    262           'first-line': 24L, 
    263           'folded-linenos': [], 
    264           'sel-line': 33L, 
    265           'sel-line-start': 1119L, 
    266           'selection_end': 1180L, 
    267           'selection_start': 1180L, 
    268           'zoom': 0L}, 
    269          1563915525.660434], 
    270         [loc('cms_watcher.py'), 
    271          {'attrib-starts': [], 
    272           'code-line': '# Read the cms message file\n', 
    273           'first-line': 12L, 
    274           'folded-linenos': [], 
    275           'sel-line': 17L, 
    276           'sel-line-start': 410L, 
    277           'selection_end': 606L, 
    278           'selection_start': 410L, 
    279           'zoom': 0L}, 
    280          1563915548.444179], 
    281         [loc('activitylog_watcher.py'), 
    282          {'attrib-starts': [('getLogEntries|0|', 
    283                              42)], 
    284           'code-line': '    currList = []\n', 
    285           'first-line': 33L, 
    286           'folded-linenos': [], 
    287           'sel-line': 45L, 
    288           'sel-line-start': 1303L, 
    289           'selection_end': 1303L, 
    290           'selection_start': 1303L, 
    291           'zoom': 0L}, 
    292          1563915776.997235], 
    293         [loc('logging_service.py'), 
    294          {'attrib-starts': [('startup|0|', 
    295                              20)], 
    296           'code-line': '                trimmed_item = item.strip()\n', 
    297           'first-line': 30L, 
    298           'folded-linenos': [], 
    299           'sel-line': 57L, 
    300           'sel-line-start': 1955L, 
    301           'selection_end': 1955L, 
    302           'selection_start': 1955L, 
    303           'zoom': 0L}, 
    304          1563915793.39434], 
    305         [loc('activitylog_watcher.py'), 
    306          {'attrib-starts': [('getLogEntries|0|', 
    307                              42)], 
    308           'code-line': '    return currList\n', 
    309           'first-line': 37L, 
    310           'folded-linenos': [], 
    311           'sel-line': 48L, 
    312           'sel-line-start': 1427L, 
    313           'selection_end': 1427L, 
    314           'selection_start': 1427L, 
    315           'zoom': 0L}, 
    316          1563915821.788454], 
    317         [loc('logging_service.py'), 
    318          {'attrib-starts': [('startup|0|', 
    319                              20)], 
    320           'code-line': '                trimmed_item = item.strip()\n', 
    321           'first-line': 39L, 
    322           'folded-linenos': [], 
    323           'sel-line': 57L, 
    324           'sel-line-start': 1955L, 
    325           'selection_end': 1955L, 
    326           'selection_start': 1955L, 
    327           'zoom': 0L}, 
    328          1563915837.345044], 
     196        1563915837.345044], 
    329197        [loc('activitylog_watcher.py'), 
    330198         {'attrib-starts': [('getLogEntries|0|', 
     
    422290          'selection_start': 559L, 
    423291          'zoom': 0L}, 
    424          1564102192.752733]], 
     292         1564102192.752733], 
     293        [loc('__main__.py'), 
     294         {'attrib-starts': [], 
     295          'code-line': 'import logging_service, os, ConfigParser\n', 
     296          'first-line': 0L, 
     297          'folded-linenos': [], 
     298          'sel-line': 0L, 
     299          'sel-line-start': 0L, 
     300          'selection_end': 40L, 
     301          'selection_start': 28L, 
     302          'zoom': 0L}, 
     303         1564182621.22245], 
     304        [loc('logging_service.py'), 
     305         {'attrib-starts': [('startup|0|', 
     306                             20)], 
     307          'code-line': '            # dynamically load the get log function '\ 
     308                       'for this plugin\n', 
     309          'first-line': 38L, 
     310          'folded-linenos': [], 
     311          'sel-line': 49L, 
     312          'sel-line-start': 1561L, 
     313          'selection_end': 1603L, 
     314          'selection_start': 1603L, 
     315          'zoom': 0L}, 
     316         1564182682.881746], 
     317        [loc('cad_watcher.py'), 
     318         {'attrib-starts': [('isFull|0|', 
     319                             16)], 
     320          'code-line': '\n', 
     321          'first-line': 27L, 
     322          'folded-linenos': [], 
     323          'sel-line': 18L, 
     324          'sel-line-start': 559L, 
     325          'selection_end': 559L, 
     326          'selection_start': 559L, 
     327          'zoom': 0L}, 
     328         1564182715.806107], 
     329        [loc('logging_service.py'), 
     330         {'attrib-starts': [('startup|0|', 
     331                             20)], 
     332          'code-line': '    #       Append simulation time and the log entri'\ 
     333                       'es to the Output Buffer\n', 
     334          'first-line': 38L, 
     335          'folded-linenos': [], 
     336          'sel-line': 55L, 
     337          'sel-line-start': 1843L, 
     338          'selection_end': 1851L, 
     339          'selection_start': 1851L, 
     340          'zoom': 0L}, 
     341         1564182751.746078], 
     342        [loc('cad_watcher.py'), 
     343         {'attrib-starts': [('isFull|0|', 
     344                             16)], 
     345          'code-line': '\n', 
     346          'first-line': 21L, 
     347          'folded-linenos': [], 
     348          'sel-line': 18L, 
     349          'sel-line-start': 559L, 
     350          'selection_end': 559L, 
     351          'selection_start': 559L, 
     352          'zoom': 0L}, 
     353         1564182793.261813], 
     354        [loc('__main__.py'), 
     355         {'attrib-starts': [], 
     356          'code-line': 'import logging_service, os, ConfigParser\n', 
     357          'first-line': 0L, 
     358          'folded-linenos': [], 
     359          'sel-line': 0L, 
     360          'sel-line-start': 0L, 
     361          'selection_end': 40L, 
     362          'selection_start': 28L, 
     363          'zoom': 0L}, 
     364         1564182798.481531], 
     365        [loc('logging_service.py'), 
     366         {'attrib-starts': [('startup|0|', 
     367                             20)], 
     368          'code-line': '    #       Append simulation time and the log entri'\ 
     369                       'es to the Output Buffer\n', 
     370          'first-line': 0L, 
     371          'folded-linenos': [], 
     372          'sel-line': 55L, 
     373          'sel-line-start': 1843L, 
     374          'selection_end': 1851L, 
     375          'selection_start': 1851L, 
     376          'zoom': 0L}, 
     377         1564182969.909882], 
     378        [loc('cad_watcher.py'), 
     379         {'attrib-starts': [], 
     380          'code-line': 'lastLineNum = 0\n', 
     381          'first-line': 7L, 
     382          'folded-linenos': [], 
     383          'sel-line': 11L, 
     384          'sel-line-start': 417L, 
     385          'selection_end': 432L, 
     386          'selection_start': 432L, 
     387          'zoom': 0L}, 
     388         1564183893.9794], 
     389        [loc('logging_service.py'), 
     390         {'attrib-starts': [('startup|0|', 
     391                             20)], 
     392          'code-line': '    #       Append simulation time and the log entri'\ 
     393                       'es to the Output Buffer\n', 
     394          'first-line': 39L, 
     395          'folded-linenos': [], 
     396          'sel-line': 55L, 
     397          'sel-line-start': 1843L, 
     398          'selection_end': 1851L, 
     399          'selection_start': 1851L, 
     400          'zoom': 0L}, 
     401         1564184320.038293], 
     402        [loc('cad_watcher.py'), 
     403         {'attrib-starts': [], 
     404          'code-line': 'lastLineNum = 0\n', 
     405          'first-line': 10L, 
     406          'folded-linenos': [], 
     407          'sel-line': 11L, 
     408          'sel-line-start': 417L, 
     409          'selection_end': 432L, 
     410          'selection_start': 432L, 
     411          'zoom': 0L}, 
     412         1564189528.213135], 
     413        [loc('logging_service.py'), 
     414         {'attrib-starts': [('startup|0|', 
     415                             20)], 
     416          'code-line': '    #       Append simulation time and the log entri'\ 
     417                       'es to the Output Buffer\n', 
     418          'first-line': 21L, 
     419          'folded-linenos': [], 
     420          'sel-line': 55L, 
     421          'sel-line-start': 1843L, 
     422          'selection_end': 1851L, 
     423          'selection_start': 1851L, 
     424          'zoom': 0L}, 
     425         1564189539.194298]], 
    425426        20), 
    426         'current-loc': loc('__main__.py'), 
     427        'current-loc': loc('cad_watcher.py'), 
    427428        'editor-state-list': [(loc('activitylog_watcher.py'), 
    428429                               {'attrib-starts': [('getLogEntries|0|', 
     
    437438                                'zoom': 0L}), 
    438439                              (loc('cad_watcher.py'), 
    439                                {'attrib-starts': [('isFull|0|', 
    440         16)], 
    441                                 'code-line': '\n', 
    442                                 'first-line': 3L, 
     440                               {'attrib-starts': [], 
     441                                'code-line': 'lastLineNum = 0\n', 
     442                                'first-line': 33L, 
    443443                                'folded-linenos': [], 
    444                                 'sel-line': 18L, 
    445                                 'sel-line-start': 559L, 
    446                                 'selection_end': 559L, 
    447                                 'selection_start': 559L, 
     444                                'sel-line': 11L, 
     445                                'sel-line-start': 417L, 
     446                                'selection_end': 432L, 
     447                                'selection_start': 432L, 
    448448                                'zoom': 0L}), 
    449449                              (loc('cms_watcher.py'), 
     
    471471                               {'attrib-starts': [('startup|0|', 
    472472        20)], 
    473                                 'code-line': '                trimmed_item ='\ 
    474         ' item.strip()\n', 
    475                                 'first-line': 50L, 
     473                                'code-line': '    #       Append simulation '\ 
     474        'time and the log entries to the Output Buffer\n', 
     475                                'first-line': 21L, 
    476476                                'folded-linenos': [], 
    477                                 'sel-line': 57L, 
    478                                 'sel-line-start': 1955L, 
    479                                 'selection_end': 1955L, 
    480                                 'selection_start': 1955L, 
     477                                'sel-line': 55L, 
     478                                'sel-line-start': 1843L, 
     479                                'selection_end': 1851L, 
     480                                'selection_start': 1851L, 
    481481                                'zoom': 0L}), 
    482482                              (loc('__main__.py'), 
     
    500500         loc('__main__.py')]), 
    501501                               'open_files': [u'../../../config/logging_service.cfg', 
     502        u'activitylog_watcher.py', 
    502503        u'cms_watcher.py', 
     504        u'__main__.py', 
    503505        u'logging_service.py', 
    504         u'activitylog_watcher.py', 
    505         u'cad_watcher.py', 
    506         u'__main__.py']}, 
     506        u'cad_watcher.py']}, 
    507507        'saved_notebook_display': None, 
    508508        'split_percents': {0: 0.5}, 
     
    511511        'traversal_pos': ((0, 
    512512                           3), 
    513                           1563915857.693931), 
     513                          1564183253.966105), 
    514514        'user_data': {}}, 
    515515                 'saved_notebook_display': None, 
     
    519519                 'traversal_pos': ((0, 
    520520                                    4), 
    521                                    1564102198.163837), 
     521                                   1564183317.08295), 
    522522                 'user_data': {}}, 
    523523        'window-alloc': (29, 
     
    525525                         1197, 
    526526                         722)}]} 
    527 guimgr.recent-documents = [loc('__main__.py'), 
    528                            loc('cad_watcher.py'), 
     527guimgr.recent-documents = [loc('cad_watcher.py'), 
     528                           loc('logging_service.py'), 
     529                           loc('__main__.py'), 
    529530                           loc('activitylog_watcher.py'), 
    530                            loc('logging_service.py'), 
    531531                           loc('cms_watcher.py'), 
    532532                           loc('../../../config/logging_service.cfg')] 
  • trunk/src/tmcsim/application.properties

    r465 r466  
    1 #Fri, 26 Jul 2019 06:34:33 -0700 
     1#Sat, 27 Jul 2019 15:30:49 -0700 
    22 
    3 Application.revision=464 
     3Application.revision=465 
    44 
    5 Application.buildnumber=170 
     5Application.buildnumber=174 
  • trunk/src/tmcsim/cadsimulator/Coordinator.java

    r465 r466  
    33import java.io.File; 
    44import java.io.FileWriter; 
     5import java.io.IOException; 
    56import java.io.PrintWriter; 
     7import java.nio.file.Files; 
     8import java.nio.file.Path; 
     9import java.nio.file.Paths; 
     10import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; 
    611import java.rmi.RemoteException; 
    712import java.rmi.server.UnicastRemoteObject; 
     
    7782import tmcsim.interfaces.SimulationManagerInterface; 
    7883import tmcsim.simulationmanager.SimulationManagerView; 
     84import tmcsim.simulationmanager.actions.LoadScriptAction; 
    7985 
    8086/** 
     
    107113    private String kCADcommentLog; 
    108114    /** 
     115     * Filename where copy of incident script is written to be used by 
     116     * EI notebook.  The same path as kSimClockFilename is used. 
     117     */ 
     118    private final static String kIncidentScriptFilename = "incident_script.xml"; 
     119    /** 
    109120     * Error logger. 
    110121     */ 
     
    540551        } 
    541552    } 
    542  
     553    /** Helper method to copy a file.   
     554     *  
     555     * @param selectedFile is the name of source file (without a path). 
     556     * The path will be extracted from kSimClockFilename and prefixed to the  
     557     * selectedFile.  Fixes #178. 
     558     */ 
     559    private void copyXMLfile(String selectedFile) 
     560    { 
     561        int ptr = kSimClockFilename.lastIndexOf(System.getProperty("file.separator")); 
     562        String foldername = kSimClockFilename.substring(0, ptr+1); 
     563        try { 
     564            Path destination = Paths.get(foldername + kIncidentScriptFilename); 
     565            Path source = Paths.get(selectedFile); 
     566            Files.copy(source, destination,REPLACE_EXISTING); 
     567            Logger.getLogger(Coordinator.class.getName()).log(Level.INFO,   
     568                    "Loaded script copied to " + destination); 
     569        } catch (IOException ex) { 
     570            Logger.getLogger(Coordinator.class.getName()).log(Level.SEVERE, null, ex); 
     571        }         
     572    } 
     573     
     574    /** Load and parse the XML script from the given file */ 
    543575    public void loadScriptFile(File scriptFile) throws RemoteException, ScriptException 
    544576    { 
    545  
    546  
     577        // Make a copy of the xml file to be used by EI notebook. 
     578        copyXMLfile(scriptFile.getPath()); 
    547579        try 
    548580        { 
Note: See TracChangeset for help on using the changeset viewer.