• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python common.check_error函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中snap7.common.check_error函数的典型用法代码示例。如果您正苦于以下问题:Python check_error函数的具体用法?Python check_error怎么用?Python check_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了check_error函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: list_blocks_of_type

    def list_blocks_of_type(self, blocktype, size):
        """This function returns the AG list of a specified block type."""

        blocktype = snap7.snap7types.block_types.get(blocktype)

        if not blocktype:
            raise Snap7Exception("The blocktype parameter was invalid")

        logger.debug("listing blocks of type: %s size: %s" %
                      (blocktype, size))

        if (size == 0):
            return 0
		
        data = (c_uint16 * size)()
        count = c_int(size)
        result = self.library.Cli_ListBlocksOfType(
            self.pointer, blocktype,
            byref(data),
            byref(count))

        logger.debug("number of items found: %s" % count)

        check_error(result, context="client")
        return data
开发者ID:gijzelaerr,项目名称:python-snap7,代码行数:25,代码来源:client.py


示例2: get_last_error

 def get_last_error(self):
     """
     Returns the last job result.
     """
     error = ctypes.c_int32()
     result = self.library.Par_GetLastError(self.pointer, ctypes.byref(error))
     check_error(result, "partner")
     return error
开发者ID:CHarira,项目名称:python-snap7,代码行数:8,代码来源:partner.py


示例3: get_cpu_info

 def get_cpu_info(self):
     """
     Retrieves CPU info from client
     """
     info = snap7.snap7types.S7CpuInfo()
     result = self.library.Cli_GetCpuInfo(self.pointer, byref(info))
     check_error(result, context="client")
     return info
开发者ID:CHarira,项目名称:python-snap7,代码行数:8,代码来源:client.py


示例4: get_mask

 def get_mask(self, kind):
     """Reads the specified filter mask.
     """
     logger.debug("retrieving mask kind %s" % kind)
     mask = longword()
     code = self.library.Srv_GetMask(self.pointer, kind, ctypes.byref(mask))
     check_error(code)
     return mask
开发者ID:lkraider,项目名称:python-snap7,代码行数:8,代码来源:server.py


示例5: disconnect

 def disconnect(self):
     """
     disconnect a client.
     """
     logger.info("disconnecting snap7 client")
     result = self.library.Cli_Disconnect(self.pointer)
     check_error(result, context="client") 
     return result
开发者ID:gijzelaerr,项目名称:python-snap7,代码行数:8,代码来源:logo.py


示例6: get_status

 def get_status(self):
     """
     Returns the Partner status.
     """
     status = ctypes.c_int32()
     result = self.library.Par_GetStatus(self.pointer, ctypes.byref(status))
     check_error(result, "partner")
     return status
开发者ID:CHarira,项目名称:python-snap7,代码行数:8,代码来源:partner.py


