rts-sim-module/system/switch_2jzdj9_system.go

586 lines
17 KiB
Go
Raw Normal View History

2023-09-05 14:47:38 +08:00
package system
2023-09-05 18:16:36 +08:00
import (
"fmt"
2023-09-05 18:16:36 +08:00
"github.com/yohamta/donburi/filter"
"joylink.club/ecs"
sysEvent "joylink.club/rtsssimulation/system/event"
"joylink.club/rtsssimulation/umi"
2023-09-05 18:16:36 +08:00
)
2023-09-11 13:33:01 +08:00
// 双机ZDJ9道岔电路系统状态定义
2023-09-05 18:16:36 +08:00
// 继电器: true-吸合false-未吸合
2023-09-11 13:33:01 +08:00
type Switch2jZdj9State struct {
2023-09-05 18:16:36 +08:00
//定操继电器
DCJ bool
//反操继电器
FCJ bool
//允许操作继电器
YCJ bool
//总定表继电器
ZDBJ bool
//总反表继电器
ZFBJ bool
//道岔第一启动继电器
J1_1DQJ bool
//道岔保护继电器
J1_BHJ bool
//道岔第二启动继电器
2023-09-06 18:07:12 +08:00
//true-吸起即1-3通false-打落即1-2通
2023-09-05 18:16:36 +08:00
J1_2DQJ bool
//道岔第一启动继电器复示继电器
J1_1DQJF bool
//断相保护器
J1_DBQ DBQState
//定位表示继电器
J1_DBJ bool
//true-当道岔转换到定位时转辙机内端子9与电路接通false-转辙机内端子9断开切断电路
J1_DB_K9 bool
//转辙机内部自动开闭器
//true-接通1、3排表示电路,用于定操;false-接通2、4排表示电路用于反操
J1_AKB bool
//道岔电机1的电源
J1_Power Switch380ACPower
//电机线圈相电流
J1_U1 Switch380ACPhase
J1_V1 Switch380ACPhase
J1_W1 Switch380ACPhase
//电机转速大于0表示正转即定操小于0表示反转即反操等于0表示不转
J1_Speed int8
2023-09-05 18:16:36 +08:00
//反位表示继电器
J1_FBJ bool
//true-当道岔转换到反位时转辙机内端子10与电路接通false-转辙机内端子10断开切断电路
J1_FB_K10 bool
2023-09-05 18:16:36 +08:00
//道岔启动切断继电器
J1_QDJ bool
//道岔启动切断继电器的LC震荡电路保磁剩余时间,单位ms
//最长保持时长3000ms
J1_QDJ_LcTime int64
//总保护继电器
J1_ZBHJ bool
//道岔第一启动继电器
J2_1DQJ bool
//道岔保护继电器
J2_BHJ bool
//道岔第二启动继电器
2023-09-06 18:07:12 +08:00
//true-吸起即1-3通false-打落即1-2通
2023-09-05 18:16:36 +08:00
J2_2DQJ bool
//道岔第一启动继电器复示继电器
J2_1DQJF bool
//断相保护器
J2_DBQ DBQState
//定位表示继电器
J2_DBJ bool
//true-当道岔转换到定位时转辙机内端子9与电路接通false-转辙机内端子9断开切断电路
J2_DB_K9 bool
2023-09-05 18:16:36 +08:00
//反位表示继电器
J2_FBJ bool
//true-当道岔转换到反位时转辙机内端子10与电路接通false-转辙机内端子10断开切断电路
J2_FB_K10 bool
//转辙机内部自动开闭器
//true-接通1、3排表示电路,用于定操;false-接通2、4排表示电路用于反操
J2_AKB bool
//道岔电机2的电源
J2_Power Switch380ACPower
//电机线圈相电流
J2_U1 Switch380ACPhase
J2_V1 Switch380ACPhase
J2_W1 Switch380ACPhase
//电机转速大于0表示正转即定操小于0表示反转即反操等于0表示不转
J2_Speed int8
2023-09-05 18:16:36 +08:00
}
2023-09-08 11:24:06 +08:00
// 创建ZDJ9道岔状态并初始化
2023-09-11 13:33:01 +08:00
func NewSwitch2jZdj9State() *Switch2jZdj9State {
return &Switch2jZdj9State{
2023-09-13 13:33:47 +08:00
DCJ: false,
FCJ: false,
YCJ: false,
ZDBJ: true,
ZFBJ: false,
J1_1DQJ: false,
J1_BHJ: false,
J1_2DQJ: true,
J1_1DQJF: false,
J1_DBQ: DBQState{PhaseLoss: true, LimitedTime: 0, Dc24Voltage: false},
J1_DBJ: true,
J1_DB_K9: true,
J1_AKB: true,
J1_Power: Switch380ACPower{PhaseA: false, PhaseB: false, PhaseC: false},
J1_U1: ACPahseN,
J1_V1: ACPahseN,
J1_W1: ACPahseN,
J1_Speed: 0,
J1_FBJ: false,
J1_FB_K10: false,
J1_QDJ: true,
J1_QDJ_LcTime: 0,
J1_ZBHJ: false,
J2_1DQJ: false,
J2_BHJ: false,
J2_2DQJ: true,
J2_1DQJF: false,
J2_DBQ: DBQState{PhaseLoss: true, LimitedTime: 0, Dc24Voltage: false},
J2_DBJ: true,
J2_DB_K9: true,
J2_FBJ: false,
J2_FB_K10: false,
J2_AKB: true,
J2_Power: Switch380ACPower{PhaseA: false, PhaseB: false, PhaseC: false},
J2_U1: ACPahseN,
J2_V1: ACPahseN,
J2_W1: ACPahseN,
J2_Speed: 0,
2023-09-08 11:24:06 +08:00
}
}
2023-09-05 18:16:36 +08:00
// 带限时功能断相保护器
// 限时13秒
type DBQState struct {
//是否缺相true-缺相false-三相电正常未缺相
PhaseLoss bool
//剩余限时时间,单位ms
LimitedTime int64
//当三相电正常时断相保护器内的24V直流整流电路会正常输出24V直流电
//当三相电不正常如缺相时断相保护器内的24V直流整流电路不会输出24V直流电
//BHJ道岔保护继电器的励磁线圈由该24V直流供电
Dc24Voltage bool
}
// 表示电路变压器变压比2:1将220V交流电变压后作为为道岔表示电路的电源
// 0-无电源规定52端子为正1-输出瞬时正电压;-1 - 输出瞬时负电压
type SwitchBB struct {
//true-变压器初级输入正常
InDj220V bool
//次级输出电压
//0-无电源规定52端子为正1-输出瞬时正电压;-1 - 输出瞬时负电压
OutBb int8
}
// 道岔380V动力交流电源
type Switch380ACPower struct {
//true-A相电正常输出
PhaseA bool
//true-B相电正常输出
PhaseB bool
//true-C相电正常输出
PhaseC bool
}
// 道岔380V动力交流电相位定义
type Switch380ACPhase int8
const (
//不存在相位交流电
ACPahseN Switch380ACPhase = iota
//存在A相位交流电
ACPahseA
//存在B相位交流电
ACPahseB
//存在C相位交流电
ACPahseC
)
// 继电器常量定义
2023-09-06 18:07:12 +08:00
const (
//QDJ 电源切断继电器LC震荡电路有效震荡时间ms
QDJ_LC_TIME int64 = 3000
//断相保护器限时单位ms
DBQ_LIMITED_TIME = 13 * 1000
)
2023-09-05 18:16:36 +08:00
// 道岔ZDJ9电路状态组件
2023-09-11 13:33:01 +08:00
var Switch2jZdj9StateComponent = ecs.NewComponentType[Switch2jZdj9State]()
2023-09-05 18:16:36 +08:00
// zdj9查询
var zdj9Query = ecs.NewQuery(filter.Contains(EntityIdentityComponent, Switch2jZdj9StateComponent))
2023-09-05 14:47:38 +08:00
// ZDJ9道岔系统
type SwitchZdj9System struct {
2023-09-05 18:16:36 +08:00
}
func NewSwitchZdj9System() *SwitchZdj9System {}
2023-09-05 18:16:36 +08:00
// world 执行
func (me *SwitchZdj9System) Update(w ecs.World) {
zdj9Query.Each(w, func(e *ecs.Entry) {
2023-09-11 13:33:01 +08:00
zdj9State := Switch2jZdj9StateComponent.Get(e)
2023-09-05 18:16:36 +08:00
//断相保护器电路
2023-09-13 13:33:47 +08:00
me.calculateDBQ(w, zdj9State)
2023-09-05 18:16:36 +08:00
//断相保护继电器励磁电路
2023-09-13 13:33:47 +08:00
me.calculateBHJ(w, zdj9State)
2023-09-05 18:16:36 +08:00
//总保护继电器励磁电路
2023-09-13 13:33:47 +08:00
me.calculateZBHJ(w, zdj9State)
2023-09-05 18:16:36 +08:00
//道岔转换启动切断继电器励磁电路
2023-09-13 13:33:47 +08:00
me.calculateQDJ(w, zdj9State)
2023-09-06 18:07:12 +08:00
//道岔第一启动继电器励磁电路
2023-09-13 13:33:47 +08:00
me.calculate1DQJ(w, zdj9State)
2023-09-06 18:07:12 +08:00
//道岔第一启动继电器复示继电器励磁电路
2023-09-13 13:33:47 +08:00
me.calculate1DQJF(w, zdj9State)
2023-09-06 18:07:12 +08:00
//道岔第二启动继电器励磁电路
2023-09-13 13:33:47 +08:00
me.calculate2DQJ(w, zdj9State)
2023-09-11 13:33:01 +08:00
//转辙机内自动开闭器
2023-09-13 13:33:47 +08:00
me.calculateAKB(w, zdj9State)
2023-09-06 18:07:12 +08:00
//道岔转辙机定表反表继电器励磁电路
2023-09-13 13:33:47 +08:00
me.calculateDBJ(w, zdj9State)
me.calculateFBJ(w, zdj9State)
2023-09-11 13:33:01 +08:00
//总定表/总反表继电器励磁电路
2023-09-13 13:33:47 +08:00
me.calculateZDBJ(w, zdj9State)
me.calculateZFBJ(w, zdj9State)
//道岔转辙机内电机驱动电路
2023-09-13 13:33:47 +08:00
me.calculateMotor(w, zdj9State)
2023-09-05 18:16:36 +08:00
})
}
// 继电器动作事件处理
var Switch2jzdj9RelayActionEventProcessor = func(w ecs.World, event sysEvent.RelayActionEvent) {
zdj9Query.Each(w, func(e *ecs.Entry) {
switchModel := FindModelStorage(w).FindById(EntityIdentityComponent.Get(e).Id)
roler, ok := switchModel.(umi.IRelayCRole)
if ok {
if relayGroup, relayName, find := roler.FindCircuitRoleById(event.Id); find {
state := Switch2jZdj9StateComponent.Get(e)
switch relayGroup {
case "TDC":
{
}
case "TDFJ1":
{
switch relayName {
case "1DQJ":
state.J1_1DQJ = event.Xh
case "BHJ":
state.J1_BHJ = event.Xh
case "2DQJ":
state.J1_2DQJ = event.Xh
case "1DQJF":
state.J1_1DQJF = event.Xh
case "DBJ":
state.J1_DBJ = event.Xh
case "FBJ":
state.J1_FBJ = event.Xh
case "QDJ":
state.J1_QDJ = event.Xh
case "ZBHJ":
state.J1_ZBHJ = event.Xh
default:
panic(fmt.Sprintf("SwitchZdj9的模型[%s]中继电器功能名称[%s]无法识别", switchModel.GetId(), relayName))
}
}
case "TDFJ2":
{
switch relayName {
case "1DQJ":
state.J2_1DQJ = event.Xh
case "BHJ":
state.J2_BHJ = event.Xh
case "2DQJ":
state.J2_2DQJ = event.Xh
case "1DQJF":
state.J2_1DQJF = event.Xh
case "DBJ":
state.J2_DBJ = event.Xh
case "FBJ":
state.J2_FBJ = event.Xh
default:
panic(fmt.Sprintf("SwitchZdj9的模型[%s]中继电器功能名称[%s]无法识别", switchModel.GetId(), relayName))
}
}
default:
panic(fmt.Sprintf("SwitchZdj9的模型[%s]中继电器组合类型[%s]无法识别", switchModel.GetId(), relayGroup))
}
}
} else {
panic("SwitchZdj9的模型未实现接口umi.IRelayCRoler")
}
})
}
2023-09-05 18:16:36 +08:00
// 断相保护电路运算
2023-09-13 13:33:47 +08:00
func (me *SwitchZdj9System) calculateDBQ(w ecs.World, state *Switch2jZdj9State) {
2023-09-05 18:16:36 +08:00
if state.J1_DBQ.LimitedTime > 0 {
state.J1_DBQ.LimitedTime -= int64(w.Tick())
2023-09-06 18:07:12 +08:00
if state.J1_DBQ.LimitedTime < 0 {
state.J1_DBQ.LimitedTime = 0
}
2023-09-05 18:16:36 +08:00
}
//
state.J1_DBQ.PhaseLoss = !state.J1_Power.PhaseA || !state.J1_Power.PhaseB || !state.J1_Power.PhaseC
//
state.J1_DBQ.Dc24Voltage = !state.J1_DBQ.PhaseLoss
///////////////////////////////////////////////////
2023-09-05 18:16:36 +08:00
if state.J2_DBQ.LimitedTime > 0 {
state.J2_DBQ.LimitedTime -= int64(w.Tick())
2023-09-06 18:07:12 +08:00
if state.J2_DBQ.LimitedTime < 0 {
state.J2_DBQ.LimitedTime = 0
}
2023-09-05 18:16:36 +08:00
}
//
state.J2_DBQ.PhaseLoss = !state.J2_Power.PhaseA || !state.J2_Power.PhaseB || !state.J2_Power.PhaseC
//
2023-09-05 18:16:36 +08:00
state.J2_DBQ.Dc24Voltage = !state.J2_DBQ.PhaseLoss
}
2023-09-11 13:33:01 +08:00
// 转辙机内自动开闭器动作实现
// 暂时规定自动开闭器跟随2DQJ
2023-09-13 13:33:47 +08:00
func (me *SwitchZdj9System) calculateAKB(w ecs.World, state *Switch2jZdj9State) {
2023-09-11 13:33:01 +08:00
state.J1_AKB = state.J1_2DQJ
state.J2_AKB = state.J2_2DQJ
}
2023-09-05 18:16:36 +08:00
// 断相保护继电器运算
2023-09-06 18:07:12 +08:00
// BHJ JWXC-1700无极缓放继电器
2023-09-13 13:33:47 +08:00
func (me *SwitchZdj9System) calculateBHJ(w ecs.World, state *Switch2jZdj9State) {
state.J1_BHJ = state.J1_DBQ.Dc24Voltage
2023-09-06 18:07:12 +08:00
//
2023-09-13 13:33:47 +08:00
state.J2_BHJ = state.J2_DBQ.Dc24Voltage
2023-09-05 18:16:36 +08:00
}
// 总保护继电器运算
2023-09-06 18:07:12 +08:00
// ZBHJ JWXC-1700无极缓放继电器
2023-09-13 13:33:47 +08:00
func (me *SwitchZdj9System) calculateZBHJ(w ecs.World, state *Switch2jZdj9State) {
2023-09-05 18:16:36 +08:00
//励磁
2023-09-06 18:07:12 +08:00
method := state.J1_BHJ && state.J2_BHJ
//自闭
self := state.J1_ZBHJ && (state.J1_BHJ || state.J2_BHJ)
//
is := method || self
2023-09-05 18:16:36 +08:00
//为总保护继电器励磁
2023-09-13 13:33:47 +08:00
state.J1_ZBHJ = is
2023-09-05 18:16:36 +08:00
}
// 道岔转换启动切断继电器运算
2023-09-06 18:07:12 +08:00
// QDJ JWXC-1700无极缓放继电器
2023-09-13 13:33:47 +08:00
func (me *SwitchZdj9System) calculateQDJ(w ecs.World, state *Switch2jZdj9State) {
2023-09-05 18:16:36 +08:00
//LC震荡电路运算
fullLc := (!state.J1_BHJ && !state.J2_BHJ) || state.J1_ZBHJ
if fullLc {
2023-09-06 18:07:12 +08:00
state.J1_QDJ_LcTime = QDJ_LC_TIME
2023-09-05 18:16:36 +08:00
} else {
2023-09-06 18:07:12 +08:00
if state.J1_QDJ_LcTime > 0 {
state.J1_QDJ_LcTime -= int64(w.Tick())
if state.J1_QDJ_LcTime < 0 {
state.J1_QDJ_LcTime = 0
}
2023-09-05 18:16:36 +08:00
}
}
//自闭励磁电路
self := state.J1_QDJ && state.J1_ZBHJ
//为启动切断继电器励磁
2023-09-13 13:33:47 +08:00
state.J1_QDJ = self || fullLc || state.J1_QDJ_LcTime > 0
2023-09-05 18:16:36 +08:00
}
// 道岔第一启动继电器运算
2023-09-06 18:07:12 +08:00
// 1DQJ JWJXC-H125/80无极加强缓放继电器
// J1先启动J2后启动
2023-09-13 13:33:47 +08:00
func (me *SwitchZdj9System) calculate1DQJ(w ecs.World, state *Switch2jZdj9State) {
2023-09-06 18:07:12 +08:00
//自闭电路
j2DqjSelf := state.J1_QDJ && state.J2_BHJ && state.J2_1DQJ
//励磁电路
j2DqjMethod1 := state.YCJ && state.J1_1DQJ && (!state.J2_2DQJ && state.DCJ || state.J2_2DQJ && state.FCJ)
2023-09-13 13:33:47 +08:00
//
2023-09-06 18:07:12 +08:00
j2DqjIs := j2DqjMethod1 || j2DqjSelf
//为J2第一启动继电器励磁
2023-09-13 13:33:47 +08:00
state.J2_1DQJ = j2DqjIs
2023-09-11 13:33:01 +08:00
// ---------------
//励磁电路
j1DqjMethod1 := state.YCJ && (!state.J1_2DQJ && state.DCJ || state.J1_2DQJ && state.FCJ)
//自闭电路
j1DqjSelf := state.J1_QDJ && state.J1_BHJ && state.J1_1DQJ
2023-09-13 13:33:47 +08:00
//
2023-09-11 13:33:01 +08:00
j1DqjIs := j1DqjMethod1 || j1DqjSelf
//为J1第一启动继电器励磁
2023-09-13 13:33:47 +08:00
state.J1_1DQJ = j1DqjIs
2023-09-06 18:07:12 +08:00
}
// 道岔第一启动继电器复示继电器运算
// 1DQJF JWJXC-480无极继电器
2023-09-13 13:33:47 +08:00
func (me *SwitchZdj9System) calculate1DQJF(w ecs.World, state *Switch2jZdj9State) {
2023-09-06 18:07:12 +08:00
state.J1_1DQJF = state.J1_1DQJ
state.J2_1DQJF = state.J2_1DQJ
}
// 道岔第二启动继电器运算
// 2DQJ JYJXC-160/260有极加强继电器
// 2DQJ为有极继电器根据线圈中电流极性不同具有 定位和反位 两种稳定状态,这两种稳定状态当线圈中电流消失时仍能继续保持;
// 在线圈中通以规定极性的电流时,继电器吸起,断电后仍保持在吸起位置;通以反方向电流时,继电器打落,断电后保持在打落位置;
// 断电保持由磁路系统中的一块长条形永久磁铁取代了大部分轭铁来实现;
// 电流3->4吸起电流2->1打落如果21和34同时通过电流时磁场相互抵消则继电器保持原来状态不变
2023-09-13 13:33:47 +08:00
func (me *SwitchZdj9System) calculate2DQJ(w ecs.World, state *Switch2jZdj9State) {
2023-09-06 18:07:12 +08:00
//J1-2DQJ
j1_2dqj_21 := state.J1_1DQJF && state.FCJ
j1_2dqj_34 := state.J1_1DQJF && state.DCJ
//磁通量,矢量
var j12dqj int8 = 0
if j1_2dqj_34 {
j12dqj++
}
if j1_2dqj_21 {
j12dqj--
}
if j12dqj != 0 {
state.J1_2DQJ = j12dqj > 0
}
//J2-2DQJ
j2_2dqj_21 := state.J2_1DQJF && state.FCJ
j2_2dqj_34 := state.J2_1DQJF && state.DCJ
//磁通量,矢量
var j22dqj int8 = 0
if j2_2dqj_34 {
j22dqj++
}
if j2_2dqj_21 {
j22dqj--
}
if j22dqj != 0 {
state.J2_2DQJ = j22dqj > 0
}
}
// 道岔总定表继电器运算
// ZDBJ JPXC-1000 偏极继电器是为了鉴别信号电路中的电流极性而设计
// 继电器在磁路中增加一个偏极磁钢,使衔铁受永磁力的作用而偏于落下位置。衔铁的吸起与线圈中的电流的极性有关,
// 通过线圈的电流为规定的方向时,衔铁才吸起,而电流的方向相反时,衔铁保持不动。
// 它只具有一种稳定状态,即衔铁靠电磁力吸起后,断电即落下,始终偏向落下的定位状态
2023-09-13 13:33:47 +08:00
func (me *SwitchZdj9System) calculateZDBJ(w ecs.World, state *Switch2jZdj9State) {
2023-09-06 18:07:12 +08:00
state.ZDBJ = state.J1_DBJ && state.J2_DBJ
}
2023-09-13 13:33:47 +08:00
func (me *SwitchZdj9System) calculateZFBJ(w ecs.World, state *Switch2jZdj9State) {
2023-09-06 18:07:12 +08:00
state.ZFBJ = state.J1_FBJ && state.J2_FBJ
}
// 道岔定表继电器运算
// DBJ JPXC-1000 偏极继电器
// BB的负半周期提供DBJ的励磁电流
2023-09-13 13:33:47 +08:00
func (me *SwitchZdj9System) calculateDBJ(w ecs.World, state *Switch2jZdj9State) {
//j1 DBJ励磁
2023-09-13 13:47:00 +08:00
j1DbjLc := state.J1_2DQJ && state.J1_AKB && state.J1_DB_K9 && !state.J1_1DQJ
2023-09-13 13:33:47 +08:00
state.J1_DBJ = j1DbjLc
//j2 DBJ励磁
2023-09-13 13:47:00 +08:00
j2DbjLc := state.J2_2DQJ && state.J2_AKB && state.J2_DB_K9 && !state.J2_1DQJ
2023-09-13 13:33:47 +08:00
state.J2_DBJ = j2DbjLc
2023-09-06 18:07:12 +08:00
}
// 道岔反表继电器运算
// FBJ JPXC-1000 偏极继电器
// BB的正半周期提供FBJ的励磁流
2023-09-13 13:33:47 +08:00
func (me *SwitchZdj9System) calculateFBJ(w ecs.World, state *Switch2jZdj9State) {
//j1 FBJ励磁
2023-09-13 13:47:00 +08:00
j1FbjLc := !state.J1_2DQJ && !state.J1_AKB && state.J1_FB_K10 && !state.J1_1DQJ
2023-09-13 13:33:47 +08:00
state.J1_FBJ = j1FbjLc
//j2
2023-09-13 13:47:00 +08:00
j2FbjLc := !state.J2_2DQJ && !state.J2_AKB && state.J2_FB_K10 && !state.J2_1DQJ
2023-09-13 13:33:47 +08:00
state.J2_FBJ = j2FbjLc
}
2023-09-05 18:16:36 +08:00
// 道岔转辙机电机内线圈电路运算
// ABC三相电电机线圈UVW,
// 定位到反位U-A V-C W-B 即U->W->V电机反转反操接通2、4排表示电路
// 反位到定位U-A V-B W-C 即U->V->W电机正转定操接通1、3排表示电路
2023-09-13 13:33:47 +08:00
func (me *SwitchZdj9System) calculateMotor(w ecs.World, state *Switch2jZdj9State) {
//电机1
state.J1_U1 = ACPahseN
state.J1_V1 = ACPahseN
state.J1_W1 = ACPahseN
state.J1_Speed = 0
//A相电
if state.J1_Power.PhaseA && state.J1_1DQJ {
state.J1_U1 = ACPahseA
}
//B相电
if state.J1_Power.PhaseB && state.J1_1DQJF {
if state.J1_2DQJ {
if state.J1_AKB {
state.J1_V1 = ACPahseB
}
} else {
if !state.J1_AKB {
state.J1_W1 = ACPahseB
}
}
}
//C相电
if state.J1_Power.PhaseC && state.J1_1DQJF {
if state.J1_2DQJ {
if state.J1_AKB {
state.J1_W1 = ACPahseC
}
} else {
if !state.J1_AKB {
state.J1_V1 = ACPahseC
}
}
}
//转速
if state.J1_U1 == ACPahseA {
switch {
case state.J1_V1 == ACPahseB: //U-A V-B W-C
{
if state.J1_W1 == ACPahseC {
state.J1_Speed = 1
}
}
case state.J1_V1 == ACPahseC: //U-A W-B V-C
{
if state.J1_W1 == ACPahseB {
state.J1_Speed = -1
}
}
}
}
/////////////
//电机2
state.J2_U1 = ACPahseN
state.J2_V1 = ACPahseN
state.J2_W1 = ACPahseN
state.J2_Speed = 0
//A相电
if state.J2_Power.PhaseA && state.J2_1DQJ {
state.J2_U1 = ACPahseA
}
//B相电
if state.J2_Power.PhaseB && state.J2_1DQJF {
if state.J2_2DQJ {
if state.J2_AKB {
state.J2_V1 = ACPahseB
}
} else {
if !state.J2_AKB {
state.J2_W1 = ACPahseB
}
}
}
//C相电
if state.J2_Power.PhaseC && state.J2_1DQJF {
if state.J2_2DQJ {
if state.J2_AKB {
state.J2_W1 = ACPahseC
}
} else {
if !state.J2_AKB {
state.J2_V1 = ACPahseC
}
}
}
//转速
if state.J2_U1 == ACPahseA {
switch {
case state.J2_V1 == ACPahseB: //U-A V-B W-C
{
if state.J2_W1 == ACPahseC {
state.J2_Speed = 1
}
}
case state.J2_V1 == ACPahseC: //U-A W-B V-C
{
if state.J2_W1 == ACPahseB {
state.J2_Speed = -1
}
}
}
}
2023-09-05 14:47:38 +08:00
}