Exemplo n.º 1
0
def main():
    local_tselector = iec61850.TSelector()
    local_tselector.size = 2
    local_tselector.value = [0, 1]
    local_sselector = iec61850.SSelector()
    local_sselector.size = 2
    local_sselector.value = [0, 1]
    local_pselector = iec61850.PSelector()
    local_pselector.size = 4
    local_pselector.value = [0, 0, 0, 1]
    remote_tselector = iec61850.TSelector()
    remote_tselector.size = 2
    remote_tselector.value = [0, 1]
    remote_sselector = iec61850.SSelector()
    remote_sselector.size = 2
    remote_sselector.value = [0, 1]
    remote_pselector = iec61850.PSelector()
    remote_pselector.size = 4
    remote_pselector.value = [0, 0, 0, 1]
    mms_connection = iec61850.MmsConnection_createWisop(
        "1.2.32.2", 1, local_tselector, local_sselector, local_pselector,
        "1.2.3", 21, remote_tselector, remote_sselector, remote_pselector)
    mmsError = iec61850.toMmsErrorP()
    conn = iec61850.MmsConnection_connect(mms_connection, mmsError,
                                          remote_server, remote_port)

    if (conn):
        print("Connection established!\n")
        vars = iec61850.LinkedList_create()
        name = iec61850.MmsVariableAccessSpecification_create(
            domain, "Transfer_Set_Name")
        tst = iec61850.MmsVariableAccessSpecification_create(
            domain, "Transfer_Set_Time_Stamp")
        dsc = iec61850.MmsVariableAccessSpecification_create(
            domain, "DSConditions_Detected")
        iec61850.LinkedList_add(vars, name)
        iec61850.LinkedList_add(vars, tst)
        iec61850.LinkedList_add(vars, dsc)

        iec61850.MmsConnection_defineNamedVariableList(mms_connection,
                                                       mmsError, domain,
                                                       ds_name, vars)

        for item in itemId:
            value = iec61850.MmsConnection_readVariable(
                mms_connection, mmsError, domain, item)
            val_part1 = iec61850.MmsValue_toDouble(
                iec61850.MmsValue_getElement(value, 0))
            val_part2 = iec61850.MmsValue_getElement(value, 1)
            bitstring_size = iec61850.MmsValue_getBitStringSize(val_part2)
            print(item)
            print("value: %s" % val_part1)
            print("bitstring_size: %s" % bitstring_size)
            for i in range(bitstring_size):
                print("bitstring_value: %s" %
                      iec61850.MmsValue_getBitStringBit(val_part2, i))
    else:
        print("Connection failed!\n")
Exemplo n.º 2
0
def main():
    local_tselector = iec61850.TSelector()
    local_tselector.size = 2
    local_tselector.value = [0, 1]
    local_sselector = iec61850.SSelector()
    local_sselector.size = 2
    local_sselector.value = [0, 1]
    local_pselector = iec61850.PSelector()
    local_pselector.size = 4
    local_pselector.value = [0, 0, 0, 1]
    remote_tselector = iec61850.TSelector()
    remote_tselector.size = 2
    remote_tselector.value = [0, 1]
    remote_sselector = iec61850.SSelector()
    remote_sselector.size = 2
    remote_sselector.value = [0, 1]
    remote_pselector = iec61850.PSelector()
    remote_pselector.size = 4
    remote_pselector.value = [0, 0, 0, 1]
    mms_connection = iec61850.MmsConnection_createWisop(
        "1.2.32.2", 1, local_tselector, local_sselector, local_pselector,
        "1.2.3", 21, remote_tselector, remote_sselector, remote_pselector)
    mmsError = iec61850.toMmsErrorP()
    conn = iec61850.MmsConnection_connect(mms_connection, mmsError,
                                          remote_server, remote_port)

    if (conn):
        print("Connection established!\n")
        value = iec61850.MmsValue_newInteger(1)
        print("Set cmd to: ", sys.argv[1])
        for item in itemId:
            if (sys.argv[1] == "ON"):
                iec61850.MmsValue_setInt8(value, 1)
            elif (sys.argv[1] == "OFF"):
                iec61850.MmsValue_setInt8(value, 0)
            else:
                print("Unknown command!\n")

            result = iec61850.MmsConnection_writeVariable(
                mms_connection, mmsError, domain, item, value)
            print(result)
    else:
        print("Connection failed!\n")
