Beispiel #1
0
def test_decimal_field():
    """Test decimal fields."""
    ob = FieldTest()
    assert ob.DecimalField == System.Decimal(0)

    ob.DecimalField = System.Decimal(1)
    assert ob.DecimalField == System.Decimal(1)
    def testDecimalField(self):
        """Test decimal fields."""
        object = FieldTest()
        self.assertTrue(object.DecimalField == System.Decimal(0))

        object.DecimalField = System.Decimal(1)
        self.assertTrue(object.DecimalField == System.Decimal(1))
Beispiel #3
0
    def testDecimalField(self):
        """Test decimal fields."""
        object = FieldTest()
        self.failUnless(object.DecimalField == System.Decimal(0))

        object.DecimalField = System.Decimal(1)
        self.failUnless(object.DecimalField == System.Decimal(1))
    def set_jog_params(self, vel=0.01, accl=0.01, stp_mode=1):

        vel = System.Decimal(vel)
        accl = System.Decimal(accl)
        new_pa = self.motor.GetJogParams()
        new_pa.StopMode = 1
        self.motor.SetJogParams(new_pa)
        self.motor.SetJogVelocityParams(vel, accl)
Beispiel #5
0
def VerifyKey(expected, actual):
    Test.Equal(expected.Name, actual.Name, "Verify key name")
    Test.Equal(expected.Description, actual.Description,
               "Verify key description")
    Test.Equal(System.Decimal(expected.Start), System.Decimal(actual.Start),
               "Verify key start")
    Test.Equal(System.Decimal(expected.Length), System.Decimal(actual.Length),
               "Verify key length")

    return
Beispiel #6
0
def VerifyReference(expected, actual):
    Test.Equal(expected.Name, actual.Name, "Verify reference name")
    Test.Equal(System.Decimal(expected.Start), System.Decimal(actual.Start),
               "Verify reference start")
    Test.Equal(System.Decimal(expected.Length), System.Decimal(actual.Length),
               "Verify reference length")
    Test.Equal(expected.Color, actual.Color, "Verify reference color")
    Test.Equal(expected.Target, actual.Target, "Verify reference target")
    #Test.Equal(expected.Parent, actual.Parent, "Verify reference parent")
    Test.Equal(expected.Uri, actual.Uri, "Verify reference uri")

    return
Beispiel #7
0
def VerifyMarker(expected, actual):
    Test.Equal(expected.Name, actual.Name, "Verify marker name")
    Test.Equal(expected.Description, actual.Description,
               "Verify key description")
    Test.Equal(System.Decimal(expected.Start), System.Decimal(actual.Start),
               "Verify key start")
    Test.Equal(System.Decimal(expected.Length), System.Decimal(actual.Length),
               "Verify key length")
    Test.Equal(expected.Color, actual.Color, "Verify reference color")
    #Test.Equal(expected.Timeline, actual.Timeline, "Verify group timeline")

    return
Beispiel #8
0
def VerifyInterval(expected, actual):
    Test.Equal(expected.Name, actual.Name, "Verify interval name")
    Test.Equal(expected.Description, actual.Description,
               "Verify interval description")
    Test.Equal(System.Decimal(expected.Start), System.Decimal(actual.Start),
               "Verify interval start")
    Test.Equal(System.Decimal(expected.Length), System.Decimal(actual.Length),
               "Verify interval length")
    Test.Equal(expected.Color, actual.Color, "Verify interval color")
    Test.Equal(expected.Track, actual.Track, "Verify interval track")

    return
Beispiel #9
0
def DotNetDecimalProc(floatNum = 5.3):
	rest_floatNum = round((floatNum - int(floatNum)),5)
	rest_floatNum_st = str(rest_floatNum)
	if(rest_floatNum_st.index('.')):
		num_s = (rest_floatNum_st.split('.'))[1]
		num_f = float(num_s)
		pwdAmt = len(num_s)
		d0 = System.Decimal(floatNum) # d4 = System.Decimal.ToDouble(d0)
		d1 = System.Decimal(num_f)
		d2 = System.Decimal(float(pow(10,pwdAmt)))
		d3 = System.Decimal.Divide(d1,d2)
		d4 = System.Decimal.Add(d0,d3)
		return d4
	return (System.Decimal.Zero)
