fix
zhangqian
2023-10-30 10c65da3d2af7056f48d9301e83f53f102f76e18
model/common/common.go
@@ -74,14 +74,17 @@
   }
   PlcConfig struct {
      Brand      string             `gorm:"type:varchar(191);comment:PLC品牌" json:"brand"`
      Method     constvar.PlcMethod `gorm:"type:varchar(191);comment:接口方式" json:"method"`
      Address    string             `gorm:"type:varchar(191);comment:PLC地址" json:"address"` //plc ip地址, method = modbusTCP用
      Port       int                `gorm:"type:int(11);comment:端口" json:"port"`            //plc 端口号,  method =  modbusTCP用
      BaudRate   int                `gorm:"type:int(11);comment:波特率"  json:"baudRate"`      //串口波特率, method = serial时 用
      SerialName string             `gorm:"type:int(11);comment:串口名称"  json:"serialName"`   //串口名称,method = serial时 用
      IsOpen     bool               `gorm:"type:tinyint(1);comment:是否开启" json:"isOpen"`
      Detail     string             `gorm:"type:varchar(2048);comment:数据详情" json:"-"`
      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或modbusRTU 时用
      SerialName string             `gorm:"type:int(11)"  json:"serialName"`  //串口名称,method = serial或modbusRTU 时用
      DataBit    int                `gorm:"type:int(11)"  json:"dataBit"`     //数据位,method = modbusRTU 用
      StopBit    int                `gorm:"type:int(11)"  json:"stopBit"`     //停止位,method = modbusRTU 用
      Parity     constvar.Parity    `gorm:"type:int(11)"  json:"parity"`      //校验方式,method = modbusRTU 用
      IsOpen     bool               `gorm:"type:tinyint(1)" json:"isOpen"`
      Detail     string             `gorm:"type:varchar(2048)" json:"-"`
      Details    []*PlcAddress      `gorm:"-" json:"details"`
   }
@@ -107,11 +110,8 @@
   }
   ResponseProcessParams struct {
      Number    string                 `json:"number"`    //工艺模型编号
      OrderId   string                 `json:"orderId"`   //订单id
      Product   string                 `json:"product"`   //产品名称
      Procedure string                 `json:"procedure"` //工序
      WorkOrder string                 `json:"workOrder"` //工单
      Device    string                 `json:"device"`    //设备
      Params    string                 `json:"params"`
      ParamsMap map[string]interface{} `json:"paramsMap"`
      DeviceId  string                 `json:"deviceId" gorm:"-"` //用于过滤获取nsq消息
@@ -127,13 +127,41 @@
   IsFinish     bool   //是否完成
}
type Device struct {
// DeviceMsg 下发到终端的设备信息
type DeviceMsg 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"`
   PlcAddressList      []*PlcAddress
   PlcConfig           *PlcConfig
}
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"
   PullDataTypeDevice       = "device"
)
// MsgPullDataRequest 拉取云端数据
type MsgPullDataRequest struct {
   DataType PullDataType `json:"dataType"` //要拉取的数据类型
}
type MsgPullDataResponse struct {
   DataType PullDataType `json:"dataType"` //要拉取的数据类型
   Data     interface{}  //返回的数据
}
type RTUConfig struct {
   BaudRate   int             `json:"baudRate"`                     //串口波特率, method = serial时 用
   SerialName string          `json:"serialName"`                   //串口名称,method = serial时 用
   DataBit    int             `gorm:"type:int(11)"  json:"dataBit"` //数据位,method = modbusRTU 用
   StopBit    int             `gorm:"type:int(11)"  json:"stopBit"` //停止位,method = modbusRTU 用
   Parity     constvar.Parity `gorm:"type:int(11)"  json:"parity"`  //校验方式,method = modbusRTU 用
}