本文整理汇总了Python中Control类的典型用法代码示例。如果您正苦于以下问题:Python Control类的具体用法?Python Control怎么用?Python Control使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Control类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: collectData
def collectData(db):
global lock
if db.connect():
try:
Control.getSettings (db)#Control sistema calefaccio
records=db.select("SELECT ipv6,thingToken FROM motes where type=0 and thingToken IS NOT NULL and thingToken !=''")
lowTemp=False#Control sistema calefaccio
for row in records:
try:
ipv6=str(row[0])
temp =ObjectCoAP.sendGET(ipv6,'temp' )
if temp is not None:
tempValue = ConvertValue.getTemperature(temp)
if not lowTemp: #Control sistema calefaccio
lowTemp = Control.checkTemp(tempValue) #Control sistema calefaccio
hum =ObjectCoAP.sendGET(ipv6,'hum' )
if hum is not None:
humValue=ConvertValue.getHumidity(hum)
if (tempValue or humValue) is not None:
send=SendDataToServer(lock,tempValue,humValue,ipv6,str(row[1]))#Emmagatzematge a thethings.iO
send.start()#Emmagatzematge a thethings.iO
except:
Log.writeError( "No hi ha comunicacio amb la mota "+ ipv6)
pass
Control.checkAction(lowTemp)#Control sistema calefaccio
except:
pass
db.close()
示例2: __init__
class Interface:
def __init__(self, robothost, robotport):
self.ctr = Control(self.__class__.__name__)
self.robot = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
while True:
try:
self.robot.connect((robothost, robotport))
except socket.error:
print "NO CONNECTION TO THE ROBOT, WTF ARE YOU DOING!"
sleep(5)
continue
break
self.mainloop()
exit(0)
def mainloop(self):
#Spawn Bro-bot
self.robot.send(ROBOT_COMMAND)
while True:
recv = self.ctr.receive(True)
if recv:
src, data = recv
if src == 'main' and data == 'STOP':
break
self.robot.send(data)
ready, _, _ = select(list(self.robot),(),(), 0.05)
for x in ready:
data = x.recv(1024)
self.ctr.send('Sensors', data)
示例3: ControlTestCase
class ControlTestCase(unittest.TestCase):
def setUp(self):
self.prefix = "ControlTeam: Control: "
self.con = Control()
self.om = self.con.getObsManager()
def tearDown(self):
self.con.close()
示例4: createBlueprinter
def createBlueprinter( name, args ):
'Creates a default blueprinters'
ret = {}
sctl = []
jnt = ""
functArgs = {"shape":"cube", "size":1, "t":0, "r":0, "s":0}
functArgs = dict(functArgs.items() + args.items())
#create Control
if(functArgs["shape"] == "cube"):
sctl = Control.cubeCtl( name, functArgs )
elif(functArgs["shape"] == "sphere"):
sctl = Control.sphereCtl( name, functArgs )
elif(functArgs["shape"] == "arrow"):
sctl = Control.arrowCtl( name , functArgs )
elif(functArgs["shape"] == "locator"):
sctl = Control.locatorCtl( name , functArgs )
else:
print "Shape not supported...\n"
return 0
#lock hide unwanted Attribute
if functArgs["t"] == 1:
Attribute.lockHide(sctl[0], {"t":1, "h":1, "l":1})
if functArgs["r"] == 1:
Attribute.lockHide(sctl[0], {"r":1, "h":1, "l":1})
if functArgs["s"] == 1:
Attribute.lockHide(sctl[0], {"s":1, "h":1, "l":1})
#add blueprinter joint
jnt = cmds.joint( n = ( name + "_SJNT" ), p= (0, 0, 0 ) )
Constraint.constrain(sctl[0], jnt, args={ "t":1, "mo":0, "name":(name)} )
#matrixConstraint(sctl[0] , jnt, 0, {})
#template(jnt)
#parent to root
cmds.parent(jnt,sctl[0])
#cmds.parent(ret["sctl"][1],rootGrp)
#rename suffix
newName = sctl[0].replace("_CTL","_SCTL")
cmds.rename(sctl[0],newName)
sctl[0] = newName
newName = sctl[1].replace("Ctl_GRP","Sctl_GRP")
cmds.rename(sctl[1],newName)
sctl[1] = newName
#create blueprinter variable
"""for blueprinter in sctl:
storeString(blueprinter, "blueprinter", "")
storeString(jnt, "sjoint", "")"""
ret["sctl"] = sctl
ret["jnt"] = jnt
return ret
示例5: _makeFkControls
def _makeFkControls(fkControls=None, side=None):
pymelLogger.debug('Starting: _makeControls()...')
topNodeList = []
for ctrl in fkControls:
parent = ctrl.replace('_'+Names.suffixes['fk']+'_'+Names.suffixes['control'],'')
topNode = Control.create( name=ctrl, offsets=3, shape='circle_01',
size=1.5, color=_getSideColor(side),
pos=None, parent=parent, typ='body' )
pm.parent(topNode, world=1)
topNodeList.append(topNode)
# getting ctrl and contrainting it directly to the jnt
childs = topNode.listRelatives(ad=1)
if 'Shape' in str(childs[0]):
cc = childs[1]
else: cc = childs[0]
pm.parentConstraint(cc,parent, mo=1)
# parent each offset to the previous ctrl
topNodeList.reverse()
last = ''
for element in topNodeList:
if last:
last.setParent(element.listRelatives(ad=1)[1]) # getting transform node not shape
last = element
topOffsetNode = last
return topOffsetNode
pymelLogger.debug('End: _makeControls()...')
示例6: __init__
def __init__(self, filepath, control = None, encoding = 'utf-8'):
if control == None:
control = Control.control()
self.control = control
self.filepath = filepath
with codecs.open(filepath, 'r', encoding) as f:
self.lines = self._genlines(f.read())
示例7: createOriginalViewer
def createOriginalViewer(imagesDirectory,htmlPath,Reducer,QLSA):
try:
os.mkdir(imagesDirectory)
except:
print "Error Creating folder"
# he maximum in the swimmer matrix is 39
return Control.imageOriginalViewGenerator(39.0,imagesDirectory,htmlPath,32,True,QLSA)
示例8: createOriginalViewer
def createOriginalViewer(imagesDirectory,htmlPath,Reducer):
try:
os.mkdir(imagesDirectory)
except:
print "Error Creating folder"
# he maximum in the swimmer matrix is 39
return Control.imageOriginalViewGenerator(Reducer.reduction.data.max(),imagesDirectory,htmlPath,241)
示例9: __init__
def __init__(self):
self.ctrl = Control(self.__class__.__name__)
self.TRESHOLD_S = 0.4
self.TRESHOLD_L = 0.25
self.RECOVERTIME = 3
self.running = True
self.run()
示例10: createRepresentationViewer
def createRepresentationViewer(imagesDirectory, htmlPath, Reducer, h):
try:
os.mkdir(imagesDirectory)
except:
print "Error Creating folder"
return Control.imageScaledViewGenerator(
Reducer.reduction.objectsM.max(), Reducer.reduction.objectsM.min(), imagesDirectory, htmlPath, h, 10
)
示例11: createBasisViewer
def createBasisViewer(basisDirectory, htmlPath, Reducer, QLSA):
try:
os.mkdir(basisDirectory)
except:
print "Error Creating folder"
return Control.imageViewGenerator(
Reducer.reduction.basisM.max(), Reducer.reduction.basisM.min(), basisDirectory, htmlPath, 19, True, QLSA
)
示例12: clusterizeCurve
def clusterizeCurve(curve):
curveNumber = getCurveCVNumber(curve)
curveName = String.removeSuffix(curve)
clusterName = (curveName + "Cluster")
clusterList = []
for x in range(curveNumber):
clusterList.append( Control.createCluster( ( clusterName + str(x) ), ( curve + ".cv["+ str(x) +"]" ) ) )
return clusterList
示例13: __init__
def __init__(self):
self.ctrl = Control(self.__class__.__name__)
self.gridSize = 1.0
self.treshold_l = 0.4
self.treshold_s = 0.25
self.sonar = ""
self.laser = ""
self.running = True
self.drive(0)
示例14: createHipShoudersControls
def createHipShoudersControls( drvStart, drvEnd, jntList ):
pymelLogger.debug('Starting: createHipShoudersControls()...')
# Get drvStart Position
drvS_pos = pm.xform(drvStart[0], query = True, translation = True)
# Get drvEnd Position
drvE_pos = pm.xform(drvEnd[0], query = True, translation = True)
# Create Hip Control
ctrl = jntList[0] + '_' + Names.suffixes['control']
rot = pm.xform(drvStart[0],q=1,ws=1,ro=1)
rot = [-90,0,90]
hips_cnt = Control.create( name= ctrl , offsets=2, shape='cube',
size=[1,1,1], color='cyan',
pos=drvS_pos, rot=rot, parent=None, typ='body' )
# Create Shoulder Ctrl
#shoulder_cnt = Control.create()
######## fix this !!! top spine ctrl shoud b called SpineX_ctrl
ctrl = jntList[-1]+ '_' + Names.suffixes['control']
rot = pm.xform(jntList[-1],ws=1,q=1,ro=1)
shoulder_cnt = Control.create( name=ctrl, offsets=2, shape='circle_01',
size=2, color='red',
pos=drvE_pos,rot=rot, parent=None, typ='body' )
# Connect CC to Drv Jnts
pm.parentConstraint(hips_cnt.listRelatives(ad=1)[0].getParent(), drvStart, maintainOffset = True)
pm.parentConstraint(shoulder_cnt.listRelatives(ad=1)[0].getParent(), drvEnd, maintainOffset = True)
# Clean Ctrls Attributes (Lock and Hide Scale and Visibility)
hideLockAttr(hips_cnt, lockHideSV)
hideLockAttr(shoulder_cnt, lockHideSV)
hideLockAttr(drvStart[0], lockHideS)
hideLockAttr(drvEnd[0], lockHideS)
rList = [hips_cnt, shoulder_cnt]
pymelLogger.debug('End: createHipShoudersControls()...')
return rList
示例15: setup
def setup():
###############################################################################
#import Data
import Prediction
import warnings
import Control
warnings.filterwarnings("ignore")
Prediction_horizon = 60 # in minutes
#Data.data_acquisition()
DATA_LIST={}
wb = openpyxl.load_workbook('DATA_LIST.xlsx')
sheet = wb.get_sheet_by_name('Sheet1')
for key in range(1, sheet.max_column+1):
DATA_LIST[sheet.cell(row=1, column=key).value]=[]
for v in range(2, sheet.max_row+1):
DATA_LIST[sheet.cell(row=1, column=key).value].append(sheet.cell(row=v, column=key).value)
# Model generation
#SVR_model = Prediction.Support_Vector_Regression(DATA_LIST, Prediction_horizon)
KNN_model = Prediction.kNN_Regression(DATA_LIST, Prediction_horizon)
BRR_model = Prediction.Bayesian_Ridge_Regression(DATA_LIST, Prediction_horizon)
# workbook = xlsxwriter.Workbook(os.path.dirname(os.path.abspath(__file__))+'\Control.xlsx')
# workbook.add_worksheet()
# workbook.close()
alpha = 0.7 # Higher alpha means slower adaptation
T_history={}
try:
for i in range(1,8):
T_history[str(i)] = Control.max_T_history(Control.previous_date(i))
Mean_Running_Average = (1.0 - alpha) * sum( (alpha** (i-1) ) * int(T_history [str(i)]) for i in range(1,8) )
except Exception:
Mean_Running_Average = 20
return DATA_LIST, KNN_model, BRR_model, Mean_Running_Average