예제 #1
0
 def operator_iand(size):
     a = Array(size, 'int32')
     b = Array(size, 'int32')
     for i in range(size):
         a[i] = nb_types.int32(i)
         b[i] = nb_types.int32(size-i-1)
     operator.iand(a, b)
     return a
예제 #2
0
 def put_(self, args):
     """PUT: Put a sprite on the screen."""
     if self._mode.is_text_mode:
         raise error.BASICError(error.IFC)
     x0, y0 = (values.to_single(_arg).to_value() for _arg in islice(args, 2))
     array_name, operation_token = args
     array_name = self._memory.complete_name(array_name)
     operation_token = operation_token or tk.XOR
     if array_name not in self._memory.arrays:
         raise error.BASICError(error.IFC)
     elif array_name[-1:] == values.STR:
         raise error.BASICError(error.TYPE_MISMATCH)
     x0, y0 = self._get_window_physical(x0, y0)
     self._last_point = x0, y0
     packed_sprite = self._memory.arrays.view_full_buffer(array_name)
     sprite = self._mode.sprite_builder.unpack(packed_sprite)
     x1, y1 = x0 + sprite.width - 1, y0 + sprite.height - 1
     # the whole sprite must fit or it's IFC
     error.throw_if(not self.graph_view.contains(x0, y0))
     error.throw_if(not self.graph_view.contains(x1, y1))
     # apply the sprite to the screen
     if operation_token == tk.PSET:
         rect = sprite
     elif operation_token == tk.PRESET:
         rect = sprite ^ (2**self._mode.bitsperpixel - 1)
     elif operation_token == tk.AND:
         # we use in-place operations as we'll assign back anyway
         rect = operator.iand(self.graph_view[y0:y1+1, x0:x1+1], sprite)
     elif operation_token == tk.OR:
         rect = operator.ior(self.graph_view[y0:y1+1, x0:x1+1], sprite)
     elif operation_token == tk.XOR:
         rect = operator.ixor(self.graph_view[y0:y1+1, x0:x1+1], sprite)
     self.graph_view[y0:y1+1, x0:x1+1] = rect
예제 #3
0
파일: reconcile.py 프로젝트: wanghp18/seed
def build_q_filter(q_set, model_a, a_attr, model_b_class, b_attr, op, trans):
    """Build a set of Q objects to filter table results.

    :param q_set: the Q object set that's being built cumulatively.
    :param model_a: model instance.
    :param a_attr: str, the name of an attribute we're querying from.
    :param model_b_class: class, model class we're querying to.
    :param b_attr: str, model attribute we're querying to (on model_b_class).
    :param op: callable, takes two parameters. This callable should be an ``operator`` module function, e.g. \
    operator.ior, or operator.iand.
    :param trans: callable or None. If callable, we apply this callable to our `a_attr` for circumstances in which \
    we need to break up its value into sub values for more accurate querying (e.g. address data.).

    """
    if trans:
        # Think of breaking up the components of an address as these values.
        a_sub_values = trans(getattr(model_a, a_attr), b_attr)
        if isinstance(a_sub_values, Q):
            return op(q_set, a_sub_values)

        for sub_value in filter(lambda x: x, a_sub_values):
            # Let's not filter for Nulls.
            if not sub_value:
                continue
            q_set = iand(q_set, build_q(
                model_a, a_attr, model_b_class, b_attr, a_value=sub_value
            ))

    sub_q = build_q(model_a, a_attr, model_b_class, b_attr)
    if not sub_q:
        return q_set

    return op(q_set, sub_q)
예제 #4
0
def left_join(right, left, onclause):
    """
    Function: Join columns using an inner join
    
    Input: 
        1. Right statement/table to be joined, 
        2. Left statement/table to be joined,  
        3. A SQL expression representing the ON clause of the join. If left at None, it attempts to join the two tables based on a foreign key relationship
    
    If more than 1 expression is listed, (expressions) have to use an '&' operator. Ex: (Table1.c.colname1 = Table2.c.colname1 & Table1.c.colname2 = Table2.c.colname2)
    
    Output: A joined object
    
    Example: Table1 >> to_statement >> left_join(Table2, onclause=(Table1.c.colname = Table2.c.colname):BooleanClauseList)
    """
    left, right = left.alias(), table_check(right)
    print(left, right)
    l1, r1 = get_onclause_col(onclause)
    l2, r2 = [c.name for c in l1], [c.name for c in r1]
    l3, r3 = sorted([c for c in left.columns if c.name in l2],
                    key=lambda x: x.name), sorted(
                        [c for c in right.columns if c.name in r2],
                        key=lambda x: x.name)
    col_dict = dict(zip(l3, r3))
    expr_list = [(k == v) for k, v in col_dict.items()]
    clause = reduce(lambda x, y: operator.iand(x, y), expr_list)
    return select_sql([left.join_sql(right, onclause=clause, isouter=True)])
