public MainWindow() { InitializeComponent(); CFSPortSelector.Init(); DrawSerialGraph.Init(); this.Closing += new CancelEventHandler(CloseEvent); }
public static void AddSerialDevice(string port_name) { SerialReceivedHandle data_received_handler = UpdateChartHandler; device.Last().cfs_control.SetDatareceivedHandle(data_received_handler); CFSPortSelector.ConnectPort(port_name, ref device.Last().cfs_control); device.Add(new Device()); // 次に使うやつ device.Last().cfs_control = new CFSControl(); }
private void CFSConnectButton_Click(object sender, RoutedEventArgs e) { if (!CFSPortSelector.IsComboBoxItemConnected()) { DrawSerialGraph.LinkingRegister2Graph(0x00, 0, "Fx", "red"); DrawSerialGraph.LinkingRegister2Graph(0x01, 0, "Fy", "blue"); DrawSerialGraph.LinkingRegister2Graph(0x02, 0, "Fz", "green"); DrawSerialGraph.LinkingRegister2Graph(0x03, 1, "Mx", "red"); DrawSerialGraph.LinkingRegister2Graph(0x04, 1, "My", "blue"); DrawSerialGraph.LinkingRegister2Graph(0x05, 1, "Mz", "green"); DrawSerialGraph.AddSerialDevice(CFSPortComboBox.Text); } else { DrawSerialGraph.RemoveSerialDevice(CFSPortComboBox.Text); } }
public static void RemoveSerialDevice(string port_name) { Device tmp = new Device(); foreach (var d in device) { if (d.cfs_control.port != null) { if (d.cfs_control.port.PortName == port_name) { CFSPortSelector.DisconnectPort(port_name, ref d.cfs_control); tmp = d; } } } device.Remove(tmp); // lineの削除 foreach (var graph in tmp.graph) { mainWindow.lines_left.Children.Remove(graph.linegraph); mainWindow.lines_right.Children.Remove(graph.linegraph); } }