private void OpenCANdb(object sender, RoutedEventArgs e) { // Configure save file dialog box Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.FileName = "ViTAmin"; // Default file name dlg.DefaultExt = ".dbc"; // Default file extension dlg.Filter = "CANdb (.dbc)|*.dbc"; // Filter files by extension // Show save file dialog box Nullable <bool> result = dlg.ShowDialog(); // Process save file dialog box results if (result == true) { // OpenFile string filename = dlg.FileName; CANdbFileName.Text = filename; Console.WriteLine(dlg.FileName); Parser pa = new Parser(); candb = pa.read(filename); List <Signal> SignalList = candb.GetAllSignal(); foreach (Signal s in SignalList) { Signals.Add(s); Console.WriteLine(Signals.Count + ", " + signals.Count); } } }
public ImagePreperation(CANdb candb) { ImgWidth = 1280; ImgHeight = 720; IpiList = new List <ImagePreperationItem>(); ImageParameters = new int[3]; // Get all signal from candb instance, this list is binded to dropbox in ListView List <Signal> signals = candb.GetAllSignal(); SignalList = new List <string>(); //Dictionary is used to convert dropbox label to actuall signal name foreach (Signal s in signals) { SignalList.Add(s.ToString()); SignalToNameDictionary.Add(s.ToString(), s.Name); } ImageDictionary = new Dictionary <string, WriteableBitmap>(); SignalDictionary = new Dictionary <string, string>(); //Get current location of app string initPath = AppDomain.CurrentDomain.BaseDirectory; //Ask user to specify the folder of images FolderBrowserDialog fbd = new FolderBrowserDialog(); fbd.SelectedPath = initPath; System.Windows.Forms.DialogResult result = fbd.ShowDialog(); string dirPath = fbd.SelectedPath; string[] paths = Directory.GetFiles(dirPath); NameList = new List <string>(paths); // Create IPI list with image and signal name. // IPI list is binded to ListView so any change in the form is directly changes value in IPI list. foreach (string name in NameList) { //Resize image so that it fits to window IplImage img = new IplImage(name); CvSize size = new CvSize(427, 240); IplImage resized = new IplImage(size, img.Depth, img.NChannels); Cv.Resize(img, resized); //WritableBitmap is compatible with Image Window of WPF WriteableBitmap wb = WriteableBitmapConverter.ToWriteableBitmap(resized); ImageDictionary.Add(name, wb); IpiList.Add(new ImagePreperationItem(wb, name)); } InitializeComponent(); }
public void SignalCheck() { List <Signal> list = candb.GetAllSignal(); Assert.AreEqual(2, list.Count); Signal s1 = list[0]; Assert.AreEqual(0.01, s1.Factor); Assert.AreEqual(16, s1.Length); Assert.AreEqual(320, s1.Max); Assert.AreEqual(0, s1.Min); Assert.AreEqual("Vi_VehicleSpeed", s1.Name); Assert.AreEqual(0, s1.Offset); Assert.AreEqual(ByteOrder.Motorola, s1.Order); Assert.AreEqual(false, s1.Signed); }
public TestMonitor(List <ImagePreperationItem> list, CANdb candb, object[] matlabParam, int[] imageParam) { matlab = new MLApp.MLApp(); can.InitCANtransmitter(); this.candb = candb; Result = new object[4]; ipiList = list; imageSize = new int[] { imageParam[1], imageParam[2] }; Cv.SetCaptureProperty(capture, CaptureProperty.FrameWidth, imageSize[0]); Cv.SetCaptureProperty(capture, CaptureProperty.FrameHeight, imageSize[1]); //Console.WriteLine("camera settings " + imageSize[0] + "x" + imageSize[1]); parameters = new object[6]; int startAt = 1; for (int i = startAt; i < parameters.Length; i++) { parameters[i] = matlabParam[i - startAt]; } parameters[0] = imageParam[0]; //Console.WriteLine("image size is " + imageSize[0] + "x" + imageSize[1]); signals = new ObservableCollection <SinalListItem>(); int count = 0; foreach (Signal s in candb.GetAllSignal()) { signals.Add(new SinalListItem(s.Name, 0.0)); nameSignalDictionary.Add(s.Name, count++); } distances = new ObservableCollection <String>(); foreach (ImagePreperationItem ipi in list) { distances.Add("0.00"); } InitializeComponent(); }