예제 #5
0
 def test_inplace(self):
     #operator = self.module
     class C(object):
         def __iadd__     (self, other): return "iadd"
         def __iand__     (self, other): return "iand"
         def __ifloordiv__(self, other): return "ifloordiv"
         def __ilshift__  (self, other): return "ilshift"
         def __imod__     (self, other): return "imod"
         def __imul__     (self, other): return "imul"
         def __ior__      (self, other): return "ior"
         def __ipow__     (self, other): return "ipow"
         def __irshift__  (self, other): return "irshift"
         def __isub__     (self, other): return "isub"
         def __itruediv__ (self, other): return "itruediv"
         def __ixor__     (self, other): return "ixor"
         def __getitem__(self, other): return 5  # so that C is a sequence
     c = C()
     self.assertEqual(operator.iadd     (c, 5), "iadd")
     self.assertEqual(operator.iand     (c, 5), "iand")
     self.assertEqual(operator.ifloordiv(c, 5), "ifloordiv")
     self.assertEqual(operator.ilshift  (c, 5), "ilshift")
     self.assertEqual(operator.imod     (c, 5), "imod")
     self.assertEqual(operator.imul     (c, 5), "imul")
     self.assertEqual(operator.ior      (c, 5), "ior")
     self.assertEqual(operator.ipow     (c, 5), "ipow")
     self.assertEqual(operator.irshift  (c, 5), "irshift")
     self.assertEqual(operator.isub     (c, 5), "isub")
     self.assertEqual(operator.itruediv (c, 5), "itruediv")
     self.assertEqual(operator.ixor     (c, 5), "ixor")
     self.assertEqual(operator.iconcat  (c, c), "iadd")
예제 #6
0
def encipher(v, k):
    y = v[0]
    z = v[1]
    sum = 0
    delta = 0x9E3779B9
    n = 32
    w = [0, 0]
    while (n > 0):
        y += (z << 4 ^ z >> 5) + z ^ sum + k[sum & 3]
        operator.iand(y, sys.maxsize)  # maxsize of 32-bit integer
        sum += delta
        z += (y << 4 ^ y >> 5) + y ^ sum + k[sum >> 11 & 3]
        operator.iand(z, sys.maxsize)
        n -= 1

    w[0] = y
    w[1] = z
    return w
예제 #7
0
    def test_inplace(self):
        #operator = self.module
        class C(object):
            def __iadd__(self, other):
                return "iadd"

            def __iand__(self, other):
                return "iand"

            def __ifloordiv__(self, other):
                return "ifloordiv"

            def __ilshift__(self, other):
                return "ilshift"

            def __imod__(self, other):
                return "imod"

            def __imul__(self, other):
                return "imul"

            def __ior__(self, other):
                return "ior"

            def __ipow__(self, other):
                return "ipow"

            def __irshift__(self, other):
                return "irshift"

            def __isub__(self, other):
                return "isub"

            def __itruediv__(self, other):
                return "itruediv"

            def __ixor__(self, other):
                return "ixor"

            def __getitem__(self, other):
                return 5  # so that C is a sequence

        c = C()
        self.assertEqual(operator.iadd(c, 5), "iadd")
        self.assertEqual(operator.iand(c, 5), "iand")
        self.assertEqual(operator.ifloordiv(c, 5), "ifloordiv")
        self.assertEqual(operator.ilshift(c, 5), "ilshift")
        self.assertEqual(operator.imod(c, 5), "imod")
        self.assertEqual(operator.imul(c, 5), "imul")
        self.assertEqual(operator.ior(c, 5), "ior")
        self.assertEqual(operator.ipow(c, 5), "ipow")
        self.assertEqual(operator.irshift(c, 5), "irshift")
        self.assertEqual(operator.isub(c, 5), "isub")
        self.assertEqual(operator.itruediv(c, 5), "itruediv")
        self.assertEqual(operator.ixor(c, 5), "ixor")
        self.assertEqual(operator.iconcat(c, c), "iadd")
