55 lines
2.1 KiB
Python
55 lines
2.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
import requests
|
|
import logging
|
|
from odoo import fields, models
|
|
|
|
|
|
class AgvSetting(models.Model):
|
|
_name = 'sf.agv.site'
|
|
_description = 'agv站点'
|
|
|
|
name = fields.Char('位置编号')
|
|
owning_region = fields.Char('所属区域')
|
|
state = fields.Selection([
|
|
('占用', '占用'),
|
|
('空闲', '空闲')], string='状态')
|
|
divide_the_work = fields.Char('主要分工')
|
|
active = fields.Boolean('有效', default=True)
|
|
|
|
def update_site_state(self):
|
|
# 调取中控的接驳站接口并修改对应站点的状态
|
|
config = self.env['res.config.settings'].get_values()
|
|
# token = sf_sync_config['token'Ba F2CF5DCC-1A00-4234-9E95-65603F70CC8A]
|
|
headers = {'Authorization': config['center_control_Authorization']}
|
|
center_control_url = config['center_control_url'] + "/AutoDeviceApi/GetAgvStationState"
|
|
center_control_r = requests.get(center_control_url, params={}, headers=headers)
|
|
ret = center_control_r.json()
|
|
logging.info('工件配送-请求中控站点信息:%s' % ret)
|
|
if ret['Succeed'] is True:
|
|
datas = ret['Datas']
|
|
for item in self:
|
|
for da in datas:
|
|
if da['DeviceId'] == item.name:
|
|
if da['AtHome'] is True:
|
|
item.state = '占用'
|
|
|
|
|
|
class AgvTaskRoute(models.Model):
|
|
_name = 'sf.agv.task.route'
|
|
_description = 'agv任务路线'
|
|
|
|
name = fields.Char('名称')
|
|
type = fields.Selection([
|
|
('F01', '搬运'), ], string='类型', default="F01")
|
|
start_site_id = fields.Many2one('sf.agv.site', '起点接驳站位置编号')
|
|
end_site_id = fields.Many2one('sf.agv.site', '终点接驳站位置编号')
|
|
destination_production_line_id = fields.Many2one('sf.production.line', '目的生产线')
|
|
priority = fields.Selection([
|
|
('0', '正常'),
|
|
('1', '低'),
|
|
('2', '中'),
|
|
('3', '高'),
|
|
('4', '紧急'),
|
|
], string='优先级', default='0')
|
|
active = fields.Boolean('有效', default=True)
|