Beispiel #1
0
def Initialise(RootFolder: str, RuleFileName: str):
    params = dict()
    try:
        # Get Dtvt_Logger and specify the log file name

        params['log_file_path'] = os.path.join(
            RootFolder + "\\Logs\\",
            os.path.basename(RuleFileName).split('.')[0] + '.log')
        params['result_file_name'] = os.path.basename(RuleFileName).split(
            '.')[0] + '.xlsx'
        params['result_file_path'] = os.path.join(
            RootFolder + "\\Results\\",
            'Test_Results_' + params['result_file_name'])
        params['dtvt_log'] = GetLogger(params['log_file_path'])
        config = Configuration.Configuration(RootFolder)
        params['config'] = config
        # read constant
        params['proj_const'] = Utility.GetProjectConstants(
            params['config'].config_File_Path)
        print("\nExecuting " + os.path.basename(RuleFileName))
        params['dtvt_log'].info("Executing " + os.path.basename(__file__))
        csv_reader = CSVReader.CSVReader(config.csv_folder_path)
        params['SyDT'] = csv_reader.SyDT
        params['SyDB'] = SydbReader.SydbReader(config.sydb_file_path)

        return params
    except:
        print("Unexpected error, Module Name: Utility.py Mthode: Initialise",
              sys.exc_info()[0])
        return None
### ========= Template ============================================================================
import sys , os , os.path
import logging
from openpyxl import workbook, worksheet
# add root folder in search path
root_folder = os.path.abspath(os.path.join(os.path.join(os.path.dirname(__file__),".."),".."))
sys.path.append(root_folder)
import DtvtLib
from DtvtLib import Utility, Configuration , CSVReader
param = Utility.Initialise(root_folder,__file__)
log_file_path    = param['log_file_path']
result_file_name = param['result_file_name']
result_file_path = param['result_file_path']
dtvt_log         = param['dtvt_log']
proj_const       = param['proj_const']
SyDT             = param['SyDT']

### ======== Template Ends=========================================================================

### =========Rule_DB_General_0001 ===============================================================
# Author : Saleem Javed
# Updated 31 May 2017
# Caps Used : All caps having column "Name",
# Constant used :  None 

###================================================================================================

# Create report file
global_test_results = list()
wbReport = workbook.Workbook()
wsRpt=wbReport.active
Beispiel #3
0
### ========= Template =========================================================================
import sys, os, os.path
import logging
from openpyxl import workbook, worksheet
# add root folder in search path
root_folder = os.path.abspath(
    os.path.join(os.path.join(os.path.dirname(__file__), ".."), ".."))
sys.path.append(root_folder)
import DtvtLib
from DtvtLib import Utility, Configuration, CSVReader
param = Utility.Initialise(root_folder, __file__)
log_file_path = param['log_file_path']
result_file_name = param['result_file_name']
result_file_path = param['result_file_path']
dtvt_log = param['dtvt_log']
proj_const = param['proj_const']
SyDT = param['SyDT']

### ======== Template Ends===============================================================================================

### =========Rule RULE_TMS_PLATF_0014 ===================================================================================
# Author : Saleem Javed
# Updated 11 April 2017
# Caps Used : Urbalis_Sectors_Cap, Platforms_cap
# Constant used :  None
###======================================================================================================================

# Create Report
global_test_results = list()
wbReport = workbook.Workbook()
wsRpt = wbReport.active
Beispiel #4
0
### ========= Template =========================================================================
import sys, os, os.path
import logging
from openpyxl import workbook, worksheet
# add root folder in search path
root_folder = os.path.abspath(
    os.path.join(os.path.join(os.path.dirname(__file__), ".."), ".."))
sys.path.append(root_folder)
import DtvtLib
from DtvtLib import Utility, Configuration, CSVReader
param = Utility.Initialise(root_folder, __file__)
log_file_path = param['log_file_path']
result_file_name = param['result_file_name']
result_file_path = param['result_file_path']
dtvt_log = param['dtvt_log']
proj_const = param['proj_const']
SyDT = param['SyDT']

### ======== Template Ends===========================================================================

### =========Rule RULE_DB_ROUTE_0001 ===================================================================
# Author : Saleem Javed
# Updated 4 May 2017
# Caps Used : Signals_Cap,Routes_Cap,Signalisation_Areas_Cap
# Constant used :  None
###==================================================================================================

