hc_common

package
v0.0.0-...-fb9317b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const SCHEMA_BOM = `` /* 1974-byte string literal not displayed */

BOM相关的数据结构

View Source
const SCHEMA_TEST = `` /* 559-byte string literal not displayed */

Variables

This section is empty.

Functions

This section is empty.

Types

type AfterCancelTaskHandler

type AfterCancelTaskHandler func() error

任务被取消后,执行的函数

type AfterStatChangeHandler

type AfterStatChangeHandler func() error

任务状态改变后,执行的函数

type AgvTask

type AgvTask struct {
	Uid          string    `json:"uid,omitempty"`
	Name         string    `json:"task_name,omitempty"`     //任务名称
	Code         string    `json:"task_code,omitempty"`     //任务编码
	MaterialCode string    `json:"material_code,omitempty"` //物料编码
	Res          Res       `json:"Res,omitempty"`           //执行该任务的资源
	Stat         TaskType  `json:"stat,omitempty"`          //任务状态
	StatMsg      string    `json:"stat_msg,omitempty"`      //任务改变状态的说明
	EarlyTime    time.Time `json:"early_time,omitempty"`    //最早开始时间
	LatestTime   time.Time `json:"latest_time,omitempty"`   //最晚结束时间
	StartTime    time.Time `json:"start_time,omitempty"`    //实际开工时间
	EndTime      time.Time `json:"end_time,omitempty"`      //实际完工时间
	SubTask      []ITask   `json:"sub_task,omitempty"`      //任务链中的下一个任务
	FromPoint    []Res     `json:"from_point,omitempty"`    //任务开始点资源(可以从几个点取货)
	ToPoint      []Res     `json:"to_point,omitempty"`      //任务结束点资源(可以送往几个点)

	//PreTask                 *Task     `json:"pre_task,omitempty"`      //前置任务
	//NextTask                *Task     `json:"sub_task,omitempty"`      //后置任务
	Planed   bool     `json:"planed,omitempty"`    //已经计算过
	TimePath timeNode `json:"time_node,omitempty"` //计算后占用对应资源的时间点集合
	DType    []string `json:"dgraph.type,omitempty"`
	// contains filtered or unexported fields
}

转运任务

func NewAgvTask

func NewAgvTask(n string, mc string, res Res, fromPoint []Res, toPoint []Res) AgvTask

type BeforeActivateTaskHandler

type BeforeActivateTaskHandler func() error

任务开始执行前,执行的函数

type BeforeCancelTaskHandler

type BeforeCancelTaskHandler func() error

任务被取消前,执行的函数,如果返回错误则不执行取消操作

type BeforeStatChangeHandler

type BeforeStatChangeHandler func() error

任务状态改变前,执行的函数

type CmdReceiveHandler

type CmdReceiveHandler func() error

type CmdSendHandler

type CmdSendHandler func() error

type CncTask

type CncTask struct {
	Task
}

机加任务

func NewCncTask

func NewCncTask(n string, mc string) CncTask

func (CncTask) Activate

func (c CncTask) Activate() error

func (CncTask) TypeOf

func (c CncTask) TypeOf() string

type Craft

type Craft struct {
	Uid       string   `json:"uid,omitempty"`
	Code      string   `json:"c_code,omitempty"`
	Name      string   `json:"c_r|c_name,omitempty"`       //工序名称
	Line      string   `json:"c_r|c_line,omitempty"`       //工序行号
	ReadyTime int      `json:"c_r|c_ready_time,omitempty"` //准终工时
	DoTime    int      `json:"c_r|c_do_time,omitempty"`    //单件工时
	Res       []Res    `json:"c_r,omitempty"`              //使用资源
	DType     []string `json:"dgraph.type,omitempty"`
}

type ExceptionReport

type ExceptionReport struct {
	Rep
}

上报异常数据

type ICmd

type ICmd interface {
	Send(b []byte) error
	Receive()
}

指令

type ITask