예제 #8
0
def decipher(v, k):
    y = v[0]
    z = v[1]
    sum = 0xC6EF3720
    delta = 0x9E3779B9
    n = 32
    w = [0, 0]
    # sum = delta<<5, in general sum = delta * n

    while (n > 0):
        z -= (y << 4 ^ y >> 5) + y ^ sum + k[sum >> 11 & 3]
        operator.iand(z, sys.maxsize)
        sum -= delta
        y -= (z << 4 ^ z >> 5) + z ^ sum + k[sum & 3]
        operator.iand(y, sys.maxsize)
        n -= 1

    w[0] = y
    w[1] = z
    return w
    def test_class_binary_inplace_operators(self):
        class WithLotsOfOperators(Class):
            def __iadd__(self, other):
                return (self, "iadd", other)

            def __isub__(self, other):
                return (self, "isub", other)

            def __imul__(self, other):
                return (self, "imul", other)

            def __imod__(self, other):
                return (self, "imod", other)

            def __itruediv__(self, other):
                return (self, "itruediv", other)

            def __ifloordiv__(self, other):
                return (self, "ifloordiv", other)

            def __ilshift__(self, other):
                return (self, "ilshift", other)

            def __irshift__(self, other):
                return (self, "irshift", other)

            def __ior__(self, other):
                return (self, "ior", other)

            def __iand__(self, other):
                return (self, "iand", other)

            def __ixor__(self, other):
                return (self, "ixor", other)

            def __imatmul__(self, other):
                return (self, "imatmul", other)

        c = WithLotsOfOperators()

        self.assertEqual(operator.iadd(c, 0), (c, "iadd", 0))
        self.assertEqual(operator.isub(c, 0), (c, "isub", 0))
        self.assertEqual(operator.imul(c, 0), (c, "imul", 0))
        self.assertEqual(operator.imod(c, 0), (c, "imod", 0))
        self.assertEqual(operator.itruediv(c, 0), (c, "itruediv", 0))
        self.assertEqual(operator.ifloordiv(c, 0), (c, "ifloordiv", 0))
        self.assertEqual(operator.ilshift(c, 0), (c, "ilshift", 0))
        self.assertEqual(operator.irshift(c, 0), (c, "irshift", 0))
        self.assertEqual(operator.ior(c, 0), (c, "ior", 0))
        self.assertEqual(operator.iand(c, 0), (c, "iand", 0))
        self.assertEqual(operator.ixor(c, 0), (c, "ixor", 0))
        self.assertEqual(operator.imatmul(c, 0), (c, "imatmul", 0))
예제 #10
0
def build_q_filter(q_set, model_a, a_attr, model_b_class, b_attr, op, trans):
    """Build a set of Q objects to filter table results.

    :param q_set: the Q object set that's being built cumulatively.
    :param model_a: model instance.
    :param a_attr: str, the name of an attribute we're querying from.
    :param model_b_class: class, model class we're querying to.
    :param b_attr: str, model attribute we're querying to (on model_b_class).
    :param op: callable, takes two parameters. This callable should be an
        ``operator`` module function, e.g. operator.ior, or operator.iand.
    :param trans: callable or None. If callable, we apply this callable to
    our `a_attr` for circumstances in which we need to break up its value
    into sub values for more accurate querying (e.g. address data.).

    """
    if trans:
        # Think of breaking up the components of an address as these values.
        a_sub_values = trans(getattr(model_a, a_attr), b_attr)
        if isinstance(a_sub_values, Q):
            return op(q_set, a_sub_values)

        for sub_value in filter(lambda x: x, a_sub_values):
            # Let's not filter for Nulls.
            if not sub_value:
                continue
            q_set = iand(
                q_set,
                build_q(model_a,
                        a_attr,
                        model_b_class,
                        b_attr,
                        a_value=sub_value))

    sub_q = build_q(model_a, a_attr, model_b_class, b_attr)
    if not sub_q:
        return q_set

    return op(q_set, sub_q)
예제 #11
0
def compound_ex(in1, in2, in3, in4):
    return nand(nor(in1, in2), iand(in3, in4))
예제 #12
0
 def bitwise_iand_usecase(x, y):
     return operator.iand(x, y)
