コード例 #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
コード例 #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
コード例 #3
0
ファイル: linez.py プロジェクト: aspeninc/pyOlxAPI
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
コード例 #4
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
コード例 #5
0
ファイル: ArcFlashEx.py プロジェクト: aspeninc/pyOlxAPI
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
コード例 #6
0
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
コード例 #7
0
ファイル: lineterm.py プロジェクト: aspeninc/pyOlxAPI
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
コード例 #8
0
ファイル: CheckNetwork.py プロジェクト: aspeninc/pyOlxAPI
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)
コード例 #9
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