Esempio n. 1
0
 def __init__(self, excutableName):
   super().__init__()
   self._processController = ProcessController(excutableName)
   self._fireingFlag = False
   self._move = 0
   self._rotate = 0
   self._direction = 0
Esempio n. 2
0
class RobotStationServer:
    def __init__(self):
        self.processController = ProcessController()

    @cherrypy.expose
    def index(self):
        return 'welcome to virtuoso robot drink station'

    @cherrypy.expose
    @cherrypy.tools.json_in()
    @cherrypy.tools.json_out()
    def order(self):
        # print 'get somthing'
        orderList = []
        order_id = randint(0, 9999)
        orderdata = cherrypy.request.json
        print orderdata
        for drinkinfo in orderdata['orderList']:
            drink = Drink(**drinkinfo)
            drink.order_id = order_id
            orderList.append(drink)
            print drink.__dict__

        self.processController.getorder(orderList)
        self.processController.lockerManager.addProcessingOrder(order_id)
        print orderList
        return {'response': 'Order recivied!! Your order id is %d' % order_id}

    @cherrypy.expose
    def getProcess(self):
        info = 'processing list = '
        for drink in self.processController.getProcessingList():
            info += str(drink.__dict__)

        return info

    @cherrypy.expose
    def close(self):
        self.processController.lockerManager.disConnectMega()
        return 'serial closed'
Esempio n. 3
0
 def __init__(self):
     self.processController = ProcessController()
Esempio n. 4
0
from processController import ProcessController
import json
from RobotStations.Drinks import Drink

pc = ProcessController()
drink1 = Drink()
drink2 = Drink()

drink1.black_tea = 10
drink1.wm_tea = 0
drink1.ingredients = 5
drink1.ice = 5
drink1.sugar = 3

drink2.black_tea = 1
drink2.wm_tea = 10
drink2.ingredients = 3
drink2.ice = 7
drink2.sugar = 0

drinkList = [drink1, drink2]

if __name__ == '__main__':
    pc.getorder(drinkList)
Esempio n. 5
0
class AiManager(Runnable):
  SPEED = 3
  def __init__(self, excutableName):
    super().__init__()
    self._processController = ProcessController(excutableName)
    self._fireingFlag = False
    self._move = 0
    self._rotate = 0
    self._direction = 0
  def setFiring(self,flag):
    #trueになると打っている
    #毎フレームチェックされる。
    self._fireingFlag = flag
  '''
  def setObjectivePoint(self,point):
    #目的地設定
    self._objectivePoint = point
  #毎フレームunit.step()が呼び出すもの
  def setPosition(self, position):
    self._position = position
  def setDirection(self, arg):
    #方向を変える
    self._direction = arg
  '''
  def getMove(self):
    if self._move > UNIT_MAX_SPEED:
      return UNIT_MAX_SPEED
    if self._move <0:
      return 0
    return self._move
  def getRotate(self):
    if self._rotate > UNIT_MAX_ROLL_ANGLE:
      return UNIT_MAX_ROLL_ANGLE
    if self._rotate < - UNIT_MAX_ROLL_ANGLE:
      return - UNIT_MAX_ROLL_ANGLE
    return self._rotate
  def getFiring(self):
    return self._fireingFlag
  '''
  def getPosition(self):
    #todo動き方
    return self._position
  def getDirection(self):
    return self._direction
    '''
  #通信用
  def writeMessage(self, unit, gameManager):
    string = CatString()
    
    gameManager.writeMessage(unit,string)
    self._processController.write(string)
    
  def sendEndMessage(self,unit,gameManager):
    string = CatString()
    
    gameManager.writeEndMessage(unit,string)
    self._processController.write(string)
  def sendStartingMessage(self,unit,gameManager):
    string = CatString()
    
    gameManager.writeStartingMessage(unit,string)
    self._processController.write(string)
  def step(self):
    #todoとりあえず
    #self._direction += self._rotate
    
    '''
    self._position += Coordinate( sin(self._direction), -cos(self._direction))*2
    '''
  def readMessage(self):
    data = self._processController.readline()
    self._move = 0
    self._rotate = 0
    self._fireingFlag = False
    if data == None:
      return
    data = data.split()
    if len(data) == 3:
      self._matchMessage(data)
  def _matchMessage(self,factorList):
    self._move = float(factorList[0])
    self._rotate = float(factorList[1])
    self._fireingFlag = int(factorList[2]) != 0
  def end(self):
    self._processController.end()
    Runnable.end(self)