# Read Caps
routes_cap = SyDT['Routes_Cap']
signals_cap = SyDT['Signals_Cap']
sig_area_cap = SyDT['Signalisation_Areas_Cap']
Beispiel #5
0
### ========= Template =========================================================================
import sys, os, os.path
import logging
from openpyxl import workbook, worksheet
# add root folder in search path
root_folder = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
sys.path.append(root_folder)
import DtvtLib
from DtvtLib import Utility, Configuration, CSVReader

param = Utility.Initialise(root_folder, __file__)
log_file_path = param['log_file_path']
result_file_name = param['result_file_name']
result_file_path = param['result_file_path']
dtvt_log = param['dtvt_log']
proj_const = param['proj_const']
SyDT = param['SyDT']

### ======== Template Ends===========================================================================

### ======== Template Ends===========================================================================

### =========Rule TMS_SSP_0012 ===================================================================
# Author : Saleem Javed
# Updated 4 May 2017
# Caps Used : Service_Stopping_Points_Cap  , TRFC_Cap,Lines_Cap,Platforms_Cap,Stablings_Location_Cap,SDDB_Cap
# Constant used :  Line.Min_Head_Opposite_Shunting_Axle_Vehicle_Length , Local_D_Joint, Loc_Error_Platform,Loc_Error_Stabling,Loc_Error_Others, Stopping_accuracy

###==================================================================================================

# Read Caps
Beispiel #6
0
### ========= Template =========================================================================
import sys , os , os.path
import logging
from openpyxl import workbook, worksheet
# add root folder in search path
root_folder = os.path.abspath(os.path.join(os.path.dirname(__file__),".."))
sys.path.append(root_folder)
import DtvtLib
from DtvtLib import Utility, Configuration , CSVReader
param = Utility.Initialise(root_folder,__file__)
log_file_path    = param['log_file_path']
result_file_name = param['result_file_name']
result_file_path = param['result_file_path']
dtvt_log         = param['dtvt_log']
proj_const       = param['proj_const']
SyDT             = param['SyDT']

### ======== Template Ends===========================================================================

### =========Rule RCD_SIGNAL_0001 ===================================================================
# Author : Saleem Javed
# Updated 11 April 2017
# Caps Used : Signals_Cap  , Service_Stopping_Points_Cap
# Constant used :  None 
###==================================================================================================

# Read Caps
signals_cap = SyDT['Signals_Cap']
sig_name = signals_cap['Name']
sig_ssp = signals_cap['SSP_ID']
sig_kp = Utility.GetKpValue(signals_cap['KpValue'],signals_cap['KpCorrected_Trolley_Value'])
### ========= Template ============================================================================
import sys , os , os.path
import logging
from openpyxl import workbook, worksheet
# add root folder in search path
root_folder = os.path.abspath(os.path.join(os.path.join(os.path.dirname(__file__),".."),".."))
sys.path.append(root_folder)
import DtvtLib
from DtvtLib import Utility, Configuration , CSVReader
param = Utility.Initialise(root_folder,__file__)
log_file_path    = param['log_file_path']
result_file_name = param['result_file_name']
result_file_path = param['result_file_path']
dtvt_log         = param['dtvt_log']
proj_const       = param['proj_const']
SyDB             = param['SyDB']

### ======== Template Ends=========================================================================

### =========RULE_STOPPING_AREA_0008===============================================================
# Author : Saleem Javed
# Updated 23 May 2017
# Caps Used : Sydb Nodes Platforms,Change_Of_Direction_Areas,Stablings_Location,Isolation_Areas
#                        Coupling_Uncoupling_Areas,Washing_Zones,Transfer_Tracks,
# Constant used :  None 
# GFPD : 0962_AR
###================================================================================================

# Create report file
global_test_results = list()
wbReport = workbook.Workbook()
Beispiel #8
0
### ========= Template =========================================================================
import sys, os, os.path
import logging
from openpyxl import workbook, worksheet
# add root folder in search path
root_folder = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
sys.path.append(root_folder)
import DtvtLib
from DtvtLib import Utility, Configuration, CSVReader

param = Utility.Initialise(root_folder, __file__)
log_file_path = param['log_file_path']
result_file_name = param['result_file_name']
result_file_path = param['result_file_path']
dtvt_log = param['dtvt_log']
proj_const = param['proj_const']
SyDT = param['SyDT']
### ======== Template Ends==================================================================================================

### =========Rule RULE_DB_ROUTE_0003 ========================================================================================
# Author : Saleem Javed
# Updated 10 April 2017
# Caps Used : Signals_Cap ,Routes_Cap ,Switchs_Cap ,Points_Cap, Secondary_Detection_Devices_Cap,Signalisation_Areas_Cap
# Constant used :  None
###==========================================================================================================================