Beispiel #10
0
def fast_quit():
    DeviceManagerCLI.BuildDeviceList()
    serialNo = DeviceManagerCLI.GetDeviceList(KCubeDCServo.DevicePrefix)
    print(serialNo)
    serialNo = '27252847'
    device = KCubeDCServo.CreateKCubeDCServo(serialNo)
    print(device)
    device.Connect(serialNo)
    device.WaitForSettingsInitialized(10000)
    motorconfiguration = device.LoadMotorConfiguration(serialNo)
    # motorconfiguration = device.LoadMotorConfiguration(serialNo,DeviceConfiguration.DeviceSettingsUseOptionType.UseFileSettings)

    motorconfiguration.DeviceSettingsName = 'Z812B'
    # motorconfiguration.DeviceSettingsName = 'MTS50/M-Z8'
    motorconfiguration.UpdateCurrentConfiguration()

    motorDeviceSettings = device.MotorDeviceSettings
    device.SetSettings(motorDeviceSettings, False)

    device.StartPolling(250)
    device.EnableDevice()
    device.MoveRelative(MotorDirection.Backward, System.Decimal(0.0005), 60000)
    time.sleep(1)
    device.StopPolling()
    device.ShutDown()
    def move_to(self, target):

        current_pos = self.pos()
        moving_range = np.abs(target - current_pos)
        timewait = int(moving_range * 10000)

        if timewait < self.polling_time:
            timewait = self.polling_time
        self.motor.MoveTo(System.Decimal(target), timewait)

        return self.pos()
def test_decimal():
    import System
    if not System.Decimal:
        Fail("should be true: %r", System.Decimal)

    AreEqual(bool(System.Decimal(0)), False)
    AreEqual(bool(System.Decimal(1)), True)
    AreEqual(System.Decimal(True), System.Decimal(1))
    AreEqual(System.Decimal(False), System.Decimal(0))
Beispiel #13
0
def VerifyAttributeVector(domNode, attr, vector):
    Test.Equal(System.Decimal(vector[0]),
               System.Decimal(domNode.GetAttribute(attr)[0]), "Verify X axis")
    Test.Equal(System.Decimal(vector[1]),
               System.Decimal(domNode.GetAttribute(attr)[1]), "Verify Y axis")
    Test.Equal(System.Decimal(vector[2]),
               System.Decimal(domNode.GetAttribute(attr)[2]), "Verify Z axis")

    return
Beispiel #14
0
    def test_decimal(self):
        import System
        if not System.Decimal:
            Fail("should be true: %r", System.Decimal)

        self.assertEqual(bool(System.Decimal(0)), False)
        self.assertEqual(bool(System.Decimal(1)), True)
        self.assertEqual(System.Decimal(True), System.Decimal(1))
        self.assertEqual(System.Decimal(False), System.Decimal(0))
Beispiel #15
0
def VerifyAttributeAngle(domNode, attr, vector):
    Test.FuzzyCompare(System.Decimal(vector[0]),
                      System.Decimal(domNode.GetAttribute(attr)[0]),
                      "Verify X angle")
    Test.FuzzyCompare(System.Decimal(vector[1]),
                      System.Decimal(domNode.GetAttribute(attr)[1]),
                      "Verify Y angle")
    Test.FuzzyCompare(System.Decimal(vector[2]),
                      System.Decimal(domNode.GetAttribute(attr)[2]),
                      "Verify Z angle")

    return
Beispiel #16
0
def AddObjectAndVerify(editingContext, domNodeType, vector):
    domNode = Sce.Atf.Dom.DomNode(domNodeType)
    gameObject = editingContext.Insert(domNode, vector[0], vector[1], vector[2])
    
    Test.Equal(gameObject.DomNode.Type.Name, domNodeType.Name, "Verify the correct type was added")
    
    Test.Equal(System.Decimal(vector[0]), System.Decimal(gameObject.Translation[0]), "Verify new object X pos")
    Test.Equal(System.Decimal(vector[1]), System.Decimal(gameObject.Translation[1]), "Verify new object Y pos")
    Test.Equal(System.Decimal(vector[2]), System.Decimal(gameObject.Translation[2]), "Verify new object Z pos")    
    
    #More generic (and cluttered) way if domNode is returned from insertion
    #Test.Equal(domNode.GetAttribute(domNode.Type.GetAttributeInfo("name")), name, "Verify new object name")
    #Test.EqualSystem.(Decimal(domNode.GetAttribute(domNode.Type.GetAttributeInfo("translate"))[0]), System.Decimal(x), "Verify new object X pos")
    #...

    return gameObject
 def set_backlash(self, lash):
     self.motor.SetBacklash(System.Decimal(lash))
