Example #1
0
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
Example #2
0
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
Example #3
0
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
Example #4
0
    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)
Example #5
0
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])
Example #6
0
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])
Example #7
0
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])
Example #8
0
 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)
Example #9
0
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
Example #10
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])
Example #11
0
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
Example #12
0
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)
Example #13
0
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
Example #14
0
def run():
    """
      Check phase shift of all 2-winding transformers with wye-delta connection.
          When a transformer with high side lagging the low side is found,
          this function converts it to make the high side lead.

        Args :
            None
        Returns:
            string result
            OLR corrected file

        Raises:
            OlrxAPIException
    """
    #
    if not AppUtils.checkInputOLR(ARGVS.fi, PY_FILE, PARSER_INPUTS):
        return
    #
    OlxAPILib.open_olrFile_1(ARGVS.olxpath, ARGVS.fi, readonly=1)
    s1 = ""
    # get all xfmr
    x2a = OlxAPILib.getEquipmentHandle(TC_XFMR)
    kd = 0
    for x1 in x2a:
        configA = OlxAPILib.getEquipmentData([x1], XR_sCfg1)[0]
        configB = OlxAPILib.getEquipmentData([x1], XR_sCfg2)[0]
        tapA = OlxAPILib.getEquipmentData([x1], XR_dTap1)[0]
        tapB = OlxAPILib.getEquipmentData([x1], XR_dTap2)[0]
        #
        test = False

        # low - hight  =>  low - hight
        #   G   - D             G  - E
        if (tapA < tapB) and configA == "G" and configB == "D":
            test = True
            # set
            OlxAPILib.setData(x1, XR_sCfg2, "E")
            # validation
            OlxAPILib.postData(x1)

        # low - small  =>  low - small
        #  G    - E              G - D
        if (tapA > tapB) and configA == "G" and configB == "E":
            test = True
            # set
            OlxAPILib.setData(x1, XR_sCfg2, "D")
            # validation
            OlxAPILib.postData(x1)
        #
        if test:
            kd += 1
            s1 += '\n' + str(kd).ljust(5) + OlxAPILib.fullBranchName(x1)
    #
    if kd > 0:
        s2 = "Fixed (" + str(
            kd
        ) + ") wye-delta transformers to make the high side lead the low side:"
    else:
        s2 = "All wye-delta transformers in this OLR file have the correct phase shift of the high-side leading the low-side."
    #
    print(s2 + s1)
    #
    if kd > 0:
        ARGVS.fo = AppUtils.get_file_out(fo=ARGVS.fo,
                                         fi=ARGVS.fi,
                                         subf='',
                                         ad='_res',
                                         ext='.OLR')
        #
        OlxAPILib.saveAsOlr(ARGVS.fo)
        if ARGVS.ut == 0:
            print("The modified network had been saved as:\n" + ARGVS.fo)
            AppUtils.launch_OneLiner(ARGVS.fo)
    #
    return s2 + s1