type ITask interface {
	//激活任务(开始执行)
	Activate() error
	//取消任务
	//before bool,为true: 则不论beforeHandler 成功与否都会取消任务,为false:当beforeHandler返回错误时则不取消任务
	Cancel(bool) error
	//改变任务状态(任务不支持回滚,值能改变为下一状态)
	NextStat(TaskType) error
	//任务取消前的处理函数
	SetBeforeCancelHandler(BeforeCancelTaskHandler) error
	//任务取消后的处理函数
	SetAfterCancelHandler(AfterCancelTaskHandler) error
	//任务激活前的处理函数
	SetBeforeActivateHandler(BeforeActivateTaskHandler) error
	//任务状态改变前的处理函数
	SetBeforeStatChange(BeforeStatChangeHandler) error
	//任务状态改变后的处理函数
	SetAfterStatChange(AfterStatChangeHandler) error
	//任务结束后的处理函数
	SetOverHandler(OverHandler) error
	//设置任务链
	//SetSubTask(iTask ITask) error
	////设置前置任务
	//SetPreTask(iTask ITask) error
	////设置后置任务
	//SetNextTask(iTask ITask) error
	//设置计划结果
	SetPlan(time.Time, time.Time) error
	//添加类型标签
	SetType(s string) error
	//获取任务的状态
	ForStat() TaskType
	//获取任务持续运行时间
	ForRunTime() int64
	//是否已经入链 0:独立、1:最后一链、2第一链、3中间链
	//ForIsChain() int
	//是否已经计划排产
	ForIsPlan() bool
	//与上一个任务的时间轴射影是否重叠(重叠意味着排序失败)
	//AxisProjectiveOverlap() bool
	//任务计划执行时间
	DurationPlanMinutes() int64
	//任务实际执行时间
	DurationDoMinutes() int64
	//任务类型
	TypeOf() string
}

任务的接口

type Ireport

type Ireport interface {
	Send()
	Connect()
	Close()
}

type OverHandler

type OverHandler func() error

任务正常执行结束后,执行的函数

type Rep

type Rep struct {
	// contains filtered or unexported fields
}

数据上报消息

func (*Rep) Close

func (r *Rep) Close()

func (*Rep) Connect

func (r *Rep) Connect()

func (*Rep) Send

func (r *Rep) Send()

type Res

type Res struct {
	Uid     string   `json:"uid,omitempty"`
	MainRes bool     `json:"r_main,omitempty"` //是否主任务
	Name    string   `json:"r_name,omitempty"`
	Group   int      `json:"r_group,omitempty"`
	Code    string   `json:"r_code,omitempty"`
	DType   []string `json:"dgraph.type,omitempty"`
}

资源

func (*Res) ForCode

func (r *Res) ForCode() string

func (*Res) ForMain

func (r *Res) ForMain() bool

func (*Res) ForName

func (r *Res) ForName() string

type ResGroupType

type ResGroupType int

资源类别

const (
	ResGroup_AgvYS ResGroupType = 1 //运输小车
	ResGroup_CNC   ResGroupType = 2 //全自动机床
	ResGroup_WmsGW ResGroupType = 3 //仓库工位
	ResGroup_ZpGw  ResGroupType = 4 //装配工位
)

func (ResGroupType) String

func (rt ResGroupType) String() string

type RuntimeReport

type RuntimeReport struct {
	Rep
}

上报运行数据

type Task

type Task struct {
	Uid          string    `json:"uid,omitempty"`
	Name         string    `json:"t_name,omitempty"`                //任务名称
	Code         string    `json:"t_code,omitempty"`                //任务编码
	MaterialCode string    `json:"t_m_code,omitempty"`              //物料编码
	Res          Res       `json:"t_use_r,omitempty"`               //执行该任务的资源
	Stat         TaskType  `json:"t_stat,omitempty"`                //任务状态
	StatMsg      string    `json:"t_stat|stat_msg,omitempty"`       //任务改变状态的说明
	EarlyTime    time.Time `json:"t_p_start_time,omitempty"`        //最早开始时间
	LatestTime   time.Time `json:"t_p_end_time,omitempty"`          //最晚结束时间
	StartTime    time.Time `json:"t_start_time,omitempty"`          //实际开工时间
	EndTime      time.Time `json:"t_end_time,omitempty"`            //实际完工时间
	Planed       bool      `json:"t_planed,omitempty"`              //已经计算过
	TimePath     time.Time `json:"t_planed|t_time_point,omitempty"` //计算后占用对应资源的时间点集合
	OffsetMinute int       `json:"t_planed|t_offset_minute,omitempty"`
	TaskType     string    `json:"t_type,omitempty"`              //任务类型
	FromPoint    string    `json:"t_type|t_from.point,omitempty"` //如果是运输任务 起始地点
	ToPoint      string    `json:"t_type|t_to.point,omitempty"`   //如果是运输任务 终止地点

	DType []string `json:"dgraph.type,omitempty"`
	// contains filtered or unexported fields
}

任务基类

func (Task) Activate

func (t Task) Activate() error

激活函数

func (Task) Cancel

func (t Task) Cancel(b bool) error

取消任务

func (Task) DurationDoMinutes

func (t Task) DurationDoMinutes() int64

执行的真实持续时间,秒

func (Task) DurationPlanMinutes

func (t Task) DurationPlanMinutes() int64

计划执行持续时间,秒

func (Task) ForIsPlan

func (t Task) ForIsPlan() bool

func (Task) ForRunTime

func (t Task) ForRunTime() int64

func (Task) ForStat

func (t Task) ForStat() TaskType

func (Task) NextStat

