Skip to content

Commit

Permalink
modbusRTU with new wirelessSystem (notTested)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dolu1990 committed Jul 9, 2014
1 parent 18c1d8e commit 3e59119
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
18 changes: 17 additions & 1 deletion mods/eln/sixnode/modbusrtu/ModbusRtuElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;

import mods.eln.Eln;
import mods.eln.misc.Direction;
import mods.eln.misc.LRDU;
import mods.eln.misc.Utils;
import mods.eln.node.NodeBase;
import mods.eln.node.six.SixNode;
import mods.eln.node.six.SixNodeDescriptor;
Expand All @@ -19,6 +21,9 @@
import mods.eln.sim.ThermalLoad;
import mods.eln.sim.nbt.NbtElectricalGateInputOutput;
import mods.eln.sim.nbt.NbtElectricalGateOutputProcess;
import mods.eln.sixnode.wirelesssignal.IWirelessSignalSpot;
import mods.eln.sixnode.wirelesssignal.WirelessUtils;
import mods.eln.sixnode.wirelesssignal.tx.IWirelessSignalTx;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
Expand Down Expand Up @@ -68,12 +73,23 @@ public ModbusRtuElement(SixNode sixNode,Direction side,SixNodeDescriptor descrip



HashMap<String, HashSet<IWirelessSignalTx>> txSet = new HashMap<String, HashSet<IWirelessSignalTx>>();
HashMap<IWirelessSignalTx, Double> txStrength = new HashMap<IWirelessSignalTx, Double>();


class ModbusRtuSlowProcess implements IProcess{

double sleepTimer = 0;

@Override
public void process(double time) {
sleepTimer -= time;
if(sleepTimer < 0){
sleepTimer += Utils.rand(1.2, 2);

IWirelessSignalSpot spot = WirelessUtils.buildSpot(getCoordonate(), null, 0);
WirelessUtils.getTx(spot, txSet, txStrength);
}

for (ServerWirelessRxStatus rx : wirelessRxStatusList.values()) {
if(rx.isConnected() != rx.connected){
rx.connected = ! rx.connected;
Expand Down
12 changes: 5 additions & 7 deletions mods/eln/sixnode/modbusrtu/ServerWirelessRxStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.google.common.base.CaseFormat;

import mods.eln.misc.Utils;
import mods.eln.sixnode.wirelesssignal.aggregator.BiggerAggregator;
import mods.eln.sixnode.wirelesssignal.tx.IWirelessSignalTx;
import mods.eln.sixnode.wirelesssignal.tx.WirelessSignalTxElement;

Expand All @@ -28,16 +29,13 @@ void delete(){
}

boolean isConnected(){
return false;
//0xEE return null != WirelessSignalTxElement.getBestTx(name, rtu.sixNode.coordonate);
return null != rtu.txSet.get(name);
}

BiggerAggregator aggregator = new BiggerAggregator();
double readWireless(){
/*IWirelessSignalTx tx = WirelessSignalTxElement.getBestTx(name, rtu.sixNode.coordonate);
if(tx == null) return 0;
return tx.getValue();*/
//0xEE
return 0;
if(isConnected() == false) return 0;
return aggregator.aggregate(rtu.txSet.get(name));
}


Expand Down

0 comments on commit 3e59119

Please sign in to comment.