routes_cap = SyDT['Routes_Cap']
switchs_cap = SyDT['Switchs_Cap']
points_cap = SyDT['Points_Cap']
sddevices_cap = SyDT['Secondary_Detection_Devices_Cap']
sig_area_cap = SyDT['Signalisation_Areas_Cap']
### ========= Template =========================================================================
import sys, os, os.path
import logging
from openpyxl import workbook, worksheet

# add root folder in search path
root_folder = os.path.abspath(
    os.path.join(os.path.join(os.path.dirname(__file__), ".."), ".."))
sys.path.append(root_folder)
import DtvtLib
from DtvtLib import Utility, Configuration, CSVReader

param = Utility.Initialise(root_folder, __file__)
log_file_path = param['log_file_path']
result_file_name = param['result_file_name']
result_file_path = param['result_file_path']
dtvt_log = param['dtvt_log']
proj_const = param['proj_const']
sydb = param['SyDB']

### ======== Template Ends=================================================================================================

### =========Rule SCMA_TMS_OVERLAP_0033 ====================================================================================
# Author : Saleem Javed
# Updated 13 April 2017
# Caps Used : SYDB Node used, Signa,Overlap,SSP,Points
# Constant used :  None
###========================================================================================================================
from DtvtLib import SydbReader
import xml.etree.ElementTree as ET
### ========= Template ============================================================================
import sys, os, os.path
import logging
from openpyxl import workbook, worksheet
# add root folder in search path
root_folder = os.path.abspath(
    os.path.join(os.path.join(os.path.dirname(__file__), ".."), ".."))
sys.path.append(root_folder)
import DtvtLib
from DtvtLib import Utility, Configuration, CSVReader
param = Utility.Initialise(root_folder, __file__)
log_file_path = param['log_file_path']
result_file_name = param['result_file_name']
result_file_path = param['result_file_path']
dtvt_log = param['dtvt_log']
proj_const = param['proj_const']
SyDT = param['SyDT']

### ======== Template Ends=========================================================================

### =========Rule_WZ_0002===============================================================
# Author : Saleem Javed
# Updated 23 May 2017
# Caps Used : Projects_Cap,
# Constant used :  None

###================================================================================================

# Create report file
global_test_results = list()
wbReport = workbook.Workbook()
### ========= Template =========================================================================
import sys, os, os.path
import logging
from openpyxl import workbook, worksheet
# add root folder in search path
root_folder = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
sys.path.append(root_folder)
import DtvtLib
from DtvtLib import Utility, Configuration, CSVReader
param = Utility.Initialise(root_folder, __file__)
log_file_path = param['log_file_path']
result_file_name = param['result_file_name']
result_file_path = param['result_file_path']
dtvt_log = param['dtvt_log']
proj_const = param['proj_const']
SyDT = param['SyDT']

### ======== Template Ends===========================================================================

### ========= RCD_DB_SIGAREA_0003 ===================================================================
# Author : Saleem Javed
# Updated 16 May 2017
# Caps Used : Signalisation_Areas_Cap , Points_Cap , SDDBs_Cap,Secondary_Detection_Devices_Cap
# Constant used : Head_Correction,  NIAP_Tail_Correction
###==================================================================================================

protected_dist = max(int(proj_const['Head_Correction']),
                     int(proj_const['NIAP_Tail_Correction']))

# Read Caps
points_cap = SyDT['Points_Cap']
### ========= Template ============================================================================
import sys, os, os.path
import logging
from openpyxl import workbook, worksheet
# add root folder in search path
root_folder = os.path.abspath(
    os.path.join(os.path.join(os.path.dirname(__file__), ".."), ".."))
sys.path.append(root_folder)
import DtvtLib
from DtvtLib import Utility, Configuration, CSVReader

param = Utility.Initialise(root_folder, __file__)
log_file_path = param['log_file_path']
result_file_name = param['result_file_name']
result_file_path = param['result_file_path']
dtvt_log = param['dtvt_log']
proj_const = param['proj_const']
SyDB = param['SyDB']

### ======== Template Ends=========================================================================

### =========RULE_STOPPING_AREA_0008===============================================================
# Author : Saleem Javed
# Updated 23 May 2017
# Caps Used : Sydb Nodes Platforms,Change_Of_Direction_Areas,Stablings_Location,Isolation_Areas
#                        Coupling_Uncoupling_Areas,Washing_Zones,Transfer_Tracks,
# Constant used :  None
# GFPD : 0962_AR
###================================================================================================