Exemplo n.º 3
0
def init_iccp(conf_file):
    global conn
    global vcc
    global conf
    success = False
    # create tase2 conf from file
    iccpconf = IccpConf.create_from_file(conf_file)

    # create IccpConnection
    if (iccpconf.use_defaults == True):
        mms_connection = iec61850.MmsConnection_create()
    else:
        # connecting with custom ISO parameters: TSelector, SSelector, PSelector, AP-Title, AE-Qualifier
        local_tselector = iec61850.TSelector()
        local_tselector.size = len(iccpconf.local_tselector)
        local_tselector.value = iccpconf.local_tselector
        local_sselector = iec61850.SSelector()
        local_sselector.size = len(iccpconf.local_sselector)
        local_sselector.value = iccpconf.local_sselector
        local_pselector = iec61850.PSelector()
        local_pselector.size = len(iccpconf.local_pselector)
        local_pselector.value = iccpconf.local_pselector
        remote_tselector = iec61850.TSelector()
        remote_tselector.size = len(iccpconf.remote_tselector)
        remote_tselector.value = iccpconf.remote_tselector
        remote_sselector = iec61850.SSelector()
        remote_sselector.size = len(iccpconf.remote_sselector)
        remote_sselector.value = iccpconf.remote_sselector
        remote_pselector = iec61850.PSelector()
        remote_pselector.size = len(iccpconf.remote_pselector)
        remote_pselector.value = iccpconf.remote_pselector
        mms_connection = iec61850.MmsConnection_createWisop(
            iccpconf.local_ap_title, iccpconf.local_ae_qual, local_tselector,
            local_sselector, local_pselector, iccpconf.remote_ap_title,
            iccpconf.remote_ae_qual, remote_tselector, remote_sselector,
            remote_pselector)
    remote_server = iccpconf.remote_server
    remote_port = iccpconf.remote_port
    conn = IccpConnection(mms_connection, remote_server, remote_port)

    # create VCC
    # create bilateral table
    ap_title = iccpconf.remote_ap_title
    blt_id = iccpconf.blt_id
    blt_version = iccpconf.blt_version
    tase2_version = iccpconf.tase2_version
    bilateraltable = BilateralTable(ap_title, blt_id, blt_version,
                                    tase2_version)

    domain = iccpconf.domain
    vcc = VCC(bilateraltable, domain)

    # create Association
    assoc_id = iccpconf.assoc_id
    ae_title = iccpconf.ae_title
    assoc = Association(assoc_id, ae_title, 0, None)
    vcc.add_assoc_to_vcc(assoc)

    success = True

    return success
Exemplo n.º 4
0
#!/usr/bin/env python
# coding: utf-8
# info
__version__ = "0.1"

import iec61850

local_tselector = iec61850.TSelector()
local_tselector.size = 2
local_tselector.value = [0, 1]
local_sselector = iec61850.SSelector()
local_sselector.size = 2
local_sselector.value = [0, 1]
local_pselector = iec61850.PSelector()
local_pselector.size = 4
local_pselector.value = [0, 0, 0, 1]
remote_tselector = iec61850.TSelector()
remote_tselector.size = 2
remote_tselector.value = [0, 1]
remote_sselector = iec61850.SSelector()
remote_sselector.size = 2
remote_sselector.value = [0, 1]
remote_pselector = iec61850.PSelector()
remote_pselector.size = 4
remote_pselector.value = [0, 0, 0, 1]
mms_connection = iec61850.MmsConnection_createWisop(
    "1.2.32.2", 1, local_tselector, local_sselector, local_pselector, "1.2.3",
    21, remote_tselector, remote_sselector, remote_pselector)
remote_server = "10.132.0.110"
remote_port = 102
mmsError = iec61850.toMmsErrorP()
Exemplo n.º 5
0
def main():
    local_tselector = iec61850.TSelector()
    local_tselector.size = 2
    local_tselector.value = [0, 1]
    local_sselector = iec61850.SSelector()
    local_sselector.size = 2
    local_sselector.value = [0, 1]
    local_pselector = iec61850.PSelector()
    local_pselector.size = 4
    local_pselector.value = [0, 0, 0, 1]
    remote_tselector = iec61850.TSelector()
    remote_tselector.size = 2
    remote_tselector.value = [0, 1]
    remote_sselector = iec61850.SSelector()
    remote_sselector.size = 2
    remote_sselector.value = [0, 1]
    remote_pselector = iec61850.PSelector()
    remote_pselector.size = 4
    remote_pselector.value = [0, 0, 0, 1]
    mms_connection = iec61850.MmsConnection_createWisop(
        "1.2.32.2", 1, local_tselector, local_sselector, local_pselector,
        "1.2.3", 21, remote_tselector, remote_sselector, remote_pselector)
    mmsError = iec61850.toMmsErrorP()
    result = iec61850.MmsConnection_connect(mms_connection, mmsError,
                                            remote_server, remote_port)

    iec61850.MmsConnection_deleteNamedVariableList(mms_connection, mmsError,
                                                   domain, ds_name)

    handler = iec61850.informationReportHandler_create()

    iec61850.MmsConnection_setInformationReportHandler(mms_connection, handler,
                                                       mms_connection)

    vars = iec61850.LinkedList_create()
    #name = iec61850.MmsVariableAccessSpecification_create(domain, "Transfer_Set_Name")
    #tst = iec61850.MmsVariableAccessSpecification_create(domain, "Transfer_Set_Time_Stamp")
    #dsc = iec61850.MmsVariableAccessSpecification_create(domain, "DSConditions_Detected")
    #iec61850.LinkedList_add(vars, name)
    #iec61850.LinkedList_add(vars, tst)
    #iec61850.LinkedList_add(vars, dsc)

    var = iec61850.MmsVariableAccessSpecification_create(domain, "tm1")
    iec61850.LinkedList_add(vars, var)

    iec61850.MmsConnection_defineNamedVariableList(mms_connection, mmsError,
                                                   domain, ds_name, vars)

    next_ts = iec61850.MmsConnection_readVariable(mms_connection, mmsError,
                                                  domain,
                                                  "Next_DSTransfer_Set")
    ts_name = iec61850.MmsValue_toString(
        iec61850.MmsValue_getElement(next_ts, 2))

    try:
        iec61850.write_dataset(
            mms_connection, domain, ds_name, ts_name, buffer_time,
            integrity_time,
            REPORT_INTERVAL_TIMEOUT | REPORT_OBJECT_CHANGES | REPORT_BUFFERED)

        print("Writing dataset successful")
    except:
        print("Error writing dataset")
        pass