Shortbus dll RTUに基づくプロジェクトに取り組んでいます。デバイスを読み取ることはできましたが、デバイスの数が増えると、読み取りごとの遅延が大きくなりすぎます。
デバイスごとに個別のタイマーを使用していますが、値をデータベースに書き込み、古い値と新しい値を比較して「動作中」と「動作していない」状態を表示する必要があるため、どこにも行きません。
227 台のデバイスをスキャンしたいのですが、32 台のデバイスだけでは必要な応答が得られません。
ポートと Modbus ID を保存するために datagridview を使用しています
http://postimage.org/' target='_blank'>http://s2.postimg.org/x1gdrkug9/modbus.gif' border='0' alt="modbus" />
http://postimage.org /index.php?lang=spanish'>画像を共有
各行を読み取るためのコード
private void lectura(int numerofila)
{
try
{
Variables.fila_actual = numerofila + 1;
ushort err;
Variables.sb1.SetCOMPort(Convert.ToUInt16(gridConf.Rows[con].Cells[4].Value), 9600, 8, 'N', 2);
Variables.sb1.SetCOMPort(Convert.ToUInt16(gridConf.Rows[numerofila].Cells[4].Value), 9600, 8, 'N', 2);
err = Variables.sb1.ReadWords(Convert.ToUInt16(gridConf.Rows[numerofila].Cells[3].Value), 1004, 1, out Variables.read, type3x: true);
gridConf.Rows[numerofila].Cells[7].Value = Variables.read[0];
}
catch
{
MessageBox.Show("Error in row " + Variables.numero_filas);
}
}
スキャン値のグリッド ビュー
http://postimage.org/' target='_blank'>http://s11.postimg.org/7544cqyoj/modbus2.gif' border='0' alt="modbus2" />
http://postimage.org /index.php?lang=spanish'>subir 写真
そして、2秒ごとに、行数に基づいて読み取りを実行します
private void timer1_Tick(object sender, EventArgs e)
{
lectura(0);
}
スレッドを試しましたが、アプリが詰まりました。どんな助けでも大歓迎です。