package main import "time" // OperatorFlag 操作位 type OperatorFlag uint16 const ( UltrasonicPower OperatorFlag = 0b1000000000000000 // UltrasonicPower bit15 超声波电源开关 1开,0关 // CYZ-A-X CirculatingIrrigation OperatorFlag = 0b0100000000000000 // CirculatingIrrigation bit14 循环灌洗水泵 1开,0关 UFRecoil OperatorFlag = 0b0010000000000000 // bit13 UF 超滤膜反冲进水阀 1开,0关 UFPositive OperatorFlag = 0b0001000000000000 // bit12 UF 超滤膜正冲进水阀 1开,0关 // YM-01-X-03 UFTreatedWater OperatorFlag = 0b0000100000000000 // bit11 UF 超滤膜净水出水阀 1开,0关 UFRawWater OperatorFlag = 0b0000010000000000 // bit10 UF超滤膜原水进水阀 1开,0关 // CirculatingTankWashWater YM-01-X-01 CirculatingTankWashWater OperatorFlag = 0b0000001000000000 // bit9 循环罐洗进水电动球阀 1开,0关 UFPositiveFlushingWaterOutlet OperatorFlag = 0b0000000100000000 // bit8 UF超滤膜正冲浓水出口电磁阀 1开,0关 // CleaningTankExhaust YV-02-02-1-X-06 CleaningTankExhaust OperatorFlag = 0b0000000010000000 // bit7 清洗罐排气电磁阀 1开,0关 DPFCompactCylinderControlB OperatorFlag = 0b0000000001000000 // bit6 DPF压紧气缸控制电磁阀B 1开,0关 DPFCompactCylinderControlA OperatorFlag = 0b0000000000100000 // bit5 DPF压紧气缸控制电磁阀A 1开,0关 // YV-02-05-1-X-04 CleaningTankDrainingWater OperatorFlag = 0b0000000000010000 // bit4 清洗罐放水阀控制电磁阀 1开,0关 GasExplosion OperatorFlag = 0b0000000000001000 // bit3 气爆阀控制电磁阀 1开,0关 // YV-02-02-1-X-02 CleaningTankInflation OperatorFlag = 0b0000000000000100 // bit2 清洗罐充气电磁阀 1开,0关 CleaningTankSealB OperatorFlag = 0b0000000000000010 // bit1 清洗罐密封圈充气电磁阀B 1开,0关 CleaningTankSealA OperatorFlag = 0b0000000000000001 // bit0 清洗罐密封圈充气电磁阀A 1开,0关 ) // ChaoShengBoQingXi func ChaoShengBoQingXi(worker *Worker) { // TODO: 预设值未知 for sensor := worker.Sensor(); (20.0/1024.0)*float64(sensor.SP02) < 10.0; sensor = worker.Sensor() { } flag := CleaningTankExhaust | CleaningTankDrainingWater | CirculatingTankWashWater | UFTreatedWater | CirculatingIrrigation worker.Write(OperatorOption(flag)) time.Sleep(time.Second * 10) // 10秒后 flag ^= CleaningTankDrainingWater worker.Write(OperatorOption(flag)) // 满水位传感器LT-01 >= 4.5电压 for sensor := worker.Sensor(); ((5.0 / 1024.0) * float64(sensor.LT01)) < 4.5; sensor = worker.Sensor() { } flag ^= CleaningTankExhaust flag ^= CirculatingIrrigation flag |= UltrasonicPower worker.Write(OperatorOption(flag)) //TODO: 设置时间 time.Sleep(time.Second * 1) flag ^= UltrasonicPower worker.Write(OperatorOption(flag)) // 灌洗开始 flag |= CleaningTankDrainingWater flag |= CirculatingIrrigation worker.Write(OperatorOption(flag)) for { // TODO: 定时时间 15000230 if time.Now().Unix() >= 15000230 { break } time.Sleep(time.Millisecond * 100) } flag ^= CirculatingIrrigation worker.Write(OperatorOption(flag)) QingXiGuanFangShui(worker) } // QingXiGuanFangShui 清洗灌放水 func QingXiGuanFangShui(worker *Worker) { // 满水位传感器LT-01 >= 4.5电压 flag := CleaningTankDrainingWater | CirculatingTankWashWater | UFTreatedWater | CleaningTankInflation for sensor := worker.Sensor(); ((5.0 / 1024.0) * float64(sensor.LT02)) >= 0.5; sensor = worker.Sensor() { worker.Write(OperatorOption(flag)) time.Sleep(time.Second) } flag = 0 worker.Write(OperatorOption(flag)) flag = CleaningTankExhaust for sensor := worker.Sensor(); ((5.0 / 1024.0) * float64(sensor.SP01)) > 0.5; sensor = worker.Sensor() { worker.Write(OperatorOption(flag)) time.Sleep(time.Second) } flag = 0 worker.Write(OperatorOption(flag)) }