# Create report file
### ========= Template =========================================================================
import sys, os, os.path
import logging
from openpyxl import workbook, worksheet
# add root folder in search path
root_folder = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
sys.path.append(root_folder)
import DtvtLib
from DtvtLib import Utility, Configuration, CSVReader
param = Utility.Initialise(root_folder, __file__)
log_file_path = param['log_file_path']
result_file_name = param['result_file_name']
result_file_path = param['result_file_path']
dtvt_log = param['dtvt_log']
proj_const = param['proj_const']
SyDT = param['SyDT']
### ======== Template Ends=======================================================================================================

signal_cap = SyDT['Signals_Cap']
sddb_cap = SyDT['SDDB_Cap']
tracks_cap = SyDT['Tracks_Cap']
signals_id = signal_cap['ID']
signal_name = signal_cap['Name']
signal_kp = Utility.GetKpValue(signal_cap['KpValue'],
                               signal_cap['KpCorrected_Trolley_Value'])
signal_track = signal_cap['Track_ID']
signal_dir = signal_cap['Direction']
Signal_Type_Function = signal_cap['Signal_Type_Function']

sigUp, sigUpKp, sigDn, sigDnKp = [], [], [], []
sigIdSortedUp, sigIdSortedDn = [], []
### ========= Template ============================================================================
import sys, os, os.path
import logging
from openpyxl import workbook, worksheet
# add root folder in search path
root_folder = os.path.abspath(
    os.path.join(os.path.join(os.path.dirname(__file__), ".."), ".."))
sys.path.append(root_folder)
import DtvtLib
from DtvtLib import Utility, Configuration, CSVReader
param = Utility.Initialise(root_folder, __file__)
log_file_path = param['log_file_path']
result_file_name = param['result_file_name']
result_file_path = param['result_file_path']
dtvt_log = param['dtvt_log']
proj_const = param['proj_const']
SyDB = param['SyDB']

### ======== Template Ends=========================================================================

### =========RCD_STOPPING_AREA_0001===============================================================
# Author : Saleem Javed
# Updated 23 May 2017
# Caps Used : Sydb Nodes Platforms,Change_Of_Direction_Areas,Stablings_Location,Isolation_Areas
#                        Coupling_Uncoupling_Areas,Washing_Zones,Transfer_Tracks,
# Constant used :  None
# GFPD : 0962_AP51
###================================================================================================

# Create report file
global_test_results = list()
Beispiel #15
0
### ========= Template =========================================================================
import sys, os, os.path
import logging
from openpyxl import workbook, worksheet
# add root folder in search path
root_folder = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
sys.path.append(root_folder)
import DtvtLib
from DtvtLib import Utility, Configuration, CSVReader
param = Utility.Initialise(root_folder, __file__)
log_file_path = param['log_file_path']
result_file_name = param['result_file_name']
result_file_path = param['result_file_path']
dtvt_log = param['dtvt_log']
proj_const = param['proj_const']
SyDT = param['SyDT']

### ======== Template Ends===============================================================================================

### =========Rule RULE_TMS_PLATF_0003 ===================================================================================
# Author : Saleem Javed
# Updated 11 April 2017
# Caps Used : Platforms_cap
# Constant used :  C_Late_Change_Distance
###======================================================================================================================

c_late_change_dist = Utility.Get_C_Late_Change_Distance(
    param['config'].C_Late_Change_Distance_File_Path)

# Create Report
global_test_results = list()
Beispiel #16
0
### ========= Template =========================================================================
import sys, os, os.path
import logging
from openpyxl import workbook, worksheet
# add root folder in search path
root_folder = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
sys.path.append(root_folder)
import DtvtLib
from DtvtLib import Utility, Configuration, CSVReader
param = Utility.Initialise(root_folder, __file__)
log_file_path = param['log_file_path']
result_file_name = param['result_file_name']
result_file_path = param['result_file_path']
dtvt_log = param['dtvt_log']
proj_const = param['proj_const']
sydb_reader = param['SyDB']

### ======== Template Ends=================================================================================================

### =========Rule RULE_TMS_SIGNAL_0012 ====================================================================================
# Author : Saleem Javed
# Updated 13 April 2017
# Caps Used : SYDB Node used, Routes,Switch,Blocks,Points,Signals
# Constant used :  None
###========================================================================================================================
from DtvtLib import SydbReader
import xml.etree.ElementTree as ET