예제 #13
0
    def getSameStatus(self, mode):
        i = 0

        markChar = 0

        self.i2c.writeList(self.WB_SAME_STATUS, [mode, 0x00])
        self.response = self.i2c.readList(0, 4)

        self.sameStatus = self.response[1]
        self.sameState = self.response[2]
        self.sameLength = self.response[3]

        if (not (self.sameStatus & self.HDRRDY)):
            return  #  If no HDRRDY, return.

        #TIMER1_START();                #  Start/Re-start the 6 second timer.

        self.sameHeaderCount += 1
        #print self.sameHeaderCount

        if (
                self.sameHeaderCount >= 3
        ):  #  If this is the third Header, set msgStatus to show that it needs to be purged after usage.
            #self.msgStatus = operator.ior(self.msgStatus, self.MSGAVL)
            self.msgStatus = operator.ior(self.msgStatus, self.MSGPUR)

        if (self.sameLength < self.SAME_MIN_LENGTH):
            return  #  Don't process messages that are too short to be valid.

        for i in range(0, self.sameLength, 8):
            self.i2c.writeList(self.WB_SAME_STATUS, [self.CHECK, i])

            self.response = self.i2c.readList(0, 14)

            self.sameConf[0] = (self.response[5] & self.SAME_STATUS_OUT_CONF0
                                ) >> self.SAME_STATUS_OUT_CONF0_SHFT
            self.sameConf[1] = (self.response[5] & self.SAME_STATUS_OUT_CONF1
                                ) >> self.SAME_STATUS_OUT_CONF1_SHFT
            self.sameConf[2] = (self.response[5] & self.SAME_STATUS_OUT_CONF2
                                ) >> self.SAME_STATUS_OUT_CONF2_SHFT
            self.sameConf[3] = (self.response[5] & self.SAME_STATUS_OUT_CONF3
                                ) >> self.SAME_STATUS_OUT_CONF3_SHFT
            self.sameConf[4] = (self.response[4] & self.SAME_STATUS_OUT_CONF4
                                ) >> self.SAME_STATUS_OUT_CONF4_SHFT
            self.sameConf[5] = (self.response[4] & self.SAME_STATUS_OUT_CONF5
                                ) >> self.SAME_STATUS_OUT_CONF5_SHFT
            self.sameConf[6] = (self.response[4] & self.SAME_STATUS_OUT_CONF6
                                ) >> self.SAME_STATUS_OUT_CONF6_SHFT
            self.sameConf[7] = (self.response[4] & self.SAME_STATUS_OUT_CONF7
                                ) >> self.SAME_STATUS_OUT_CONF7_SHFT

            self.sameData[0] = self.response[6]
            self.sameData[1] = self.response[7]
            self.sameData[2] = self.response[8]
            self.sameData[3] = self.response[9]
            self.sameData[4] = self.response[10]
            self.sameData[5] = self.response[11]
            self.sameData[6] = self.response[12]
            self.sameData[7] = self.response[13]
            j = 0
            for j in range(0, 8):
                self.rxBuffer[j + i] = self.sameData[j]
                self.rxConfidence[j + i] = self.sameConf[j]

                if (self.rxBuffer[j + i] == 47):  # "/" symbol in callsign
                    markChar = 1

                if ((self.rxBuffer[j + i] == 45) and (markChar)):
                    self.sameLength = (j + i)
                    break

        self.msgStatus = operator.ior(self.msgStatus, self.MSGAVL)

        i = 0

        for i in range(0, self.sameLength):

            if (self.rxConfidence[i] < self.SAME_CONFIDENCE_THRESHOLD):
                self.msgStatus = operator.iand(self.msgStatus, ~self.MSGAVL)

        if (not (self.msgStatus & self.MSGAVL)):
            return

        self.rxBufferIndex = 0
        self.rxBufferLength = self.sameLength
        print ' '
        for i in range(0, self.rxBufferLength):
            sys.stdout.write(chr(self.rxBuffer[i])),

        confStr = '\n'
        for i in range(0, self.rxBufferLength):
            confStr += str(self.rxConfidence[i])

        print confString
