private void chkAgvPrestopIO1_CheckedChanged(object sender, EventArgs e) { int result = com.FetchDataInt(155 /* IO1 */, 166 / 2); if (chkAgvPrestopIO1.Checked) { result = BauerCOM.Commons.SetBit(0, result); } else { result = BauerCOM.Commons.ClearBit(0, result); } com.WriteDataInt(155, 166, result); }
private void btnWrite_Click(object sender, EventArgs e) { if (com.ReconnectIfDisconnected()) { // int read = com.FetchDataInt(10, Address); int write = 0; int bitmask = 1; for (int bit = 0; bit <= 15; bit++) { foreach (Control ctrl in Controls) { CheckBox chk = ctrl as CheckBox; if (chk == null) { continue; } if (chk.Text != bit.ToString()) { continue; } if (chk.Checked) { write = write | bitmask; } } bitmask = bitmask << 1; } int check = com.WriteDataInt(DB, Address, write); Logtext($"{DateTime.Now.ToShortTimeString()} : written to {Address} : {write}"); } }