[新增]继电器设置初始位置逻辑

This commit is contained in:
thesai 2024-06-28 11:10:09 +08:00
parent c5f139267a
commit 181dd9951b
5 changed files with 790 additions and 706 deletions

View File

@ -26,6 +26,13 @@ func NewRelayEntity(w ecs.World, relay *repository.Relay, entityMap map[string]*
entry.AddComponent(component.HfRelayTag)
}
entityMap[uid] = entry
//设置继电器初始状态
switch relay.DefaultPos() {
case proto.Relay_Pos_Q:
component.RelayDriveType.Get(entry).Td = true
case proto.Relay_Pos_H:
component.RelayDriveType.Get(entry).Td = false
}
}
return entry
}

View File

@ -419,10 +419,16 @@ message Relay {
JYJXC_160_260 = 7;
JZXC_H18 = 8;
}
enum Pos {
Pos_None = 0; //
Pos_Q = 1; //
Pos_H = 2; //
}
string id = 1;
string code = 2;
Model model = 3;
string stationId = 4; // id
Pos defaultPos = 5; //
}
//

View File

@ -11,21 +11,23 @@ type IGroupedElectronicComponent interface {
// Relay 继电器
type Relay struct {
Identity
code string
model proto.Relay_Model
code string
model proto.Relay_Model
defaultPos proto.Relay_Pos
// 所属车站
station *Station
}
func newRelay(id string, code string, model proto.Relay_Model, s *Station) *Relay {
func newRelay(id string, code string, model proto.Relay_Model, defaultPos proto.Relay_Pos, s *Station) *Relay {
return &Relay{
Identity: identity{
id: id,
deviceType: proto.DeviceType_DeviceType_Relay,
},
code: code,
model: model,
station: s,
code: code,
model: model,
defaultPos: defaultPos,
station: s,
}
}
@ -37,6 +39,10 @@ func (r *Relay) Model() proto.Relay_Model {
return r.model
}
func (r *Relay) DefaultPos() proto.Relay_Pos {
return r.defaultPos
}
// ElectronicComponentGroup 电子元件组合
type ElectronicComponentGroup struct {
code string

File diff suppressed because it is too large Load Diff

View File

@ -96,7 +96,7 @@ func buildModels(source *proto.Repository, repository *Repository) error {
if !ok {
return fmt.Errorf("id=%s的继电器所属车站不存在,车站id=%s", protoData.Id, protoData.StationId)
}
m := newRelay(protoData.Id, protoData.Code, protoData.Model, s)
m := newRelay(protoData.Id, protoData.Code, protoData.Model, protoData.DefaultPos, s)
repository.relayMap[m.Id()] = m
}
for _, protoData := range source.PhaseFailureProtectors {