public AddFunctionCodeForm(EasyModbusManager easyModbusManager, int selectedConnection) { this.easyModbusManager = easyModbusManager; this.selectedConnection = selectedConnection; InitializeComponent(); propertyGrid1.SelectedObject = new FunctionProperties(); }
private void UpdateDataGridView(object sender) { for (int i = 0; i < dataGridView1.RowCount - 1; i++) { foreach (ConnectionProperties connectionProperty in easyModbusManager.connectionPropertiesList) { if (dataGridView1[0, i].Value != null) { if (connectionProperty.ConnectionName.Equals(dataGridView1[0, i].Value.ToString())) { foreach (FunctionProperties functionProperty in connectionProperty.FunctionPropertiesList) { if (dataGridView1[1, i].Value != null) { for (int j = 0; j < functionProperty.Quantity; j++) { if (EasyModbusManager.getAddress(functionProperty.FunctionCode, functionProperty.StartingAdress, functionProperty.Quantity, j).Equals(dataGridView1[1, i].Value.ToString())) { if (functionProperty.values.GetType().Equals(typeof(Boolean[]))) { dataGridView1[4, i].Value = ((bool[])functionProperty.values)[j].ToString(); } else { if (dataGridView1[3, i].Value != null) { if (dataGridView1[3, i].Value.Equals("UINT16 (0...65535)")) { if (((int[])functionProperty.values)[j] < 0) { dataGridView1[4, i].Value = (65536 + ((int[])functionProperty.values)[j]).ToString(); } else { dataGridView1[4, i].Value = ((int[])functionProperty.values)[j].ToString(); } } else { dataGridView1[4, i].Value = ((int[])functionProperty.values)[j].ToString(); } } else { dataGridView1[4, i].Value = ((int[])functionProperty.values)[j].ToString(); } } } } } } } } } } }
public AddFunctionCodeForm(EasyModbusManager easyModbusManager, int selectedConnection, int indexToEdit) { this.easyModbusManager = easyModbusManager; this.selectedConnection = selectedConnection; InitializeComponent(); FunctionProperties functionProperty; functionProperty = easyModbusManager.connectionPropertiesList[selectedConnection].FunctionPropertiesList[indexToEdit]; propertyGrid1.SelectedObject = functionProperty; editMode = true; this.indexToEdit = indexToEdit; }
public AddConnectionForm(EasyModbusManager easyModbusManager) { // // The InitializeComponent() call is required for Windows Forms designer support. // this.easyModbusManager = easyModbusManager; InitializeComponent(); connectionProperties.ConnectionName = "Connection #" + (easyModbusManager.connectionPropertiesList.Count + 1).ToString(); propertyGrid1.SelectedObject = connectionProperties; // // TODO: Add constructor code after the InitializeComponent() call. // }
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e) { // check if we are in column value if (e.ColumnIndex == 4) { int idx = e.RowIndex; FunctionProperties functionProperties = easyModbusManager.FindPropertyFromGrid(idx); if (functionProperties != null) { string str = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString(); int[] values = EasyModbusManager.StrToValues(functionProperties, str); easyModbusManager.WriteToServer(functionProperties, values); } } }
public AddConnectionForm(EasyModbusManager easyModbusManager, int indexToEdit) { this.easyModbusManager = easyModbusManager; InitializeComponent(); connectionProperties.ConnectionName = easyModbusManager.connectionPropertiesList[indexToEdit].ConnectionName; connectionProperties.CycleTime = easyModbusManager.connectionPropertiesList[indexToEdit].CycleTime; connectionProperties.CyclicFlag = easyModbusManager.connectionPropertiesList[indexToEdit].CyclicFlag; connectionProperties.ModbusTCPAddress = easyModbusManager.connectionPropertiesList[indexToEdit].ModbusTCPAddress; connectionProperties.Port = easyModbusManager.connectionPropertiesList[indexToEdit].Port; connectionProperties.ComPort = easyModbusManager.connectionPropertiesList[indexToEdit].ComPort; connectionProperties.SlaveID = easyModbusManager.connectionPropertiesList[indexToEdit].SlaveID; connectionProperties.ModbusTypeProperty = easyModbusManager.connectionPropertiesList[indexToEdit].ModbusTypeProperty; connectionProperties.modbusClient = easyModbusManager.connectionPropertiesList[indexToEdit].modbusClient; propertyGrid1.SelectedObject = connectionProperties; editMode = true; this.indexToEdit = indexToEdit; }
private void UpdateDataGridView(object sender) { for (int i = 0; i < dataGridView1.RowCount - 1; i++) { foreach (ConnectionProperties connectionProperty in easyModbusManager.connectionPropertiesList) { if (dataGridView1[0, i].Value != null) { if (connectionProperty.ConnectionName.Equals(dataGridView1[0, i].Value.ToString())) { foreach (FunctionProperties functionProperty in connectionProperty.FunctionPropertiesList) { if (dataGridView1[1, i].Value != null) { for (int j = 0; j < functionProperty.Quantity; j++) { if (EasyModbusManager.getAddress(functionProperty.FunctionCodeRead, functionProperty.StartingAdress, functionProperty.Quantity, j).Equals(dataGridView1[1, i].Value.ToString())) { functionProperty.DataGridRow = i; if (functionProperty.values.GetType().Equals(typeof(Boolean[]))) { dataGridView1[4, i].Value = ((bool[])functionProperty.values)[j].ToString(); } else { if (dataGridView1[3, i].Value != null) { if (dataGridView1[3, i].Value.Equals("UINT16 (0...65535)")) { if (((int[])functionProperty.values)[j] < 0) { dataGridView1[4, i].Value = (65536 + ((int[])functionProperty.values)[j]).ToString(); } else { dataGridView1[4, i].Value = ((int[])functionProperty.values)[j].ToString(); } } else if (dataGridView1[3, i].Value.Equals("ASCII")) { string str = ""; for (int tt = 0; tt < ((int[])functionProperty.values).Length; tt++) { int value = ((int[])functionProperty.values)[tt]; str += "" + (char)((value & 0xff00) >> 8) + (char)((value & 0x00ff)); } dataGridView1[4, i].Value = "" + str; } else { dataGridView1[4, i].Value = ((int[])functionProperty.values)[j].ToString(); } } else { dataGridView1[4, i].Value = ((int[])functionProperty.values)[j].ToString(); } } } } } } } } } } }