rts-sim-testing-service/ats/verify/simulation/wayside/face/device_model.go

68 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package face
import (
"fmt"
"strings"
)
// 设备模型基类
type DeviceModel struct {
//图形id,即由前端作图时生成,且全局唯一
GraphicId string
//索引编号,同类设备唯一,不同类设备不唯一
Index string
}
// 判断是否同一个设备
func (dm *DeviceModel) IsSame(other *DeviceModel) bool {
return strings.EqualFold(dm.GraphicId, other.GraphicId)
}
// 模型图形id
func (dm *DeviceModel) GetGraphicId() string {
return dm.GraphicId
}
// 模型索引
func (dm *DeviceModel) GetIndex() string {
return dm.Index
}
//////////////////////////////////////////////////////////////
// 设备端口枚举定义
type PortEnum int8
func (pe PortEnum) Name() string {
switch pe {
case A:
return "A"
case B:
return "B"
case C:
return "C"
default:
panic(fmt.Sprintf("未知的PortEnum%d", pe))
}
}
// 设备端口枚举值
const (
A PortEnum = iota
B
C
)
func GetPortEnum(i int8) PortEnum {
switch i {
case int8(A):
return A
case int8(B):
return B
case int8(C):
return C
default:
panic(fmt.Sprintf("未知的PortEnum%d", i))
}
}