예제 #14
0
def getStatus():

    radio.getIntStatus()

    if (radio.intStatus & radio.STCINT):
        radio.getTuneStatus(
            radio.INTACK)  # Using INTACK clears STCINT, CHECK preserves it.
        print "FREQ:", radio.frequency, " RSSI:", int(
            radio.rssi - 107), "dBm", " SNR:", int(radio.snr), "dBuV\n"
        radio.sameFlush()  # This should be done after any tune function.
        #radio.intStatus = ior(radio.intStatus,radio.RSQINT)  # We can force it to get rsqStatus on any tune.

    if (radio.intStatus & radio.RSQINT):
        radio.getRsqStatus(radio.INTACK)
        print "RSSI:", int(radio.rssi - 107), "dBm", " SNR:", int(
            radio.snr), "dBuV", " FREQOFF:", radio.freqoff

    if (radio.intStatus & radio.SAMEINT):
        radio.getSameStatus(radio.INTACK)

        if (radio.sameStatus & radio.EOMDET):
            global eomCnt
            radio.sameFlush()
            print "EOM detected.\n"
            eomCnt = eomCnt + 1
            #print int(eomCnt)
            ##More application specific code could go here. (Mute audio, turn something on/off, etc.)
            return
        if (radio.msgStatus & radio.MSGAVL
                and (not (radio.msgStatus & radio.MSGUSD))
                and radio.sameHeaderCount >=
                3):  # If a message is available and not already used,
            radio.sameParse()

            if (radio.msgStatus & radio.MSGPAR):
                global msg
                global relayTrigger1  # used to activate relay

                #Example of looking for a specific event code..i.e. TOR for Tornado
                if (radio.sameEventName[0] == 'T'
                        and radio.sameEventName[1] == 'O'
                        and radio.sameEventName[2] == 'R'):
                    #print "Event Match True!"
                    relayTrigger1 = 1  #trigger relay1 based on Tornado event

                msg = "ZCZC"
                radio.msgStatus = operator.iand(
                    radio.msgStatus, ~radio.MSGPAR
                )  # Clear the parse status, so that we don't print it again.
                #print ''.join(radio.finalMsg), "\n"
                msg = msg + str(''.join(radio.finalMsg))
                msg = msg + "\n\n"
                print "Originator: ", ''.join(radio.sameOriginatorName)
                msg = msg + "Originator: "
                msg = msg + str(''.join(radio.sameOriginatorName))
                msg = msg + "\n"
                print "Event: ", ''.join(radio.sameEventName)
                msg = msg + "Event: "
                msg = msg + str(''.join(radio.sameEventName))
                msg = msg + "\n"
                print "Locations: ", int(radio.sameLocations)
                msg = msg + "Locations: "
                msg = msg + str(int(radio.sameLocations))
                msg = msg + "\n"
                print "Location Codes:"
                msg = msg + "Location Codes: "
                print ', '.join(radio.sameLocationCodes)
                msg = msg + str(','.join(radio.sameLocationCodes))
                print "\nDuration: ", ''.join(radio.sameDuration)
                msg = msg + "\nDuration: "
                msg = msg + str(''.join(radio.sameDuration))
                msg = msg + "\n"
                print "Day: ", ''.join(radio.sameDay)
                msg = msg + "Day: "
                msg = msg + str(''.join(radio.sameDay))
                msg = msg + "\n"
                print "Time: ", ''.join(radio.sameTime)
                msg = msg + "Time: "
                msg = msg + str(''.join(radio.sameTime))
                msg = msg + "\n"
                print "Callsign: ", ''.join(radio.sameCallSign), "\n"
                msg = msg + "Callsign: "
                msg = msg + str(''.join(radio.sameCallSign))
                msg = msg + "\n"

        if (radio.msgStatus & radio.MSGPUR
            ):  #  Signals that the third header has been received.
            radio.sameFlush()

    if ((radio.intStatus & radio.ASQINT) or (radio.sameWat == 0x01)):
        radio.getAsqStatus(radio.INTACK)
        #print "sameWat:" , hex(radio.sameWat), "ASQ Stat:", hex(radio.asqStatus)

        if (radio.sameWat == radio.asqStatus):
            return

        if (radio.asqStatus == 0x01):
            radio.sameFlush()
            print "\n1050Hz Alert Tone: ON\n"
            radio.sameWat = radio.asqStatus
        if (radio.asqStatus == 0x02):
            print "1050Hz Alert Tone: OFF\n"
            radio.sameWat = radio.asqStatus

    if (radio.intStatus & radio.ERRINT):
        radio.intStatus = operator.iand(radio.intStatus, ~radio.ERRINT)
        print "An error occured!\n"

    return
예제 #15
0
 def __iand__(self, other):
     return operator.iand(self._wrapped(), other)
예제 #16
0
b = 0
print(operator.ixor(a, b))

"""8.ipow() :- This function is used to assign and exponentiate the current value. This operation does “a ** = b” operation. Assigning is not performed in case of
immutable containers, such as strings, numbers and tuples."""

a = 3
b = 2
print(operator.ipow(a, b))

"""9.iand() :- This function is used to assign and bitwise and the current value. This operation does “a &= b” operation. Assigning is not performed in case of
immutable containers, such as strings, numbers and tuples"""

a = 1
b = 1
print(operator.iand(a, b))

"""10.ior()-  This function is used to assign and bitwise or the current value. This operation does “a |=b ” operation. Assigning is not performed in case of
immutable containers, such as strings, numbers and tuples."""
a = 5
b = 1
print(operator.ior(a, b))

