fix
zhangqian
2023-10-19 cab6eea89a0d82710369604ecb51f1cdb122e433
model/common/common.go
@@ -1,6 +1,9 @@
package common
import "github.com/shopspring/decimal"
import (
   "apsClient/constvar"
   "github.com/shopspring/decimal"
)
// 排程任务下发
type (
@@ -48,6 +51,7 @@
      OutputMaterials   []*ProcedureMaterial `json:"outputMaterials"`   // 输出物料列表
      Workers           []*ProcedureWorker   `json:"workers"`           // 人员列表
      AllProcedureNames []string             `json:"allProcedureNames"` // 所属工单工序列表
      Channel           int32                `json:"channel"`           //通道序号
   }
   DeliverScheduleTask struct {
@@ -62,9 +66,32 @@
      DeviceId string
   }
   ResponsePlcAddress struct {
      KeyData     []byte
      AddressData []byte
      DeviceId    string
      KeyData        []byte
      AddressData    []byte
      DeviceId       string
      PlcAddressList []*PlcAddress //plc 完成量,总量, 读写地址
      PlcConfig      PlcConfig     //用网口还是端口以及网口ip port
   }
   PlcConfig struct {
      Brand      string             `gorm:"type:varchar(191)" json:"brand"`   //comment:PLC品牌
      Method     constvar.PlcMethod `gorm:"type:varchar(191)" json:"method"`  //comment:接口方式
      Address    string             `gorm:"type:varchar(191)" json:"address"` //plc ip地址, method = modbusTCP用
      Port       int                `gorm:"type:int(11)" json:"port"`         //plc 端口号,  method =  modbusTCP用
      BaudRate   int                `gorm:"type:int(11)"  json:"baudRate"`    //串口波特率, method = serial时 用
      SerialName string             `gorm:"type:int(11)"  json:"serialName"`  //串口名称,method = serial时 用
      IsOpen     bool               `gorm:"type:tinyint(1)" json:"isOpen"`
      Detail     string             `gorm:"type:varchar(2048)" json:"-"`
      Details    []*PlcAddress      `gorm:"-" json:"details"`
   }
   PlcAddress struct {
      DeviceID     string                       `json:"deviceID"`     // 设备id
      Channel      int                          `json:"channel"`      // 生产通道on,一个机器可能有多个机位,需要分别配置plc地址
      StartAddress int                          `json:"startAddress"` // 数据起始地址
      Length       int                          `json:"length"`       // 数据长度
      Type         string                       `json:"type"`         // 数据类型
      FieldName    constvar.PlcStartAddressType `json:"fieldName"`    // 对应系统字段,完成量或总量
   }
)
@@ -99,3 +126,30 @@
   IsProcessing bool   //是否处理中
   IsFinish     bool   //是否完成
}
type Device struct {
   ID                  string                 `gorm:"comment:主键ID;primaryKey;type:varchar(191);" json:"id"`
   DeviceProcedureAttr []*DeviceProcedureAttr `json:"deviceProcedureAttr"` // 设备工序属性列表
   ExtChannelAmount    int                    `gorm:"type:tinyint;comment:额外的通道数量;default:0;" json:"extChannelAmount"`
}
type DeviceProcedureAttr struct {
   ProcedureID   string `gorm:"index;type:varchar(191);comment:工序ID" json:"procedureId"`
   ProcedureName string `gorm:"type:varchar(191);comment:工序名称" json:"procedureName"`
   DeviceID      string `gorm:"index;type:varchar(191);not null;comment:设备ID" json:"deviceId"`
}
type PullDataType string
const (
   PullDataTypeProcessModel = "process_model"
)
// MsgPullDataRequest 拉取云端数据
type MsgPullDataRequest struct {
   DataType PullDataType `json:"dataType"` //要拉取的数据类型
}
type MsgPullDataResponse struct {
   DataType PullDataType `json:"dataType"` //要拉取的数据类型
   Data     interface{}  //返回的数据
}