Beispiel #18
0
def AddObjectSetPropertiesAndVerify(editingContext, domNodeType, vTranslation, vScale, vRotation, vRotatePivot):
    domNode = Sce.Atf.Dom.DomNode(domNodeType)
    gameObject = editingContext.Insert(domNode, vTranslation[0], vTranslation[1], vTranslation[2])
    editingContext.SetProperty(gameObject.DomNode, Schema.gameObjectType.scaleAttribute, Test.ConstructArray([vScale[0], vScale[1], vScale[2]]))
    editingContext.SetProperty(gameObject.DomNode, Schema.gameObjectType.rotatePivotAttribute, Test.ConstructArray([vRotatePivot[0], vRotatePivot[1], vRotatePivot[2]]))
    editingContext.SetProperty(gameObject.DomNode, Schema.gameObjectType.rotateAttribute, Test.ConstructArray([vRotation[0], vRotation[1], vRotation[2]]))
    
    Test.Equal(gameObject.DomNode.Type.Name, domNodeType.Name, "Verify the correct type was added")

    Test.Equal(System.Decimal(vTranslation[0]), System.Decimal(gameObject.Translation[0]), "Verify new object X pos")
    Test.Equal(System.Decimal(vTranslation[1]), System.Decimal(gameObject.Translation[1]), "Verify new object Y pos")
    Test.Equal(System.Decimal(vTranslation[2]), System.Decimal(gameObject.Translation[2]), "Verify new object Z pos")
    
    Test.Equal(System.Decimal(vScale[0]), System.Decimal(gameObject.Scale[0]), "Verify new object X scale")
    Test.Equal(System.Decimal(vScale[1]), System.Decimal(gameObject.Scale[1]), "Verify new object Y scale")
    Test.Equal(System.Decimal(vScale[2]), System.Decimal(gameObject.Scale[2]), "Verify new object Z scale")
    
    VerifyAttributeAngle(gameObject.DomNode, Schema.gameObjectType.rotateAttribute, vRotation)
    
    Test.Equal(System.Decimal(vRotatePivot[0]), System.Decimal(gameObject.RotatePivot[0]), "Verify new object X rotate pivot")
    Test.Equal(System.Decimal(vRotatePivot[1]), System.Decimal(gameObject.RotatePivot[1]), "Verify new object Y rotate pivot")
    Test.Equal(System.Decimal(vRotatePivot[2]), System.Decimal(gameObject.RotatePivot[2]), "Verify new object Z rotate pivot")
    
    return gameObject
 def set_jog_step(self, step):
     self.motor.SetJogStepSize(System.Decimal(step))
Beispiel #20
0
def test_decimal_default_param():
    """Test that decimal default parameters work."""
    result = MethodTest.TestDecimalDefaultParam()
    assert result == System.Decimal(1)
Beispiel #21
0
def test_pep3141():
    '''
    This is already well covered by CPython's test_abstract_numbers.py. Just 
    check a few .NET interop cases as well to see what happens.
    '''
    import System
    from numbers import Complex, Real, Rational, Integral, Number
    
    #--Complex
    for x in [
                System.Double(9), System.Int32(4), System.Boolean(1), 
                ]:
        Assert(isinstance(x, Complex))
    
    for x in [
                #http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=23147
                System.Char.MaxValue, 
                System.Single(8), System.Decimal(10),
                System.SByte(0), System.Byte(1),
                System.Int16(2), System.UInt16(3), System.UInt32(5), System.Int64(6), System.UInt64(7),
                ]:
        Assert(not isinstance(x, Complex), x)
        
    #--Real
    for x in [
                System.Double(9), System.Int32(4), System.Boolean(1), 
                ]:
        Assert(isinstance(x, Real))
    
    for x in [
                #http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=23147
                System.Char.MaxValue, 
                System.Single(8), System.Decimal(10),
                System.SByte(0), System.Byte(1),
                System.Int16(2), System.UInt16(3), System.UInt32(5), System.Int64(6), System.UInt64(7),
                ]:
        Assert(not isinstance(x, Real))
    
    
    #--Rational
    for x in [
                System.Int32(4), System.Boolean(1), 
                ]:
        Assert(isinstance(x, Rational))
    
    for x in [
                System.Double(9), 
                #http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=23147
                System.Char.MaxValue, 
                System.Single(8), System.Decimal(10),
                System.SByte(0), System.Byte(1),
                System.Int16(2), System.UInt16(3), System.UInt32(5), System.Int64(6), System.UInt64(7),
                ]:
        Assert(not isinstance(x, Rational))
    
    #--Integral
    for x in [
                System.Int32(4), System.Boolean(1), 
                ]:
        Assert(isinstance(x, Integral))
    
    for x in [
                System.Double(9), 
                #http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=23147
                System.Char.MaxValue, 
                System.Single(8), System.Decimal(10),
                System.SByte(0), System.Byte(1),
                System.Int16(2), System.UInt16(3), System.UInt32(5), System.Int64(6), System.UInt64(7),
                ]:
        Assert(not isinstance(x, Integral))

    #--Number
    for x in [ 
                System.Double(9), System.Int32(4), System.Boolean(1), 
                ]:
        Assert(isinstance(x, Number))
    
    for x in [  
                #http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=23147
                System.Char.MaxValue, 
                System.Single(8), System.Decimal(10),
                System.SByte(0), System.Byte(1),
                System.Int16(2), System.UInt16(3), System.UInt32(5), System.Int64(6), System.UInt64(7),
                ]:
        Assert(not isinstance(x, Number))
