コード例 #1
0
ファイル: master.py プロジェクト: vitormhenrique/pydnp3
def restart_callback(result=opendnp3.RestartOperationResult()):
    if result.summary == opendnp3.TaskCompletion.SUCCESS:
        print("Restart success | Restart Time: {}".format(
            result.restartTime.GetMilliseconds()))
    else:
        print("Restart fail | Failure: {}".format(
            opendnp3.TaskCompletionToString(result.summary)))
コード例 #2
0
ファイル: dnp3_master.py プロジェクト: tpktang/volttron
def command_callback(result=None):
    """
    :type result: opendnp3.ICommandTaskResult
    """
    print("Received command result with summary: {}".format(
        opendnp3.TaskCompletionToString(result.summary)))
    result.ForeachItem(collection_callback)
コード例 #3
0
 def test_enum_type_to_string(self):
     """
         Convert the enumeration member to string, and test is it returns the correct string.
     """
     assert opendnp3.AuthErrorCodeToString(
         opendnp3.AuthErrorCode.AUTHORIZATION_FAILED
     ) == "AUTHORIZATION_FAILED"
     assert opendnp3.CertificateTypeToString(
         opendnp3.CertificateType.ID_CERTIFICATE) == "ID_CERTIFICATE"
     assert opendnp3.ChallengeReasonToString(
         opendnp3.ChallengeReason.CRITICAL) == "CRITICAL"
     assert opendnp3.ChannelStateToString(
         opendnp3.ChannelState.CLOSED) == "CLOSED"
     assert opendnp3.CommandPointStateToString(
         opendnp3.CommandPointState.SELECT_SUCCESS) == "SELECT_SUCCESS"
     assert opendnp3.CommandStatusToString(
         opendnp3.CommandStatus.DOWNSTREAM_FAIL) == "DOWNSTREAM_FAIL"
     assert opendnp3.ControlCodeToString(
         opendnp3.ControlCode.LATCH_ON) == "LATCH_ON"
     assert opendnp3.DoubleBitToString(
         opendnp3.DoubleBit.INTERMEDIATE) == "INTERMEDIATE"
     assert opendnp3.FlagsTypeToString(
         opendnp3.FlagsType.DoubleBinaryInput) == "DoubleBinaryInput"
     assert opendnp3.FlowControlToString(
         opendnp3.FlowControl.Hardware) == "Hardware"
     assert opendnp3.FunctionCodeToString(
         opendnp3.FunctionCode.GET_FILE_INFO) == "GET_FILE_INFO"
     assert opendnp3.GroupVariationToString(
         opendnp3.GroupVariation.Group1Var0
     ) == "Binary Input - Any Variation"
     assert opendnp3.HMACTypeToString(
         opendnp3.HMACType.NO_MAC_VALUE) == "NO_MAC_VALUE"
     assert opendnp3.IntervalUnitsToString(
         opendnp3.IntervalUnits.Months9) == "Months9"
     assert opendnp3.KeyChangeMethodToString(
         opendnp3.KeyChangeMethod.AES_128_SHA1_HMAC) == "AES_128_SHA1_HMAC"
     assert opendnp3.KeyStatusToString(
         opendnp3.KeyStatus.COMM_FAIL) == "COMM_FAIL"
     assert opendnp3.KeyWrapAlgorithmToString(
         opendnp3.KeyWrapAlgorithm.AES_128) == "AES_128"
     assert opendnp3.LinkFunctionToString(
         opendnp3.LinkFunction.PRI_CONFIRMED_USER_DATA
     ) == "PRI_CONFIRMED_USER_DATA"
     assert opendnp3.MasterTaskTypeToString(
         opendnp3.MasterTaskType.CLEAR_RESTART) == "CLEAR_RESTART"
     assert opendnp3.ParityToString(opendnp3.Parity.Odd) == "Odd"
     assert opendnp3.QualifierCodeToString(
         opendnp3.QualifierCode.UINT8_START_STOP) == "8-bit start stop"
     assert opendnp3.StopBitsToString(
         opendnp3.StopBits.OnePointFive) == "OnePointFive"
     assert opendnp3.TaskCompletionToString(
         opendnp3.TaskCompletion.FAILURE_BAD_RESPONSE
     ) == "FAILURE_BAD_RESPONSE"
     assert opendnp3.UserOperationToString(
         opendnp3.UserOperation.OP_UNDEFINED) == "OP_UNDEFINED"
     assert opendnp3.UserRoleToString(opendnp3.UserRole.VIEWER) == "VIEWER"
コード例 #4
0
ファイル: dnp3_master.py プロジェクト: tpktang/volttron
def restart_callback(result=opendnp3.RestartOperationResult()):
    if result:
        if result.summary == opendnp3.TaskCompletion.SUCCESS:
            status_message = "Success, Time: {0}".format(
                result.restartTime.GetMilliseconds())
        else:
            status_message = "Failure: {0}".format(
                opendnp3.TaskCompletionToString(result.summary))
    else:
        status_message = "Failure: No result returned"

    _log.debug(status_message)