/// <summary> /// read a word /// </summary> private void ReadWord() { if (string.IsNullOrWhiteSpace(word_position.Text) || string.IsNullOrWhiteSpace(word_count.Text)) return; UInt16 val = 0; try { MemoryArea area = (MemoryArea) word_memory_area.SelectedItem; UInt16 position = Convert.ToUInt16(word_position.Text); UInt16 count = Convert.ToUInt16(word_count.Text); if (! plc.finsMemoryAreadRead(area, position, 0, count)) { throw new Exception(plc.LastError); } val = BTool.BytesToUInt16(plc.FinsCommand.Response[0], plc.FinsCommand.Response[1]); word_value.Text = val.ToString(); dialog.Text = plc.LastDialog("READ WORD"); dialog.AppendText("WORD VALUE: " + val.ToString()); } catch (Exception ex) { MessageBox.Show("ReadWord() Error: " + ex.Message); } }