"""11.ilshift()-This function is used to assign and bitwise leftshift the current value by second argument. This operation does “a <<=b ” operation. Assigning is not
performed in case of immutable containers, such as strings, numbers and tuples."""

a = 3
b = 2
print(operator.ilshift(a, b))

"""12.irshift()- This function is used to assign and bitwise rightshift the current value by second argument. This operation does “a >>=b ” operation. Assigning is not
print(li)
operator.delitem(li, slice(1, 4))
print(li)
print(operator.getitem(li, slice(0, 2)))
s1 = "testing "
s2 = "operator"
print(operator.concat(s1, s2))
if (operator.contains(s1, s2)):
    print("Contains")
else:
    print("It doesn't")
a = 1
b = 0
print(operator.and_(a, b))
print(operator.or_(a, b))
print(operator.invert(a))

x = 10
y = 5
print(operator.iadd(x, y))
print(operator.isub(x, y))
print(operator.iconcat(s1, s2))
print(operator.imul(x, y))
print(operator.itruediv(x, y))
print(operator.imod(x, y))
print(operator.ixor(x, y))
print(operator.ipow(x, y))
print(operator.iand(x, y))
print(operator.ior(x, y))
print(operator.ilshift(x, y))
print(operator.irshift(x, y))
예제 #18
0
    	def getSameStatus(self, mode):
        	i = 0
		
		markChar = 0

        	self.i2c.writeList(self.WB_SAME_STATUS,[mode, 0x00])
        	self.response = self.i2c.readList(0, 4)

        	self.sameStatus = self.response[1]
        	self.sameState  = self.response[2]
        	self.sameLength = self.response[3]


        	if (not(self.sameStatus & self.HDRRDY)):
			return                  #  If no HDRRDY, return.

        	#TIMER1_START();                #  Start/Re-start the 6 second timer.

        	self.sameHeaderCount += 1
                #print self.sameHeaderCount
        	
		if (self.sameHeaderCount >= 3): #  If this is the third Header, set msgStatus to show that it needs to be purged after usage.
			#self.msgStatus = operator.ior(self.msgStatus, self.MSGAVL)
			self.msgStatus = operator.ior(self.msgStatus,self.MSGPUR)

        	if (self.sameLength < self.SAME_MIN_LENGTH):
			return  #  Don't process messages that are too short to be valid.

        	for i in range(0, self.sameLength, 8):
			self.i2c.writeList(self.WB_SAME_STATUS, [self.CHECK, i])

            		self.response = self.i2c.readList(0, 14)


            		self.sameConf[0] = (self.response[5] & self.SAME_STATUS_OUT_CONF0) >> self.SAME_STATUS_OUT_CONF0_SHFT
			self.sameConf[1] = (self.response[5] & self.SAME_STATUS_OUT_CONF1) >> self.SAME_STATUS_OUT_CONF1_SHFT
            		self.sameConf[2] = (self.response[5] & self.SAME_STATUS_OUT_CONF2) >> self.SAME_STATUS_OUT_CONF2_SHFT
            		self.sameConf[3] = (self.response[5] & self.SAME_STATUS_OUT_CONF3) >> self.SAME_STATUS_OUT_CONF3_SHFT
            		self.sameConf[4] = (self.response[4] & self.SAME_STATUS_OUT_CONF4) >> self.SAME_STATUS_OUT_CONF4_SHFT
            		self.sameConf[5] = (self.response[4] & self.SAME_STATUS_OUT_CONF5) >> self.SAME_STATUS_OUT_CONF5_SHFT
            		self.sameConf[6] = (self.response[4] & self.SAME_STATUS_OUT_CONF6) >> self.SAME_STATUS_OUT_CONF6_SHFT
            		self.sameConf[7] = (self.response[4] & self.SAME_STATUS_OUT_CONF7) >> self.SAME_STATUS_OUT_CONF7_SHFT

            		self.sameData[0] = self.response[6]
            		self.sameData[1] = self.response[7]
            		self.sameData[2] = self.response[8]
            		self.sameData[3] = self.response[9]
            		self.sameData[4] = self.response[10]
            		self.sameData[5] = self.response[11]
            		self.sameData[6] = self.response[12]
            		self.sameData[7] = self.response[13]
            		j = 0
            		for j in range (0,8):
                		self.rxBuffer[j + i] = self.sameData[j]
                		self.rxConfidence[j + i] = self.sameConf[j]

                		if (self.rxBuffer[j + i] == 47): # "/" symbol in callsign
					markChar = 1
				
				if ((self.rxBuffer[j + i] == 45) and (markChar)):
					self.sameLength = (j + i)
                    			break
                
        	self.msgStatus = operator.ior(self.msgStatus, self.MSGAVL)
		
        	i = 0 
                  
        
        	for i in range(0,self.sameLength):
            		
        		if (self.rxConfidence[i] < self.SAME_CONFIDENCE_THRESHOLD):
                      		self.msgStatus = operator.iand(self.msgStatus, ~self.MSGAVL)
				                                         


        	if (not(self.msgStatus & self.MSGAVL)):
			return

        	self.rxBufferIndex = 0
        	self.rxBufferLength = self.sameLength
                print ' '
                for i in range(0, self.rxBufferLength):
                        sys.stdout.write (chr(self.rxBuffer[i])), 
                
                confStr = '\n'
                for i in range(0, self.rxBufferLength):
                        confStr += str(self.rxConfidence[i])
				
		print confString
예제 #19
0
b = operator.imul(a, 5)
print a
print b

#将与自身的值相除之和的值赋给自身 同 /=
#这个除法是精确除法,不是取整
#但是不改变自身的值,返回值返回相除的结果
a = 9
b = operator.itruediv(a, 2)
print a
print b

#将与自身的值相与的值赋给自身 同 &=
#但是不改变自身的值,返回值返回相与的结果
a = 8
b = operator.iand(a, 1)
print a
print b

#将与自身的值相或的值赋给自身 同 |=
#但是不改变自身的值,返回值返回相或的结果
a = 8
b = operator.ior(a, 1)
print a
print b

#将与自身的值相异或的值赋给自身 同 ^=
#但是不改变自身的值,返回值返回相异或的结果
a = 8
b = operator.ixor(a, 1)
print a
예제 #20
0
 def bitwise_iand_usecase(x, y):
     return operator.iand(x, y)
예제 #21
0
x = 5
y = 4
x = operator.ipow(x, y)
print("The value after exponentiating and assigning : ", end="")
print(x)

# using ior() to or, and assign value
x = 10
y = 5
x = operator.ior(x, y)
print("The value after bitwise or, and assigning : ", end="")
print(x)

x = 5
y = 4
x = operator.iand(x, y)
print("The value after bitwise and, and assigning : ", end="")
print(x)

#%%
''' ilshift() :- This function is used to assign and bitwise 
    leftshift the current value by second argument.'''

import operator

# using ilshift() to bitwise left shift and assign value
x = 8
y = 2
x = operator.ilshift(x, y)
print("The value after bitwise left shift and assigning : ", end="")
print(x)
예제 #22
0
b = operator.imul(a,5)
print a
print b

#将与自身的值相除之和的值赋给自身 同 /= 
#这个除法是精确除法,不是取整
#但是不改变自身的值,返回值返回相除的结果
a = 9
b = operator.itruediv(a,2)
print a
print b

#将与自身的值相与的值赋给自身 同 &=
#但是不改变自身的值,返回值返回相与的结果
a = 8
b = operator.iand(a,1)
print a
print b

#将与自身的值相或的值赋给自身 同 |=
#但是不改变自身的值,返回值返回相或的结果
a = 8
b = operator.ior(a,1)
print a
print b

#将与自身的值相异或的值赋给自身 同 ^=
#但是不改变自身的值,返回值返回相异或的结果
a = 8
b = operator.ixor(a,1)
print a
예제 #23
0
# using ipow() to exponentiate and assign value
x = operator.ipow(5, 4)
print("The value after exponentiating and assigning : ")
print(x)

# Python code to demonstrate the working of
# ior() and iand()

# using ior() to or, and assign value
x = operator.ior(10, 5)
print("The value after bitwise or and assigning : ")
print(x)

# using iand() to and , and assign value
x = operator.iand(5, 4)
print("The value after bitwise and, and assigning : ")
print(x)

# Python code to demonstrate the working of
# ilshift() and irshift()

# using ilshift() to bitwise left shift and assign value
x = operator.ilshift(8, 2)
print("The value after bitwise left shift and assigning : ")
print(x)

# using irshift() to bitwise right  shift and assign value
x = operator.irshift(8, 2)
print("The value after bitwise right shift and assigning : ")
print(x)
예제 #24
0
 def update_event(self, inp=-1):
     self.set_output_val(0, operator.iand(self.input(0), self.input(1)))
예제 #25
0
def getStatus():

        radio.getIntStatus()

        if (radio.intStatus & radio.STCINT):
                radio.getTuneStatus(radio.INTACK)  # Using INTACK clears STCINT, CHECK preserves it.
                print "FREQ:", radio.frequency, " RSSI:", int(radio.rssi-107), "dBm", " SNR:", int(radio.snr), "dBuV\n"
                radio.sameFlush()    # This should be done after any tune function.
                #radio.intStatus = ior(radio.intStatus,radio.RSQINT)  # We can force it to get rsqStatus on any tune.


        if (radio.intStatus & radio.RSQINT):
                radio.getRsqStatus(radio.INTACK)
                print "RSSI:", int(radio.rssi-107), "dBm", " SNR:", int(radio.snr), "dBuV", " FREQOFF:", radio.freqoff

        if (radio.intStatus & radio.SAMEINT):
                radio.getSameStatus(radio.INTACK)

                if (radio.sameStatus & radio.EOMDET):
                        global eomCnt
                        radio.sameFlush()
                        print "EOM detected.\n"
                        eomCnt = eomCnt + 1
                        #print int(eomCnt)			
                        ##More application specific code could go here. (Mute audio, turn something on/off, etc.)
                        return
                if (radio.msgStatus & radio.MSGAVL and (not(radio.msgStatus & radio.MSGUSD)) and radio.sameHeaderCount >=3): # If a message is available and not already used,
                        radio.sameParse()
			
                	if (radio.msgStatus & radio.MSGPAR):			
                        	global msg
                        	global relayTrigger1 # used to activate relay

                        	#Example of looking for a specific event code..i.e. TOR for Tornado
                        	if (radio.sameEventName[0] == 'T' and radio.sameEventName[1] == 'O' and radio.sameEventName[2] == 'R'):
                                	#print "Event Match True!"
                                	relayTrigger1 = 1 #trigger relay1 based on Tornado event
                               
                        	msg = "ZCZC"
                        	radio.msgStatus = operator.iand(radio.msgStatus,~radio.MSGPAR) # Clear the parse status, so that we don't print it again.
                        	#print ''.join(radio.finalMsg), "\n"
                        	msg = msg + str(''.join(radio.finalMsg))
                        	msg = msg + "\n\n"
                        	print "Originator: ", ''.join(radio.sameOriginatorName)
                        	msg = msg + "Originator: "
                        	msg = msg + str(''.join(radio.sameOriginatorName))
                        	msg = msg + "\n"
                        	print "Event: ", ''.join(radio.sameEventName)
                        	msg = msg + "Event: "
                        	msg = msg + str(''.join(radio.sameEventName))
                        	msg = msg + "\n"
                       	 	print "Locations: ", int(radio.sameLocations)
                        	msg = msg + "Locations: "
                        	msg = msg + str(int(radio.sameLocations))
                        	msg = msg + "\n"
                        	print "Location Codes:"
                        	msg = msg + "Location Codes: "                        
                        	print ', '.join(radio.sameLocationCodes)
                        	msg = msg + str(','.join(radio.sameLocationCodes))			
                        	print "\nDuration: ", ''.join(radio.sameDuration)
                        	msg = msg + "\nDuration: "
                        	msg = msg + str(''.join(radio.sameDuration))
                        	msg = msg + "\n"
                        	print "Day: ", ''.join(radio.sameDay)
                        	msg = msg + "Day: "
                        	msg = msg + str(''.join(radio.sameDay))
                        	msg = msg + "\n"
                        	print "Time: ", ''.join(radio.sameTime)
                        	msg = msg + "Time: "
                        	msg = msg + str(''.join(radio.sameTime))
                        	msg = msg + "\n"
                        	print "Callsign: ", ''.join(radio.sameCallSign), "\n"
                        	msg = msg + "Callsign: "
                        	msg = msg + str(''.join(radio.sameCallSign))
                        	msg = msg + "\n"		

                if (radio.msgStatus & radio.MSGPUR):  #  Signals that the third header has been received.
                        radio.sameFlush()

                
        if ((radio.intStatus & radio.ASQINT) or (radio.sameWat == 0x01)):
                radio.getAsqStatus(radio.INTACK)
                #print "sameWat:" , hex(radio.sameWat), "ASQ Stat:", hex(radio.asqStatus)

                if (radio.sameWat == radio.asqStatus):
                        return

                if (radio.asqStatus == 0x01):
                        radio.sameFlush()
                        print "\n1050Hz Alert Tone: ON\n"
			radio.sameWat = radio.asqStatus
		if (radio.asqStatus == 0x02):
                        print "1050Hz Alert Tone: OFF\n"
			radio.sameWat = radio.asqStatus

        if (radio.intStatus & radio.ERRINT):
                radio.intStatus = operator.iand(radio.intStatus,~radio.ERRINT)
                print "An error occured!\n"

        return