これによると、選択した値のレジスタを持つ自分のmodbusスレーブを作成しようとしています(後ほど、これらの値をpython/jythonを使って監視対象デバイスのデータで埋めたい)それらはPredix(クラウドプラットフォーム)を使用して離れています。私はモデバスのグリーンホーンなので、選んだ値を登録者に追加する方法はまだ見つけられません。ここでModbus TCPスレーブスレッドセットと値を取得する
は、私がローカルホスト上のマスターのためのデータを提供するために使用私の奴隷スレッドです:502:
<channel protocol="TCP_IP" tcpIpAddress="127.0.0.1" tcpIpPort="502">
<unit id="1">
<register name="Node-1-1" dataType="INTEGER" address="10" registerType="HOLDING" description="temperature"/>
<register name="Node-1-2" dataType="DECIMAL" address="11" registerType="HOLDING" description="pressure"/>
</unit>
<unit id="2">
<register name="Node-2-1" dataType="INTEGER" address="20" registerType="HOLDING" description="temperature"/>
<register name="Node-2-2" dataType="INTEGER" address="21" registerType="HOLDING" description="pressure"/>
</unit>
</channel>
私は論文転送(「出力」を得る:
public class SimpleApp {
public static void main(String args[]) {
try {
//1. The important instances and variables
ModbusTCPListener listener = null;
SimpleProcessImage spi = null;
int port = 502;
//2. Prepare a process image
spi = new SimpleProcessImage();
//I dont understand this part, why do i need it?
spi.addDigitalOut(new SimpleDigitalOut(true));
spi.addDigitalOut(new SimpleDigitalOut(false));
spi.addDigitalIn(new SimpleDigitalIn(false));
spi.addDigitalIn(new SimpleDigitalIn(true));
spi.addDigitalIn(new SimpleDigitalIn(false));
spi.addDigitalIn(new SimpleDigitalIn(true));
//setting up register holders, gonna ask no 10,11,20 and 21 as set in the data node config
for (int i = 0; i < 25; i++) {
int value = 15;
SimpleInputRegister sr = new SimpleInputRegister(value);
spi.addRegister(sr);
}
//3. Set the image on the coupler
ModbusCoupler.getReference().setProcessImage(spi);
ModbusCoupler.getReference().setMaster(false);
ModbusCoupler.getReference().setUnitID(15); //15
//4. Create a listener with 3 threads in pool
listener = new ModbusTCPListener(1); //no of threads
listener.setPort(port);
listener.start();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
データが設定ノード):
[{"address":"com.ge.dspmicro.machineadapter.modbus://127.0.0.1:502/2/20","datatype":"INTEGER","name":"Node-2-1","category":"REAL","value":655370,"timestamp":1464006550991,"quality":"NOT_SUPPORTED (20000000) "},
{"address":"com.ge.dspmicro.machineadapter.modbus://127.0.0.1:502/1/10","datatype":"INTEGER","name":"Node-1-1","category":"REAL","value":655370,"timestamp":1464006550992,"quality":"NOT_SUPPORTED (20000000) "}]
主な質問:
1)ノード1-2および2-2のデータはどこにありますか(出力にはありません)。
2)レジスタから送信される値を編集するにはどうすればよいですか? (なぜ "値" ですか?:655370)を
オプションQustions:(私はdocumentationに理解していませんでし物事)
3)用のスタンドで/クラスsimpleDigitalOutを何?
4)ModbusCoupler.getReference()。setUnitID(value)は何を表しますか? (それは明らかにデータノードのunitIDと共通して何もしなくてはならない。
5)SimpleInputRegisterクラスとSimpleRegisterクラスの違いは何ですか?
この質問は、ここでしばらく解決されましたか、Java Modbus Libraryデベロッパーフォーラムで質問してみましたか? – j12y