use of com.cas.circuit.util.MesureResult in project TeachingInSimulation by ScOrPiOzzy.
the class FX3UPLCLogic method onReceivedLocal.
@Override
protected void onReceivedLocal(Terminal terminal) {
// plc工作电压
if (term_L == terminal || term_N == terminal || term_GND == terminal) {
MesureResult volt = R.matchRequiredVolt(Voltage.IS_AC, term_L, term_N, 220, 2);
boolean tmp = volt != null;
R r = R.getR(SIGNAL_EVN);
if (!workable && tmp) {
// 开始工作
workable = true;
// 输出24V电压
if (r == null) {
r = R.create(SIGNAL_EVN, Voltage.IS_DC, term_24V, term_0V, 24);
}
r.shareVoltage();
if (client != null) {
Pool.getOPCPool().submit(new Runnable() {
@Override
public void run() {
try {
client.connect();
} catch (ConnectivityException e) {
log.error("连接OPC server 失败!!" + e.getMessage(), e);
}
}
});
}
} else if (workable && !tmp) {
// 停止工作
workable = false;
if (r != null) {
r.shutPowerDown();
}
if (client != null) {
Pool.getOPCPool().submit(new Runnable() {
@Override
public void run() {
client.disconnect();
log.info("OPC 客户端断开连接");
}
});
}
}
if (client != null) {
client.setWorkable(workable);
}
return;
} else if (terminal == rda || terminal == rdb) {
}
if (!workable || client == null) {
return;
}
// 能有信号的连接头 以X开头
String prex = String.valueOf(terminal.getPO().getId().charAt(0)).toUpperCase();
if ("X".equals(prex)) {
MesureResult volt = R.matchRequiredVolt(Voltage.IS_DC, terminal, term_SS, 24, 2);
if (volt == null) {
volt = R.matchRequiredVolt(Voltage.IS_DC, term_SS, terminal, 24, 2);
}
// 满足电压的输入,将对应的X信号写入PLC
// FIXME 格式化信号格式
String signal = Signal.formatSignal(terminal.getName(), 3);
inputSignalMap.put(signal, volt != null);
assist.dealWithHSXSignal(signal, volt);
client.updateItemValue(deviceName + ".X." + signal, new Variant(volt != null));
}
}
use of com.cas.circuit.util.MesureResult in project TeachingInSimulation by ScOrPiOzzy.
the class FiberSensorLogic method onReceivedLocal.
@Override
protected void onReceivedLocal(Terminal terminal) {
super.onReceivedLocal(terminal);
MesureResult result = R.matchRequiredVolt(Voltage.IS_DC, terminal1, terminal2, 24, 2f);
boolean tmp = result != null;
if (!enabled && tmp) {
enabled = true;
} else if (enabled && !tmp) {
enabled = false;
}
}
use of com.cas.circuit.util.MesureResult in project TeachingInSimulation by ScOrPiOzzy.
the class ValveLogic method onButtonAction.
@Override
public void onButtonAction(ControlIO button, boolean press) {
// 判断Jack是否满足电压
String jackName = button.getProperties().get("jackName");
Jack jack = def.getJackMap().get(jackName);
MesureResult result = R.matchRequiredVolt(Voltage.IS_DC, jack.getStitch().get("1"), jack.getStitch().get("2"), 24, 2);
// 如果电磁阀上没有满足条件的电压,则允许切换
if (result != null) {
return;
}
String switchFrom = button.getProperties().get("switchFrom");
String switchTo = button.getProperties().get("switchTo");
if (press) {
changeBlockState(switchFrom, switchTo);
} else {
changeBlockState(switchTo, switchFrom);
}
}
use of com.cas.circuit.util.MesureResult in project TeachingInSimulation by ScOrPiOzzy.
the class ValveLogicEx method singleValve.
private void singleValve(ControlIO button, boolean press) {
// 判断Jack是否满足电压
String jackName = button.getProperties().get("jackName");
Jack jack = def.getJackMap().get(jackName);
MesureResult result = R.matchRequiredVolt(Voltage.IS_DC, jack.getStitch().get("1"), jack.getStitch().get("2"), 24, 2);
// 如果电磁阀上没有满足条件的电压,则允许切换
if (result != null) {
return;
}
String switchFrom = button.getProperties().get("switchFrom");
String switchTo = button.getProperties().get("switchTo");
if (press) {
changeBlockState(switchFrom, switchTo);
} else {
changeBlockState(switchTo, switchFrom);
}
}
use of com.cas.circuit.util.MesureResult in project TeachingInSimulation by ScOrPiOzzy.
the class Encoder method onReceivedLocal.
@Override
protected void onReceivedLocal(Terminal terminal) {
super.onReceivedLocal(terminal);
if (_24v == terminal || _0v == terminal) {
// 编码器工作条件
MesureResult result = R.matchRequiredVolt(Voltage.IS_DC, _24v, _0v, 24, 1);
boolean tmp = result != null;
if (tmp && !workable) {
workable = true;
} else if (!tmp && workable) {
workable = false;
//
}
encoderControl.setEnabled(workable);
}
}
Aggregations