point_deadlocking_blocks = sydb_reader.Point_Deadlocking_Block_ID_List()
signal_kp_pair = sydb_reader.Get_Signal_ID_Kp_Pairs()
route_sig_pair = sydb_reader.Get_Route_OriginSignal_Pairs()
### ========= Template =========================================================================
import sys, os, os.path
import logging
from openpyxl import workbook, worksheet
# add root folder in search path
root_folder = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
sys.path.append(root_folder)
import DtvtLib
from DtvtLib import Utility, Configuration, CSVReader

param = Utility.Initialise(root_folder, __file__)
log_file_path = param['log_file_path']
result_file_name = param['result_file_name']
result_file_path = param['result_file_path']
dtvt_log = param['dtvt_log']
proj_const = param['proj_const']
SyDT = param['SyDT']

### ======== Template Ends===========================================================================

### =========Rule RCD_TMS_RMZ_016 ===================================================================
# Author : Saleem Javed
# Updated 12 April 2017
# Caps Used : Reverse_Movement_Zones_Cap  , SDDB_Cap
# Constant used :  None
###==================================================================================================

# Read Caps
Dir_In_Increasing_Kp = str.upper(
    SyDT['Lines_Cap']['Conventional_Description_Direction'][0])
rmz_cap = SyDT['Reverse_Movement_Zones_Cap']
import logging
from openpyxl import workbook, worksheet

# add root folder in search path
root_folder = os.path.abspath(os.path.join(os.path.dirname(__file__),".."))
sys.path.append(root_folder)

import DtvtLib
from DtvtLib import Utility, Configuration , CSVReader

try:
    # Get Dtvt_Logger and specify the log file name   
    log_file_path = os.path.join(root_folder + "\\Logs\\" , os.path.basename(__file__).split('.')[0] + '.log')
    result_file_name = os.path.basename(__file__).split('.')[0] + '.xlsx'
    result_file_path = os.path.join(root_folder + "\\Results\\" ,'Test_Results_' + result_file_name)
    dtvt_log = Utility.GetLogger(log_file_path)
except:
    print("Error while creating logger")

config = Configuration.Configuration(root_folder)
# read constant
proj_const = dict()
proj_const = Utility.GetProjectConstants(config.config_File_Path)
print("Executing " + os.path.basename(__file__))
dtvt_log.info("Executing " + os.path.basename(__file__))

### ======== Template Ends===============================================================================================

### =========Rule RULE_TMS_SDD_0046 ===================================================================================
# Author : Saleem Javed
# Updated 10 May 2017
### ========= Template =========================================================================
import sys, os, os.path
import logging
from openpyxl import workbook, worksheet
# add root folder in search path
root_folder = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
sys.path.append(root_folder)
import DtvtLib
from DtvtLib import Utility, Configuration, CSVReader

param = Utility.Initialise(root_folder, __file__)
log_file_path = param['log_file_path']
result_file_name = param['result_file_name']
result_file_path = param['result_file_path']
dtvt_log = param['dtvt_log']
proj_const = param['proj_const']
SyDT = param['SyDT']

### ======== Template Ends===========================================================================

### =========Rule RSCMA_SPECIFIC_RMZ_CONSTRAINT ===================================================================
# Author : Saleem Javed
# Updated 11 April 2017
# Caps Used : Reverse_Movement_Zones_Cap  , Points_Cap
# Constant used :  Min_RMR_Protection ,  Min_RMR_Protection_Forward
###==================================================================================================

# Read Caps
rmz_cap = SyDT['Reverse_Movement_Zones_Cap']
point_cap = SyDT['Points_Cap']
### ========= Template =========================================================================
import sys, os, os.path
import logging
from openpyxl import workbook, worksheet
# add root folder in search path
root_folder = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
sys.path.append(root_folder)
import DtvtLib
from DtvtLib import Utility, Configuration, CSVReader
param = Utility.Initialise(root_folder, __file__)
log_file_path = param['log_file_path']
result_file_name = param['result_file_name']
result_file_path = param['result_file_path']
dtvt_log = param['dtvt_log']
proj_const = param['proj_const']
SyDT = param['SyDT']

### ======== Template Ends===========================================================================

### =========Rule RULE_TMS_STABL_0003 ===================================================================
# Author : Saleem Javed
# Updated 12 April 2017
# Caps Used : Tracks_Cap, Stablings_Location_Cap  , TRFC_Cap , Service_Stopping_Points_Cap
# Constant used :  None
###==================================================================================================

# Read Caps
Dir_In_Increasing_Kp = str.upper(
    SyDT['Lines_Cap']['Conventional_Description_Direction'][0])

stl_cap = SyDT['Stablings_Location_Cap']