def run_demo(): if ARGVS.demo == 1: ARGVS.fi = AppUtils.getASPENFile(olxpath, 'SAMPLE30.OLR') ARGVS.op = [1, 2, 3, 4, 5] run() else: AppUtils.demo_notFound(PY_FILE, ARGVS.demo, [1])
def saveReportBusFile(self): ARGVS.fb = AppUtils.get_file_out(fo=ARGVS.fb, fi=ARGVS.fi, subf='', ad='_bus', ext='.txt') # sr = [] sr.append('App : ' + PY_FILE) sr.append('User: '******'Date: ' + time.asctime()) sr.append('\nBus report:') k = 0 for b1 in self.busA: k += 1 sb = OlxAPILib.fullBusName(b1) sr.append(str(k).ljust(5) + sb) if k == 0: sr.append('\tNo bus found') # AppUtils.saveArString2File(ARGVS.fb, sr) print('\nReport bus file had been saved in:\n"%s"' % ARGVS.fb) # if ARGVS.gui > 0 and ARGVS.ut == 0: AppUtils.launch_notepad(ARGVS.fb)
def run(): """ run linez: """ flog = AppUtils.logger2File(PY_FILE, version=__version__) if not AppUtils.checkInputOLR(ARGVS.fi, PY_FILE, PARSER_INPUTS): return if not AppUtils.checkInputPK(ARGVS.pk, 'BUS/LINE/RLYGROUP', PY_FILE, PARSER_INPUTS): return # OlxObj.load_olxapi(ARGVS.olxpath) # OlxAPI module initialization OlxObj.OLCase.open(ARGVS.fi, 1) # logging.info('\nOLR file: ' + ARGVS.fi) if type(ARGVS.pk) != list: ARGVS.pk = [ARGVS.pk] # for i in range(len(ARGVS.pk)): logging.info('\nSelected Object: ' + str(ARGVS.pk[i])) t0 = OlxObj.OLCase.findOBJ(ARGVS.pk[i]) run1t(t0) print('logFile:', flog) return 1
def main(): AppUtils.logger2File(PY_FILE, version=__version__) # global FRUNNING, SRUNNING FRUNNING, SRUNNING = AppUtils.markerStart(ARGVS.opath) if ARGVS.demo > 0: return run_demo() run()
def unit_test(): ARGVS.fi = os.path.join(PATH_FILE, 'ARCFLASH.OLR') run() sres = "OLR file: " + os.path.basename(ARGVS.fi) + "\n" sres += "Template file: " + os.path.basename(ARGVS.ft) + "\n" sres += AppUtils.read_File_text_2(ARGVS.fo, 5) # AppUtils.deleteFile(ARGVS.fo) return AppUtils.unit_test_compare(PATH_FILE, PY_FILE, sres)
def unit_test(): ARGVS.fi = os.path.join(PATH_FILE, "BusFlt.OLR") ARGVS.pk = ["[BUS] 6 'NEVADA' 132 kV"] sres = "OLR file: " + os.path.basename(ARGVS.fi) + "\n" run() sres += AppUtils.read_File_text_2(ARGVS.fo, 1) # AppUtils.deleteFile(ARGVS.fo) return AppUtils.unit_test_compare(PATH_FILE, PY_FILE, sres)
def checkInput(): if not AppUtils.checkInputOLR(ARGVS.fi, PY_FILE, PARSER_INPUTS): return False # a, s = AppUtils.checkFile(ARGVS.ft, [".XLSX", ".XLS", ".XLSM", ".CSV"], 'Input template file') if not a: return AppUtils.FinishCheck(PY_FILE, s, PARSER_INPUTS) # return True
def unit_test(): ARGVS.fi = os.path.join(PATH_FILE, "NETWORKUTIL.OLR") ARGVS.pk = ["[BUS] 10 'NEW HAMPSHR' 33 kV", "[BUS] 28 'ARIZONA' 132 kV"] # run() sres = "OLR file: " + os.path.basename(ARGVS.fi) + "\n" sres += AppUtils.read_File_text_2(ARGVS.fo, 4) # AppUtils.deleteFile(ARGVS.fo) return AppUtils.unit_test_compare(PATH_FILE, PY_FILE, sres)
def run_demo(): if ARGVS.demo == 1: ARGVS.fi = ARGVS.olxpath + '\\SAMPLE30.OLR' ARGVS.pk = "[BUS] 6 'NEVADA' 132 kV" # choice = AppUtils.ask_run_demo(PY_FILE, 0, ARGVS.fi, "Selected BUS: " + str(ARGVS.pk)) if choice == "yes": return run() else: AppUtils.demo_notFound(PY_FILE, ARGVS.demo, [1])
def run_demo(): if ARGVS.demo==1: ARGVS.fi = AppUtils.getASPENFile(PATH_FILE,'SAMPLE30.OLR') ARGVS.fo = AppUtils.get_file_out(fo='' , fi=ARGVS.fi , subf='' , ad='_'+os.path.splitext(PY_FILE)[0]+'_demo' , ext='.csv') ARGVS.pk = ["[BUS] 6 'NEVADA' 132 kV", "[BUS] 14 'MONTANA' 33 kV"] # choice = AppUtils.ask_run_demo(PY_FILE,ARGVS.ut,ARGVS.fi,"Selected Bus: " + str(ARGVS.pk)) if choice=="yes": return run() else: AppUtils.demo_notFound(PY_FILE,ARGVS.demo,[1])
def unit_test(): ARGVS.fi = os.path.join(PATH_FILE, "LINETERM.OLR") ARGVS.pk = ["[RELAYGROUP] 5 'FIELDALE' 132 kV-'BUS3' 132 kV 1 L"] sres = 'OLR file: ' + os.path.basename(ARGVS.fi) + '\n' run() sres += AppUtils.read_File_text_2(ARGVS.fo, 4) ARGVS.pk = ["[RELAYGROUP] 2 'CLAYTOR' 132 kV-6 'NEVADA' 132 kV 1 L"] run() sres += '\n' sres += AppUtils.read_File_text_2(ARGVS.fo, 4) AppUtils.deleteFile(ARGVS.fo) return AppUtils.unit_test_compare(PATH_FILE, PY_FILE, sres)
def getIPForAPI(self): p = re.search(REGEX_PATTERN, IP_API).groups() DOMAIN_NAME = p[len(p) - 2] DOMAIN_URL = DOMAIN_NAME try: res = socket.gethostbyname(DOMAIN_URL) self.api_ip = res self.ignored_ip_set.add(self.api_ip) except RequestExceptions as e: logger.error(e, exc_info=True) if e.exit: au.exitFromApp()
def unit_test(): ARGVS.fi = os.path.join(PATH_FILE, "XFMRConn.OLR") sres = "OLR file: " + os.path.basename(ARGVS.fi) + "\n" sres += run() # s1 = ARGVS.fi ARGVS.fi = ARGVS.fo sres += "\nRe-check\n" sres += "OLR file: " + os.path.basename(ARGVS.fi) + "\n" sres += run() # OlxAPI.CloseDataFile() AppUtils.deleteFile(ARGVS.fi) return AppUtils.unit_test_compare(PATH_FILE, PY_FILE, sres)
def run_demo(): if ARGVS.demo == 1: ARGVS.fi = AppUtils.getASPENFile(PATH_FILE, 'SAMPLE30.OLR') ARGVS.fo = AppUtils.get_file_out( fo='', fi=ARGVS.fi, subf='', ad='_' + os.path.splitext(PY_FILE)[0] + '_demo', ext='.OLR') # choice = AppUtils.ask_run_demo(PY_FILE, ARGVS.ut, ARGVS.fi, '') if choice == "yes": return run() else: AppUtils.demo_notFound(PY_FILE, ARGVS.demo, [1])
def checkInput(): if not AppUtils.checkInputOLR(ARGVS.fi, PY_FILE, PARSER_INPUTS): return False # if not (ARGVS.pk or ARGVS.ar or ARGVS.zo): s = "\nSelected Objects,Area number,Zone number = Empty.\nUnable to continue.\n" return AppUtils.FinishCheck(PY_FILE, s, PARSER_INPUTS) # try: ARGVS.ar = list(map(int, ARGVS.ar)) except: raise Exception('Area Number is not an INTEGER') try: ARGVS.zo = list(map(int, ARGVS.zo)) except: raise Exception('Zone Number is not an INTEGER') return True
def initialize(self): self.feed = self.args["feed"] self.alexa_devices = self.args.get("alexa_devices") self.google_devices = self.args.get("google_devices") self.no_reminder_today_sensor = self.args.get( "no_reminder_today_sensor") self.reminder_sensor = self.args.get("reminder_sensor") self.reminder_sensor_friendly_name = self.args.get( "reminder_sensor_friendly_name", "Reminder") self.fetch_interval = self.args.get("fetch_interval", DEFAULT_FETCH_INTERVAL) self.reminder_offset = self.args.get("reminder_offset", DEFAULT_REMINDER_OFFSET) self.skip_days = self.args.get("skip_days", AppUtils.DEFAULT_SKIP_DAYS) self.skip_dates = AppUtils.get_skip_dates(self.args.get("skip_dates")) self.start_hour = self.args.get("start_hour", DEFAULT_START_HOUR) self.end_hour = self.args.get("end_hour", DEFAULT_END_HOUR) # In test mode, data is downloaded once and saved to a local file "basic.ics" for future use. # No announcements are send. This mode can be combined with "time travel" flags for testing. # https://appdaemon.readthedocs.io/en/latest/INSTALL.html?highlight=Time%20Travel#appdaemon-arguments # e.g. appdaemon -c ~/appdaemon_config/ -s "2021-02-15 09:00:00" -t 5 self.test_mode = self.args.get("test_mode", False) reminder_offset = self.reminder_offset if self.fetch_interval <= reminder_offset: raise Exception( f"fetch_interval '{self.fetch_interval}' should be more than reminder_offset '{reminder_offset}'." # noqa: E501 ) # now = self.get_now() # localTZ = pytz.timezone(self.get_timezone()) # self.log(now) # self.log(now.astimezone(localTZ)) # This is the same as before self.log( f"Initialized at {self.datetime(True)} skipping days {self.skip_days}" ) if self.test_mode: CURR_DIR = os.path.dirname(os.path.realpath(__file__)) data_file = os.path.join(CURR_DIR, "basic.ics") if os.path.exists(data_file): f = open(data_file, "r") self.test_cached_feed_text = f.read() self.log("Using cached data") self.events = {} self.scheduled_event_uids = [] self.set_reminder_sensor("None", None) # Start listening to no_school input_boolean sensor if self.no_reminder_today_sensor: self.listen_state(self.no_school_status_changed, self.no_reminder_today_sensor) self.set_recurring_fetch()
def run(): if not AppUtils.checkInputOLR(ARGVS.fi, PY_FILE, PARSER_INPUTS): return if not AppUtils.checkInputPK(ARGVS.pk, 'Bus', PY_FILE, PARSER_INPUTS): return # OlxAPILib.open_olrFile(ARGVS.fi, ARGVS.olxpath) # sres = 'App: ' + PY_FILE sres += '\nUser: '******'\nDate: ' + time.asctime() sres += '\nOLR file: ' + ARGVS.fi print('Selected Bus: ', str(ARGVS.pk)) for i in range(len(ARGVS.pk)): sres += '\n\nSelected Bus:' + ARGVS.pk[i] # get handle of object picked up bhnd = OlxAPILib.FindObj1LPF_check(ARGVS.pk[i], TC_BUS) # br_res, bus_res = getRemoteTerminals(bhnd) sres += getRemoteTerminals_str(br_res, bus_res) # ARGVS.fo = AppUtils.get_file_out(fo=ARGVS.fo, fi=ARGVS.fi, subf='', ad='_res', ext='.txt') # AppUtils.saveString2File(ARGVS.fo, sres) print("\nReport file had been saved in:\n" + ARGVS.fo) if ARGVS.ut == 0: AppUtils.launch_notepad(ARGVS.fo) return 1
def run(): if not AppUtils.checkInputOLR(ARGVS.fi,PY_FILE,PARSER_INPUTS): return if not AppUtils.checkInputPK(ARGVS.pk,'Bus',PY_FILE,PARSER_INPUTS): return # sr = ''#"\nOLR file: " + os.path.abspath(ARGVS.fi) # OlxAPILib.open_olrFile(ARGVS.fi,ARGVS.olxpath) # print("Selected BUS: "+ str(ARGVS.pk)) for i in range(len(ARGVS.pk)): # get handle of object picked up bhnd = OlxAPILib.FindObj1LPF_check(ARGVS.pk[i],TC_BUS) sb = OlxAPILib.fullBusName(bhnd).ljust(25) +' : BUS FOUND' sr+= "\n"+sb print(sb) # sr += "\nFault, PhaseA, PhaseB, PhaseC, R0+jX0, R1+jX1, R2+jX2, X/R" # sr+= do1busFlt1(bhnd) + "\n" #update file out ARGVS.fo = AppUtils.get_file_out(fo=ARGVS.fo , fi=ARGVS.fi , subf='res' , ad='' , ext='.csv') AppUtils.saveString2File(ARGVS.fo,sr) print('\nReport file had been saved in:\n%s'%ARGVS.fo) if ARGVS.ut ==0: AppUtils.launch_excel(ARGVS.fo) return 1
def run(): if not AppUtils.checkInputOLR(ARGVS.fi, PY_FILE, PARSER_INPUTS): return if not AppUtils.checkInputPK(ARGVS.pk, 'Bus', PY_FILE, PARSER_INPUTS): return # OlxAPILib.open_olrFile(ARGVS.fi, ARGVS.olxpath) # get handle of object picked up print("Selected BUS: " + str(ARGVS.pk)) bhnd = OlxAPILib.FindObj1LPF_check(ARGVS.pk[0], TC_BUS) # # sr = "\nOLR file: " + os.path.abspath(ARGVS.fi) sr = '\n' + OlxAPILib.fullBusName(bhnd).ljust(25) + ' : BUS FOUND' print(sr) sr += "\n\nBUS FAULT REPORT" sr += "\n ,Phase A ,Phase B ,Phase C" sr += do1busFlt(bhnd) #update file out ARGVS.fo = AppUtils.get_file_out(fo=ARGVS.fo, fi=ARGVS.fi, subf='res', ad='', ext='.csv') # AppUtils.saveString2File(ARGVS.fo, sr) # print('\nReport file had been saved in:\n%s' % ARGVS.fo) if ARGVS.ut == 0: AppUtils.launch_excel(ARGVS.fo) return 1
def run_demo(): if ARGVS.demo == 1: ARGVS.fi = AppUtils.getASPENFile(PATH_FILE, 'SAMPLE30.OLR') ARGVS.fo = AppUtils.get_file_out( fo='', fi=ARGVS.fi, subf='', ad='_' + os.path.splitext(PY_FILE)[0] + '_demo', ext='.csv') ARGVS.ft = os.path.join(PATH_FILE, 'InputTemplate2018.xlsx') # choice = AppUtils.ask_run_demo(PY_FILE, ARGVS.ut, ARGVS.fi, "Input template file: " + ARGVS.ft) # if choice == "yes": return run() else: AppUtils.demo_notFound(PY_FILE, ARGVS.demo, [1])
def runBoundaryEquivalent(self): # ARGVS.fo = AppUtils.get_file_out(fo=ARGVS.fo, fi=ARGVS.fi, subf='res', ad='_res', ext='.OLR') # opt = [ARGVS.opt1, ARGVS.opt2, ARGVS.opt3] OlxAPILib.BoundaryEquivalent(ARGVS.fo, list(self.busA), opt) # OlxAPI.CloseDataFile() if not os.path.isfile(ARGVS.fo): raise Exception(" Run BoundaryEquivalent") # if ARGVS.gui > 0 and ARGVS.ut == 0: AppUtils.launch_OneLiner(ARGVS.fo) print('\nOLR result file had been saved in:\n"%s"' % ARGVS.fo)
def run_demo(): if ARGVS.demo == 1: ARGVS.fi = AppUtils.getASPENFile(PATH_FILE, 'SAMPLE30.OLR') ARGVS.pk = ["[RELAYGROUP] 2 'CLAYTOR' 132 kV-6 'NEVADA' 132 kV 1 L"] ARGVS.fo = AppUtils.get_file_out( fo='', fi=ARGVS.fi, subf='', ad='_' + os.path.splitext(PY_FILE)[0] + '_demo', ext='.txt') # choice = AppUtils.ask_run_demo( PY_FILE, ARGVS.ut, ARGVS.fi, "Selected Relay Group: " + str(ARGVS.pk)) if choice == "yes": return run() else: AppUtils.demo_notFound(PY_FILE, ARGVS.demo, [1]) return 0
def run_demo(): if ARGVS.demo == 1: ARGVS.fi = AppUtils.getASPENFile('', 'SAMPLE30.OLR') ARGVS.fo = AppUtils.get_file_out( fo='', fi=ARGVS.fi, subf='', ad='_' + os.path.splitext(PY_FILE)[0] + '_demo', ext='.OLR') ARGVS.pk = [ "[XFORMER3] 6 'NEVADA' 132 kV-10 'NEVADA' 33 kV-'DOT BUS' 13.8 kV 1" ] ARGVS.ti = 1 ARGVS.ar = [] ARGVS.zo = [] # choice = AppUtils.ask_run_demo(PY_FILE, ARGVS.ut, ARGVS.fi, "Selected Object: " + str(ARGVS.pk)) if choice == "yes": return run() else: AppUtils.demo_notFound(PY_FILE, ARGVS.demo, [1])
def run(): if not AppUtils.checkInputOLR(ARGVS.fi, PY_FILE, PARSER_INPUTS): return if not AppUtils.checkInputPK(ARGVS.pk, 'Relay Group', PY_FILE, PARSER_INPUTS): return # OlxAPILib.open_olrFile(ARGVS.fi, ARGVS.olxpath) # bhnd, tc = OlxAPILib.FindObj1LPF(ARGVS.pk[0]) if tc != TC_RLYGROUP: s = "\nNo Relay Group is selected: " + str( ARGVS.pk) + "\nUnable to continue." return AppUtils.FinishCheck(PY_FILE, s, PARSER_INPUTS) # br1 = OlxAPILib.getEquipmentData([bhnd], RG_nBranchHnd)[0] b1 = OlxAPILib.getEquipmentData([br1], BR_nBus1Hnd)[0] nTap1 = OlxAPILib.getEquipmentData([b1], BUS_nTapBus)[0] inSer1 = OlxAPILib.getEquipmentData([br1], BR_nInService)[0] sLocal = "Local Relay Group: " + OlxAPILib.fullBranchName(br1) if nTap1 > 0: s = '\n' + sLocal + "\n\tis located at a TAP bus. Unable to continue." return AppUtils.FinishCheck(PY_FILE, s, None) # if inSer1 != 1: s = '\n' + sLocal + "\n\tis located on out-of-service branch. Unable to continue." return AppUtils.FinishCheck(PY_FILE, s, None) # kr = 0 sres = "" bres = OlxAPILib.getOppositeBranch( hndBr=br1, typeConsi=[] ) # consider all type [TC_LINE,TC_SWITCH,TC_SCAP,TC_PS,TC_XFMR,TC_XFMR3] # for bri in bres: rg1 = -1 try: rg1 = OlxAPILib.getEquipmentData([bri], BR_nRlyGrp1Hnd)[0] except: pass # if rg1 > 0: kr += 1 sres += "\n\t" + OlxAPILib.fullBranchName(bri) # s0 = 'App: ' + PY_FILE s0 += '\nUser: '******'\nDate: ' + time.asctime() s0 += '\nOLR file: ' + ARGVS.fi s0 += '\n\nSelected Relay Group:' + str(ARGVS.pk[0]) if kr > 1: s0 += "\nRemote groups (" + str(kr) + "):" else: s0 += "\nRemote group (" + str(kr) + "):" # ARGVS.fo = AppUtils.get_file_out(fo=ARGVS.fo, fi=ARGVS.fi, subf='res', ad='_res', ext='.txt') # AppUtils.saveString2File(ARGVS.fo, s0 + sres) print("\nReport file had been saved in:\n" + ARGVS.fo) if ARGVS.ut == 0: AppUtils.launch_notepadpp(ARGVS.fo) return 1
__version__ = "1.2.1" # IMPORT ----------------------------------------------------------------------- import sys, os, time PATH_FILE, PY_FILE = os.path.split(os.path.abspath(__file__)) PATH_LIB = os.path.split(PATH_FILE)[0] if PATH_LIB not in sys.path: os.environ['PATH'] = PATH_LIB + ";" + os.environ['PATH'] sys.path.insert(0, PATH_LIB) # import OlxAPILib from OlxAPIConst import * import AppUtils # INPUTS cmdline --------------------------------------------------------------- PARSER_INPUTS = AppUtils.iniInput( usage= "\n\tList the Relay Group(s) on the remoted terminal(s)\n\tof the selected line or transformer" ) PARSER_INPUTS.add_argument('-fi', metavar='', help='*(str) OLR input file', default="") PARSER_INPUTS.add_argument( '-pk', metavar='', help='*(str) Selected Relay Group in the 1-line diagram', default=[], nargs='+') PARSER_INPUTS.add_argument('-fo', metavar='', help=' (str) Path name of the report file', default="")
# IMPORT ----------------------------------------------------------------------- import sys, os, time PATH_FILE, PY_FILE = os.path.split(os.path.abspath(__file__)) PATH_LIB = os.path.split(PATH_FILE)[0] if PATH_LIB not in sys.path: os.environ['PATH'] = PATH_LIB + ";" + os.environ['PATH'] sys.path.insert(0, PATH_LIB) # import OlxAPILib from OlxAPIConst import * import AppUtils # INPUTS cmdline --------------------------------------------------------------- PARSER_INPUTS = AppUtils.iniInput( usage="\n\tList all remote end of all branches of the selected bus\ \n\tAll taps are ignored. Close switches are included") PARSER_INPUTS.add_argument('-fi', help='*(str) OLR file path', default="", metavar='') PARSER_INPUTS.add_argument('-pk', help='*(str) Selected Bus in the 1-line diagram', default=[], nargs='+', metavar='') PARSER_INPUTS.add_argument('-fo', help=' (str) Path name of the report file', default="", metavar='') ARGVS = AppUtils.parseInput(PARSER_INPUTS, demo=1)
def run(): if not AppUtils.checkInputOLR(ARGVS.fi, PY_FILE, PARSER_INPUTS): return False # if type(ARGVS.op) != list: op = [ARGVS.op] else: op = ARGVS.op vd = { 1: '-Check XFMR', 2: '-GEN34 VCCS', 3: '-Check Duplicate (CID, BusNumber)', 4: '-Check Line', 5: '-Check Memo' } for op1 in op: if op1 not in vd.keys(): se = 'ValueError of op=' + str(op1) for k, v in vd.items(): se += '\n\top=' + str(k) + ':' + str(v) raise Exception(se) print('\nCheck: ' + str(vd[op1])) # load_olxapi(ARGVS.olxpath) OLCase.open(ARGVS.fi, 1) fr = AppUtils.get_file_out(fo=ARGVS.fo, fi=ARGVS.fi, subf='', ad='_CheckNetwork_Report', ext='.CSV') f1 = open(fr, "w") fwriter = csv.writer(f1, quotechar="'", lineterminator="\n") fwriter.writerow([ '', 'CheckNetwork version=%s Date:%s' % (__version__, time.asctime()) ]) fwriter.writerow(['', 'OLR file:%s' % ARGVS.fi]) # if (0 in op) or (1 in op): cx = CHECK_XFMR(fwriter) cx.checkConfig() # if (0 in op) or (2 in op): cx = CHECK_GENW34_VCCS(fwriter) cx.check1() cx.check2() cx.check3() cx.check4() # if (0 in op) or (3 in op): cx = CHECK_DUPLICATE(fwriter) cx.check_Loadunit() cx.check_Genunit() cx.check_Shuntunit() cx.checkBusNumber() # if (0 in op) or (4 in op): cx = CHECK_LINE(fwriter) cx.checkLineRX() cx.checkLineType() # if (0 in op) or (5 in op): cx = CHECK_MEMO(fwriter) cx.check() fo = AppUtils.get_file_out(fo=ARGVS.fo, fi=ARGVS.fi, subf='', ad='_CheckNetwork', ext='.OLR') OLCase.save(fo) OLCase.close() f1.close() print('\nChecking report:', fr) print('Updated network:', fo)
# def main(): AppUtils.logger2File(PY_FILE, version=__version__) # global FRUNNING, SRUNNING FRUNNING, SRUNNING = AppUtils.markerStart(ARGVS.opath) if ARGVS.demo > 0: return run_demo() run() # if __name__ == '__main__': ## ARGVS.op = 1 ## ARGVS.fi = 'sample\\CN01.OLR' # ARGVS.fi = 'sample\\ieee9_w4.OLR' # ARGVS.fi = 'sample\\CN02.OLR' # ARGVS.fi = 'sample\\BIGTEST1_0Relay.OLR' # ARGVS.fi = 'sample\\BIGTEST2_0Relay.OLR' # ARGVS.fi = 'sample\\BIGTEST3_0Relay.OLR' ## ARGVS.fi = 'sample\\BIGTEST4_0Relay.OLR' ## ARGVS.fi = 'sample\\ECIM_5tierNew_anon_iniCN_deleteSw.OLR' ## ARGVS.fi = 'sample\\S01.OLR' ## ARGVS.fi = 'sample\\problem_x2.olr' try: main() AppUtils.markerSucces(ARGVS.opath) except Exception as err: AppUtils.FinishException(PY_FILE, err)
def run(): if not checkInput(): return print("Template file: " + ARGVS.ft) print("IEEE-1584 2018") # import xml.etree.ElementTree as ET # update file out ARGVS.fo = AppUtils.get_file_out(fo=ARGVS.fo, fi=ARGVS.fi, subf='', ad='', ext='.csv') # OlxAPILib.open_olrFile(ARGVS.fi, ARGVS.olxpath) # ws = AppUtils.ToolCSVExcell() ws.readFile(fi=ARGVS.ft, delim=',') # nSuccess = 0 # for i in range(7, 10000): if ws.getVal(row=i, column=1) == None: break # sbus = getStrBus(ws, i) if sbus != "": if str(ws.getVal( row=6, column=4)) == "Electrode config": # standardYear = 2018 data = ET.Element('ARCFLASHCALCULATOR2018') data.set('REPFILENAME', ARGVS.fo) # fo data.set('OUTFILETYPE', '2') # csv file if nSuccess == 0: data.set('APPENDREPORT', '0') else: data.set('APPENDREPORT', '1') # data.set('SELECTEDOBJ', sbus) # bus data.set('ELECTRODECFG', str(ws.getVal(row=i, column=4))) data.set('BOXH', str(ws.getVal(row=i, column=5))) data.set('BOXW', str(ws.getVal(row=i, column=6))) data.set('BOXD', str(ws.getVal(row=i, column=7))) data.set('CONDUCTORGAP', str(ws.getVal(row=i, column=8))) data.set('WORKDIST', str(ws.getVal(row=i, column=9))) data.set('BRKINTTIME', str(ws.getVal(row=i, column=10))) data.set('ARCDURATION', str(ws.getVal(row=i, column=11))) if str(ws.getVal(row=i, column=11)) == "FUSE": data.set('FUSECURVE', str(ws.getVal(row=i, column=12))) elif str(ws.getVal(row=i, column=11)) == "FIXED": data.set('ARCTIME', str(ws.getVal(row=i, column=12))) elif str(ws.getVal(row=i, column=11)) == "FASTEST": data.set('DEVICETIERS', str(ws.getVal(row=i, column=12))) #------------------------------------------------------------------- elif str(ws.getVal( row=6, column=4)) == "Equipment Category": # standardYear = 2012 raise Exception("Not yet support for standardYear = 2012") # else: raise Exception("Error Template File") # sInput = ET.tostring(data) # if OlxAPILib.run1LPFCommand(sInput): nSuccess += 1 # if nSuccess > 0: print("\nArc-flash calculation ran successfully on " + str(nSuccess) + " buses") print("Report file had been saved in:\n%s" % ARGVS.fo) # open res in Excel if ARGVS.ut == 0: AppUtils.launch_excel(ARGVS.fo) else: print( "Something was not right (no bus found). No arc flash calculation results." ) return 1
from OlxAPIConst import * import AppUtils # INPUTS cmdline --------------------------------------------------------------- PARSER_INPUTS = AppUtils.iniInput( usage="\n\tRun DoArcFlash with input data from a template file\ \n\tin CSV/Excel format with columns (fields) in following order:\ \n\ \nIEEE-1584 2018 Arc flash\ \n 1. 'No.' - Bus number (optional)\ \n 2. 'Bus Name' - bus name\ \n 3. 'kV' - bus kv\ \n 4. 'Electrode config' - 0: VCB 1: VCBB 2: HCB 3: VOA 4: HOA\ \n 5. 'Enclosure H (in.)' - Applicable for electrode configs VCB, VCBB, HCB\ \n 6. 'Enclosure W (in.)' - Applicable for electrode configs VCB, VCBB, HCB\ \n 7. 'Enclosure D (in.)' - Applicable for electrode configs VCB, VCBB, HCB at voltage 600V or lower\ \n 8. 'Conductor Gap (mm)'\ \n 9. 'Working Distance (inches)'\ \n 10. 'Breaker interrupting Time (cycles)'\ \n 11. 'Fault Clearing' - FUSE: Use fuse curve\ \n - FIXED: Use fixed duration\ \n - FASTEST: Use fastest trip time of device in vicinity\ \n 12. 'Fault clearing option\ \n - For clearing time option FASTEST: NO of tiers\ \n - For clearing time option FIXED: Fixed delay\ \n - For clearing Time Option FUSE: fuse LibraryName:CurveName" ) # ft_default = os.path.join(PATH_FILE, 'InputTemplate2018.xlsx') if not os.path.isfile(ft_default): ft_default = ''