func (t Task) NextStat(stat TaskType) error

改变任务的状态 Stat: 需要改变的状态

func (Task) SetAfterCancelHandler

func (t Task) SetAfterCancelHandler(f AfterCancelTaskHandler) error

设置 任务取消后 触发函数

func (Task) SetAfterStatChange

func (t Task) SetAfterStatChange(f AfterStatChangeHandler) error

设置 任务的状态改变后的处理行数

func (Task) SetBeforeActivateHandler

func (t Task) SetBeforeActivateHandler(f BeforeActivateTaskHandler) error

设置 任务激活前的 处理函数

func (Task) SetBeforeCancelHandler

func (t Task) SetBeforeCancelHandler(f BeforeCancelTaskHandler) error

设置 任务取消前 触发函数

func (Task) SetBeforeStatChange

func (t Task) SetBeforeStatChange(f BeforeStatChangeHandler) error

设置 任务状态修改前的 处理函数

func (Task) SetOverHandler

func (t Task) SetOverHandler(f OverHandler) error

设置 任务完成后的 处理函数

func (Task) SetPlan

func (t Task) SetPlan(startTime time.Time, endTime time.Time) error

func (Task) SetType

func (t Task) SetType(s string) error

func (Task) TypeOf

func (t Task) TypeOf() string

任务类型

type TaskRep

type TaskRep struct {
	Rep
	// contains filtered or unexported fields
}

人工报工数据

func NewTaskRep

func NewTaskRep(taskCode string, fromPoint string, repType int) *TaskRep

实例报工单 taskCode : 任务编码 fromPoint: 报送资源编码 repType : 报工类型 开始/完工(0/1)

func (*TaskRep) SetMsg

func (t *TaskRep) SetMsg(msg []byte) *TaskRep

func (*TaskRep) SetToPoint

func (t *TaskRep) SetToPoint(point string) *TaskRep

type TaskType

type TaskType int
const (
	TaskStatDraft  TaskType = 1 //等待确认
	TaskStatActive TaskType = 2 //激活状态
	TaskStatRun    TaskType = 3 //运行中
	TaskStatCancel TaskType = 4 //取消
	TaskStatOver   TaskType = 5 //正常完工
)

type WorkOrder

type WorkOrder struct {
	Uid       string    `json:"uid,omitempty"`
	Code      string    `json:"wo_code,omitempty"`        //编码
	StartTime time.Time `json:"wo_start,omitempty"`       //计划开始时间
	EndTime   time.Time `json:"wo_end,omitempty"`         //计划完工时间
	State     int       `json:"wo_state,omitempty"`       //工单当前状态 0:执行中 1完成 -1:取消
	Tasks     []Task    `json:"wo_t,omitempty"`           //工单下的任务
	Line      string    `json:"wo_t|wo_t_line,omitempty"` //任务的数序号
	DType     []string  `json:"dgraph.type,omitempty"`
}

工单

type Workpiece

type Workpiece struct {
	Uid        string       `json:"uid,omitempty"`
	Code       string       `json:"b_code,omitempty"`     //编码
	Name       string       `json:"b_name,omitempty"`     //名称
	Spec       string       `json:"b_spec,omitempty"`     //规格
	Unit       string       `json:"b_unit,omitempty"`     //计量单位
	WmsType    string       `json:"b_wms_type,omitempty"` //仓库供应类型
	Cost       string       `json:"b_cost,omitempty"`     //成本相关
	GetType    string       `json:"b_get_type,omitempty"` //生产类型
	Remark     string       `json:"b_remark,omitempty"`   //备注
	HasCF      []*Craft     `json:"b_cf,omitempty"`
	Category   int          `json:"b_cf|b_cf_category,omitempty"`       //工艺种类。装配2,生产1
	HasWO      []*WorkOrder `json:"b_wo,omitempty"`                     //工单
	HasWP      []*Workpiece `json:"b_children,omitempty"`               //下级子件
	Level      string       `json:"b_children|b_level,omitempty"`       //节点层级
	Line       string       `json:"b_children|b_line,omitempty"`        //子件行号
	BasicCount float64      `json:"b_children|b_basic_count,omitempty"` //基础用量
	BasicUnit  float64      `json:"b_basic_unit,omitempty"`             //基础数量
	UsedCount  float64      `json:"b_children|b_used_count,omitempty"`  //使用数量
	DType      []string     `json:"dgraph.type,omitempty"`
	// contains filtered or unexported fields
}

func (*Workpiece) GetPcode

func (wp *Workpiece) GetPcode() string

func (*Workpiece) SetPcode

func (wp *Workpiece) SetPcode(pc string)

type ZhuangpeiTask

type ZhuangpeiTask struct {
	Task
}

func (ZhuangpeiTask) TypeOf

func (z ZhuangpeiTask) TypeOf() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL