use of com.cas.circuit.util.MesureResult in project TeachingInSimulation by ScOrPiOzzy.
the class Inverter method onReceivedLocal.
@Override
protected void onReceivedLocal(Terminal terminal) {
super.onReceivedLocal(terminal);
if (_r == terminal || _s == terminal || _t == terminal) {
// 分别测量uvw三者之间的电压情况
MesureResult resultUV = R.matchRequiredVolt(Voltage.IS_AC, _r, _s, 380, 10);
MesureResult resultVW = R.matchRequiredVolt(Voltage.IS_AC, _s, _t, 380, 10);
MesureResult resultWU = R.matchRequiredVolt(Voltage.IS_AC, _t, _r, 380, 10);
// 判断三者之间是否存在电势差
boolean tmp = Util.notEmpty(resultUV) && Util.notEmpty(resultWU) && Util.notEmpty(resultVW);
List<R> controlVoltPower = R.get3Phase(controlVoltEnv);
if (tmp && !workable) {
workable = true;
// if (controlVoltPower == null) {
// controlVoltPower = R.create3Phase(controlVoltEnv, _u, _v, _w, new Terminal(), 380);
// }
// R.set3PhaseFrequency(controlVoltEnv, frequency);
// R.reversePhase(controlVoltEnv, dir == Dir.CW);
//
// for (R r : controlVoltPower) {
// r.shareVoltage();
// }
} else if (!tmp && workable) {
if (controlVoltPower != null) {
for (R r : controlVoltPower) {
r.shutPowerDown();
}
}
workable = false;
}
} else if (!workable) {
return;
} else if (_rda == terminal || _rdb == terminal) {
// 处理PLC侧发来的数据
MesureResult result = R.matchRequiredVolt(Voltage.IS_DC, _rda, _rdb, 5, 1);
if (result != null) {
Map<String, String> data = R.getR(result.getEvn()).getVoltage().getData();
assist.decode(data);
}
if (voltNeedChange) {
List<R> controlVoltPower = R.get3Phase(controlVoltEnv);
if (controlVoltPower != null) {
// 断电
for (R r : controlVoltPower) {
r.shutPowerDown();
}
}
if (dir != null) {
controlVoltPower = R.create3Phase(controlVoltEnv, _u, _v, _w, new Terminal(), 380);
// 通电
// System.err.println("Inverter.onReceivedLocal()" + frequency);
R.set3PhaseFrequency(controlVoltEnv, frequency);
R.reversePhase(controlVoltEnv, dir == Dir.CW);
for (R r : controlVoltPower) {
r.shareVoltage();
}
}
}
} else {
}
}
use of com.cas.circuit.util.MesureResult in project TeachingInSimulation by ScOrPiOzzy.
the class MMT_4QLogic method onReceivedLocal.
@Override
protected void onReceivedLocal(Terminal terminal) {
MesureResult dcinResult = R.matchRequiredVolt(Voltage.IS_DC, dcin1, dcin2, 24, 2);
R r1 = R.getR("MMT_4Q_OUT2-OUT1" + this.hashCode());
R r2 = R.getR("MMT_4Q_OUT1-OUT2" + this.hashCode());
if (dcinResult == null) {
if (r1 != null) {
r1.shutPowerDown();
}
if (r2 != null) {
r2.shutPowerDown();
}
return;
}
MesureResult output = R.mesureVoltage(en, com1);
// en--com1之间为24V则不输出,0V则输出
if (output == null || Math.abs(output.getVolt() - 24) <= 2) {
if (r1 != null) {
r1.shutPowerDown();
}
if (r2 != null) {
r2.shutPowerDown();
}
return;
}
MesureResult direction = R.mesureVoltage(dir, com2);
// dir--com2之间为24V则正转,0V则反转
if (direction == null) {
if (r1 != null) {
r1.shutPowerDown();
}
if (r2 != null) {
r2.shutPowerDown();
}
} else if (Math.abs(direction.getVolt() - 24) <= 2) {
if (r1 == null) {
r1 = R.create("MMT_4Q_OUT2-OUT1" + this.hashCode(), Voltage.IS_DC, out2, out1, 24);
r1.shareVoltage();
}
if (r2 != null) {
r2.shutPowerDown();
}
} else if (Math.abs(direction.getVolt()) <= 2) {
if (r2 == null) {
r2 = R.create("MMT_4Q_OUT1-OUT2" + this.hashCode(), Voltage.IS_DC, out1, out2, 24);
r2.shareVoltage();
}
if (r1 != null) {
r1.shutPowerDown();
}
}
}
use of com.cas.circuit.util.MesureResult in project TeachingInSimulation by ScOrPiOzzy.
the class ServoDrive method speedControl.
private void speedControl() {
MesureResult result = R.matchRequiredVolt(Voltage.IS_DC, _OPC1, _PULS2, 24, 2);
boolean tmp = result != null;
if (tmp && !receivedPulse) {
LOG.info("伺服放大器收到脉冲信号");
receivedPulse = true;
Float f = MathUtil.parseFloat(result.getData("pulseFrequency"), 0f) / rate;
if (f != frequency) {
frequency = f;
}
} else if (!tmp && receivedPulse) {
LOG.warn("伺服放大器脉冲信号停止");
receivedPulse = false;
if (frequency != 0) {
frequency = 0;
}
}
rotateChange();
}
use of com.cas.circuit.util.MesureResult in project TeachingInSimulation by ScOrPiOzzy.
the class ServoDrive method output.
private void output() {
MesureResult resultuv = R.matchRequiredVolt(Voltage.IS_AC, _L1, _L2, 380, 10);
MesureResult resultvw = R.matchRequiredVolt(Voltage.IS_AC, _L2, _L3, 380, 10);
MesureResult resultwu = R.matchRequiredVolt(Voltage.IS_AC, _L3, _L1, 380, 10);
boolean matchRequiredVolt = Util.notEmpty(resultuv) && Util.notEmpty(resultwu) && Util.notEmpty(resultvw);
if (matchRequiredVolt && !outputEnable) {
LOG.info("伺服放大器能够输出电压");
outputEnable = true;
rotateChange();
} else if (!matchRequiredVolt && outputEnable) {
LOG.info("伺服放大器无法输出电压");
outputEnable = false;
rotateChange();
}
}
use of com.cas.circuit.util.MesureResult in project TeachingInSimulation by ScOrPiOzzy.
the class ElecCompDef method doMagnetism.
// 电生磁->磁生电或力3版
public final void doMagnetism() {
if (magnetismList.size() == 0) {
return;
}
// System.out.println(ref.getTagName());
// if ("VC1".equals(ref.getTagName())) {
// System.out.println(this + "@" + hashCode() + ref.getTagName() + " createdEnv=" + createdEnv);
// }
// ref.getCompState().getEquipmentState().getEquipment().getNumber() + ref.getTagName() + ref.hashCode();
String env_prefix = "";
for (Magnetism magnetism : magnetismList) {
float bili = 0;
VoltageIO effectVoltageIO = null;
for (VoltageIO voltageIO : magnetism.getInputVoltageIOs()) {
// String termIds = voltageIO.getTerm1Id() + "-" + voltageIO.getTerm2Id();
// 需求电压值和类型
float requireVolt = voltageIO.getRequireVolt();
int requireType = voltageIO.getVoltage().getType();
MesureResult realVolt = R.matchRequiredVolt(requireType, voltageIO.getTerm1(), voltageIO.getTerm2(), requireVolt, voltageIO.getDeviation(), ElecCompCPU.Power_Evn_Filter);
// 电生磁成功-- 不是自己创建的点才符合接入条件
if (realVolt != null && (createdEnv == null || !createdEnv.contains(realVolt.getEvn()))) {
bili = realVolt.getVolt() / requireVolt;
effectVoltageIO = voltageIO;
if (!magnetism.isEffect() && voltageIO.getResisStateIds().size() == 2) {
voltageIO.doSwitch(1);
}
break;
}
}
R r = null;
if (bili > 0 && !magnetism.isEffect()) {
// 磁生电 -- 找出output的VoltageIO
List<VoltageIO> outputVoltIOs = new ArrayList<VoltageIO>();
outputVoltIOs.addAll(magnetism.getOutputVoltageIOs());
outputVoltIOs.remove(effectVoltageIO);
for (VoltageIO outputVoltIO : outputVoltIOs) {
MesureResult checkVolt = R.matchRequiredVolt(outputVoltIO.getVoltage().getType(), outputVoltIO.getTerm1(), outputVoltIO.getTerm2(), outputVoltIO.getRequireVolt() * bili, outputVoltIO.getDeviation(), ElecCompCPU.Power_Evn_Filter);
if (checkVolt == null) {
String env = env_prefix + outputVoltIO.getTerm1Id() + "-" + outputVoltIO.getTerm2Id();
// System.out.println("ElecCompDef.doMagnetism()");
addCreatedEnv(env);
r = R.create(env, outputVoltIO.getVoltage().getType(), outputVoltIO.getTerm1(), outputVoltIO.getTerm2(), outputVoltIO.getRequireVolt() * bili);
r.shareVoltage();
// }else{
// if("VC1".equals(ref.getTagName())){
// System.err.println(outputVoltIO.getVoltType() +":"+outputVoltIO.getTerm1().getResidualVolt() +","+ outputVoltIO.getTerm2().getResidualVolt() +" volt=" + outputVoltIO.getRequireVolt() * bili +"Deviation="+ outputVoltIO.getDeviation());
// }
}
}
// 磁生力
for (final ControlIO outputControlIO : magnetism.getOutputControlIOs()) {
if (ControlIO.INTERACT_PRESS.equals(outputControlIO.getInteract())) {
if (!magnetism.isEffect() && outputControlIO.getSwitchIndex() == 0) {
outputControlIO.switchStateChanged(null);
// FIXME outputControlIO.playMotion(Dispatcher.getIns().getMainApp().getAssetManager(), null);
}
}
}
// 指示灯
for (LightIO lightIO : magnetism.getLightIOList()) {
lightIO.openLight();
}
magnetism.setEffect(true);
} else if (bili == 0 && magnetism.isEffect()) {
// System.err.println(ref.getTagName() + "上不满足输入条件");
for (final ControlIO outputControlIO : magnetism.getOutputControlIOs()) {
if (ControlIO.INTERACT_PRESS.equals(outputControlIO.getInteract())) {
if (magnetism.isEffect() && outputControlIO.getSwitchIndex() == 1) {
// outputControlIO.doSwitch(0);
outputControlIO.switchStateChanged(null);
// FIXME outputControlIO.playMotion(Dispatcher.getIns().getMainApp().getAssetManager(), null);
}
}
}
if (magnetism.isEffect()) {
for (VoltageIO inputVoltIO : magnetism.getInputVoltageIOs()) {
if (inputVoltIO.getResisStateIds().size() == 2) {
inputVoltIO.doSwitch(0);
}
}
}
for (VoltageIO outputVoltIO : magnetism.getOutputVoltageIOs()) {
String powerEnv = env_prefix + outputVoltIO.getTerm1Id() + "-" + outputVoltIO.getTerm2Id();
// System.out.println(this + "@" + hashCode() + createdEnv);
if (createdEnv != null && createdEnv.contains(powerEnv)) {
// if ("VC1".equals(ref.getTagName())) {
// System.out.println("清除电源 " + powerEnv + "上输出的电压" + powerEnv + System.nanoTime());
// }
r = R.getR(powerEnv);
if (r != null) {
r.shutPowerDown();
removeCreatedEvn(powerEnv);
}
}
}
for (LightIO lightIO : magnetism.getLightIOList()) {
lightIO.closeLight();
}
magnetism.setEffect(false);
}
}
}
Aggregations