Beispiel #22
0
def approach(max_currentin, dev, daq, setpoint_p):

    setpoint = daq.get('/%s/PIDS/%d/SETPOINT' % (dev, 0))
    setpointt = setpoint['dev4346']['pids']['0']['setpoint']['value'][0]
    max_currentin = setpointt / setpoint_p
    ##设置步进电机
    DeviceManagerCLI.BuildDeviceList()
    serialNo = DeviceManagerCLI.GetDeviceList(KCubeDCServo.DevicePrefix)
    print(serialNo)
    serialNo = '27252847'
    device = KCubeDCServo.CreateKCubeDCServo(serialNo)
    print(device)

    device.Connect(serialNo)
    device.WaitForSettingsInitialized(10000)
    motorconfiguration = device.LoadMotorConfiguration(serialNo)
    # motorconfiguration = device.LoadMotorConfiguration(serialNo,DeviceConfiguration.DeviceSettingsUseOptionType.UseFileSettings)

    motorconfiguration.DeviceSettingsName = 'Z812B'
    # motorconfiguration.DeviceSettingsName = 'MTS50/M-Z8'
    motorconfiguration.UpdateCurrentConfiguration()

    motorDeviceSettings = device.MotorDeviceSettings
    device.SetSettings(motorDeviceSettings, False)

    device.StartPolling(250)
    device.EnableDevice()
    currentin = max_currentin
    daq.set([["/%s/pids/%d/enable" % (dev, 0), True]])
    time.sleep(2)

    #步进的步数
    count = 0
    while currentin >= max_currentin * 0.98:
        device.MoveRelative(MotorDirection.Forward, System.Decimal(0.0002),
                            60000)
        time.sleep(0.5)
        data = daq.getSample("/%s/demods/%d/sample" % (dev, 0))
        currentin = np.abs(data['x'][0] + 1j * data['y'][0])
        print(currentin)
        print(count)
        count = 1 + count
    print('sigin突变')
    count = 0
    while np.abs(currentin - max_currentin * 0.95) / (max_currentin *
                                                      0.95) > 0.002:
        device.MoveRelative(MotorDirection.Forward, System.Decimal(0.00015),
                            60000)
        time.sleep(0.5)
        data = daq.getSample("/%s/demods/%d/sample" % (dev, 0))
        currentin = np.abs(data['x'][0] + 1j * data['y'][0])
        print(currentin)
        print(count)
        count = 1 + count
    print('到达setpoint')
    count = 0
    aux = daq.get('/%s/auxouts/%d/value' % (dev, 0))
    auxout_value = aux['dev4346']['auxouts']['0']['value']['value'][0]
    while np.abs(auxout_value - 4.5) > 0.1:
        device.MoveRelative(MotorDirection.Forward, System.Decimal(0.00009),
                            60000)
        time.sleep(0.5)
        aux = daq.get('/%s/auxouts/%d/value' % (dev, 0))
        auxout_value = aux['dev4346']['auxouts']['0']['value']['value'][0]
        print(auxout_value)
        print(count)
        count = 1 + count
    print('进针成功,辅助输出值为:{}'.format(auxout_value))
    device.StopPolling()
    device.ShutDown()
Beispiel #23
0
data[System.UInt64] = [
    1, 2, System.UInt64.MinValue, System.UInt64.MaxValue,
    r.Next(0, System.Int32.MaxValue)
]
data[System.Single] = [
    0, 1, -1, System.Single.MinValue, System.Single.MaxValue,
    r.Next()
]
data[System.Double] = [
    0, 1, -1, System.Math.PI, System.Double.MinValue, System.Double.MaxValue,
    r.NextDouble()
]
data[System.Decimal] = [
    System.Decimal.MinValue, System.Decimal.MaxValue, System.Decimal.MinusOne,
    System.Decimal.Zero, System.Decimal.One,
    System.Decimal(r.Next()),
    System.Decimal(r.NextDouble())
]
data[System.Guid] = [System.Guid.Empty, System.Guid.NewGuid()]
data[System.DateTime] = [
    System.DateTime.MinValue, System.DateTime.MaxValue, System.DateTime.Now,
    System.DateTime.UtcNow, System.DateTime.Today
]
data[System.TimeSpan] = [
    System.TimeSpan.MinValue, System.TimeSpan.MaxValue,
    System.TimeSpan.FromDays(1),
    System.TimeSpan.FromHours(1),
    System.TimeSpan.FromMinutes(1),
    System.TimeSpan.FromSeconds(1),
    System.TimeSpan.FromMilliseconds(1),
    System.TimeSpan.FromTicks(1),