public nodeParameterDescription() { NodeTypes = new List <nodeTypes>(); using (StreamReader r = new StreamReader("parameters.json")) { string json = r.ReadToEnd(); dynamic array = JsonConvert.DeserializeObject(json); foreach (var item in array) { nodeTypes t = new nodeTypes(); NodeTypes.Add(t); t.Name = item.Name; foreach (var item2 in item.Value) { NodeParameterDefinition pd = new NodeParameterDefinition(); t.ParameterDefs.Add(pd); pd.Index = item2[0]; if (item2[1] != null) { pd.Min = item2[1]; } if (item2[2] != null) { pd.Max = item2[2]; } pd.Units = item2[3]; pd.Description = item2[4]; } } } }
private void UpdateDGVTimer_Tick(object sender, EventArgs e) { if (listBox1.SelectedIndex < 0) { dataGridView1.Rows.Clear(); return; } string node = listBox1.Items[listBox1.SelectedIndex].ToString(); LatestNodeDataNode nodeData = rPodNetworking.LatestNodeData.FirstOrDefault(x => (x.NodeName.Substring(0, 1).ToUpper() + x.NodeName.Substring(1) + " Node") == node); if (nodeData != null) { foreach (NodeDataPoint p in nodeData.DataValues) { bool found = false; foreach (DataGridViewRow row in dataGridView1.Rows) { if (row.Cells[0].Value != null && row.Cells[0].Value.ToString() == ("0x" + p.Index.ToString("X4"))) { row.Cells[1].Value = p.Value.ToString(); found = true; break; } } if (!found) { int row = dataGridView1.Rows.Add(); dataGridView1.Rows[row].Cells[0].Value = "0x" + p.Index.ToString("X4"); dataGridView1.Rows[row].Cells[1].Value = p.Value; nodeTypes t = rPodNetworking.nodeParameterData.NodeTypes.FirstOrDefault(x => node == (x.Name.Substring(0, 1).ToUpper() + x.Name.Substring(1) + " Node")); if (t != null) { NodeParameterDefinition def = t.ParameterDefs.FirstOrDefault(x => x.Index == p.Index); if (def != null) { dataGridView1.Rows[row].Cells[2].Value = def.Units; dataGridView1.Rows[row].Cells[3].Value = def.Description; } } } } } }