示例7: read

    def read(self, vm_address):
        """
        Reads from VM addresses of Siemens Logo. Examples: read("V40") / read("VW64") / read("V10.2") 
        
        :param vm_address: of Logo memory (e.g. V30.1, VW32, V24)
        :returns: integer
        """
        area = snap7types.S7AreaDB
        db_number = 1
        size = 1
        start = 0
        wordlen = 0
        logger.debug("read, vm_address:%s" % (vm_address))
        if re.match("V[0-9]{1,4}\.[0-7]{1}", vm_address):
            ## bit value
            logger.info("read, Bit address: " + vm_address)
            address = vm_address[1:].split(".")
            # transform string to int
            address_byte = int(address[0])
            address_bit = int(address[1])
            start = (address_byte*8)+address_bit
            wordlen = snap7types.S7WLBit
        elif re.match("V[0-9]+", vm_address):
            ## byte value
            logger.info("Byte address: " + vm_address)
            start = int(vm_address[1:])
            wordlen = snap7types.S7WLByte
        elif re.match("VW[0-9]+", vm_address):
            ## byte value
            logger.info("Word address: " + vm_address)
            start = int(vm_address[2:])
            wordlen = snap7types.S7WLWord
        elif re.match("VD[0-9]+", vm_address):
            ## byte value
            logger.info("DWord address: " + vm_address)
            start = int(vm_address[2:])
            wordlen = snap7types.S7WLDWord
        else:
            logger.info("Unknown address format")
            return 0
             
        type_ = snap7.snap7types.wordlen_to_ctypes[wordlen]
        data = (type_ * size)()

        logger.debug("start:%s, wordlen:%s, data-length:%s" % (start, wordlen, len(data)) )

        result = self.library.Cli_ReadArea(self.pointer, area, db_number, start,
                                           size, wordlen, byref(data))
        check_error(result, context="client")
        # transform result to int value
        if wordlen == snap7types.S7WLBit:
            return(data)[0]
        if wordlen == snap7types.S7WLByte:
            return struct.unpack_from(">B", data)[0]
        if wordlen == snap7types.S7WLWord:
            return struct.unpack_from(">h", data)[0]
        if wordlen == snap7types.S7WLDWord:
            return struct.unpack_from(">l", data)[0]
开发者ID:gijzelaerr,项目名称:python-snap7,代码行数:58,代码来源:logo.py


示例8: db_get

 def db_get(self, db_number):
     """Uploads a DB from AG.
     """
     logging.debug("db_get db_number: %s" % db_number)
     _buffer = buffer_type()
     result = self.library.Cli_DBGet(self.pointer, db_number, byref(_buffer),
                             byref(c_int(buffer_size)))
     check_error(result, context="client")
     return bytearray(_buffer)
开发者ID:lance5107B,项目名称:python-snap7,代码行数:9,代码来源:client.py


示例9: db_get

 def db_get(self, db_number):
     """Uploads a DB from AG.
     """
     logging.debug("db_get db_number: %s" % db_number)
     buffer_ = buffer_type()
     result = clib.Cli_DBGet(self.pointer, db_number, byref(buffer_),
                             byref(c_int(buffer_size)))
     check_error(result, client=True)
     return bytearray(buffer_)
开发者ID:crvidya,项目名称:python-snap7,代码行数:9,代码来源:client.py


示例10: get_param

 def get_param(self, number):
     """Reads an internal Server object parameter.
     """
     logger.debug("retreiving param number %s" % number)
     value = ctypes.c_int()
     code = self.library.Srv_GetParam(self.pointer, number,
                                      ctypes.byref(value))
     check_error(code)
     return value.value
开发者ID:lkraider,项目名称:python-snap7,代码行数:9,代码来源:server.py


示例11: read_multi_vars

    def read_multi_vars(self, items):
        """This function read multiple variables from the PLC.

        :param items: list of S7DataItem objects
        :returns: a tuple with the return code and a list of data items
        """
        result = self.library.Cli_ReadMultiVars(self.pointer, byref(items),
                                                c_int32(len(items)))
        check_error(result, context="client")
        return result, items
开发者ID:jdugge,项目名称:python-snap7,代码行数:10,代码来源:client.py


示例12: get_connected

    def get_connected(self):
        """
        Returns the connection status

        :returns: a boolean that indicates if connected.
        """
        connected = c_int32()
        result = self.library.Cli_GetConnected(self.pointer, byref(connected))
        check_error(result, context="client")
        return bool(connected)
开发者ID:jdugge,项目名称:python-snap7,代码行数:10,代码来源:client.py


示例13: get_param

 def get_param(self, number):
     """Reads an internal Client object parameter.
     """
     logger.debug("retreiving param number %s" % number)
     type_ = param_types[number]
     value = type_()
     code = self.library.Cli_GetParam(self.pointer, c_int(number),
                                      byref(value))
     check_error(code)
     return value.value
开发者ID:jdugge,项目名称:python-snap7,代码行数:10,代码来源:client.py


