Git Product home page Git Product logo

bauzak's Introduction

Bauzak

PyPI version Build Status Coverage Status license made in taiwan

PLC工具

專案名

取自埔里噶哈巫語的

bauzak's People

Contributors

sih4sing5hong5 avatar

Watchers

James Cloos avatar  avatar

bauzak's Issues

Fatek 檢查

改用:https://github.com/rimek/fatek-fbs-lib


    def __calculate_offset(self):
        """
            # coils:
            Y(0-255) : 0 - 255
            X(0-255) : 1000 - 1255
            M(0-2001): 2000 - 4001
            S(0-999) : 6000 - 6999
            T(0-255) : 9000 - 9255 (current_value=False)
            C(0-255) : 9500 - 9755 (current_value=False)

            # registers
            R(0-4167)    : 0    - 4167
            R(5000-5998) : 5000 - 5998 (holding or ror)
            D(0-2998)    : 6000 - 8998
            T(0-255)     : 9000 - 9255 (current_value = True)
            C(0-199)     : 9500 - 9699 (16bit, current_value=True)
            C(200-255)   : 9700 - 9811 (32bit, current_value=True) double offset
        """

        target = self.register
        number = self.number
        current_value = self.current_value

        offset_dict = {
            'Y': 0,
            'X': 1000,
            'M': 2000,
            'S': 6000,
            'T': 9000,
            'R': 0,
            'D': 6000,
            'C': 9500
        }

        offset = offset_dict[target]
        if target == 'C' and current_value == True and number >= 200:
            number %= 200
            offset = 9700 + 2*(number)
        elif target == 'R' and number >= 5000:
            number = 0
            offset = 5000

        return number + offset

    def __verify_number(self):
        number = self.number
        target = self.register

        allowed_numbers = {
            'Y': (0,256),
            'X': (0,256),
            'M': (0,2002),
            'S': (0,1000),
            'T': (0,256),
            'D': (0,2999),
            'C': (0,256)
        }
        allowed_r_numbers = ((0, 4168), (5000, 5999))

        if target != 'R':
            result = number in xrange(*allowed_numbers[target])
        else:
            result = any([number in xrange(*numbers) for numbers in allowed_r_numbers])

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.