示例14: get_times

 def get_times(self):
     """
     Returns the last send and recv jobs execution time in milliseconds.
     """
     send_time = ctypes.c_int32()
     recv_time = ctypes.c_int32()
     result = self.library.Par_GetTimes(self.pointer, ctypes.byref(send_time),
                                ctypes.byref(recv_time))
     check_error(result, "partner")
     return send_time, recv_time
开发者ID:CHarira,项目名称:python-snap7,代码行数:10,代码来源:partner.py


示例15: get_param

 def get_param(self, number):
     """
     Reads an internal Partner object parameter.
     """
     logger.debug("retreiving param number %s" % number)
     type_ = snap7.snap7types.param_types[number]
     value = type_()
     code = self.library.Par_GetParam(self.pointer, ctypes.c_int(number),
                                      ctypes.byref(value))
     check_error(code)
     return value.value
开发者ID:CHarira,项目名称:python-snap7,代码行数:11,代码来源:partner.py


示例16: as_db_get

 def as_db_get(self, db_number):
     """
     This is the asynchronous counterpart of Cli_DBGet.
     """
     # logger.debug("db_get db_number: %s" % db_number)
     _buffer = buffer_type()
     bufferSize = c_int(snap7.snap7types.buffer_size)
     result = self.library.Cli_AsDBGet(self.pointer, db_number, byref(_buffer), byref(bufferSize))
     check_error(result, context="client")
     msg = bytearray(_buffer[:bufferSize.value])
     return msg
开发者ID:prodlinetrace,项目名称:trace,代码行数:11,代码来源:client.py


示例17: get_pdu_length

    def get_pdu_length(self):
        """
        Returns info about the PDU length.
        """
        logger.info("getting PDU length")
        requested_ = c_uint16()
        negotiated_ = c_uint16()
        code = self.library.Cli_GetPduLength(self.pointer, byref(requested_), byref(negotiated_))
        check_error(code)

        return negotiated_.value
开发者ID:jdugge,项目名称:python-snap7,代码行数:11,代码来源:client.py


示例18: read_area

 def read_area(self, area, dbnumber, start, amount, wordlen):
     """This is the main function to read data from a PLC.
     With it you can read DB, Inputs, Outputs, Merkers, Timers and Counters.
     """
     logging.debug("reading area: %s dbnumber: %s start: %s: amount %s: "
                   "wordlen: %s" % (area, dbnumber, start, amount, wordlen))
     data = (wordlen_to_ctypes[wordlen] * amount)()
     result = clib.Cli_ReadArea(self.pointer, area, dbnumber, start, amount,
                                wordlen, byref(data))
     check_error(result, client=True)
     return data
开发者ID:crvidya,项目名称:python-snap7,代码行数:11,代码来源:client.py


示例19: as_db_get

 def as_db_get(self, db_number):
     """
     This is the asynchronous counterpart of Cli_DBGet.
     """
     logging.debug("db_get db_number: %s" % db_number)
     _buffer = buffer_type()
     result = self.library.Cli_AsDBGet(self.pointer, db_number,
                                       byref(_buffer),
                                       byref(c_int(buffer_size)))
     check_error(result, context="client")
     return bytearray(_buffer)
开发者ID:jdugge,项目名称:python-snap7,代码行数:11,代码来源:client.py


示例20: list_blocks

    def list_blocks(self):
        """Returns the AG blocks amount divided by type.

        :returns: a snap7.types.BlocksList object.
        """
        logging.debug("listing blocks")
        blocksList = BlocksList()
        result = self.library.Cli_ListBlocks(self.pointer, byref(blocksList))
        check_error(result, context="client")
        logging.debug("blocks: %s" % blocksList)
        return blocksList
开发者ID:jdugge,项目名称:python-snap7,代码行数:11,代码来源:client.py



注:本文中的snap7.common.check_error函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python common.get_partsdir函数代码示例发布时间:2022-05-27
下一篇:
Python osutils.pjoin函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap