/// <summary> /// 생성자 - 초기 변수 & 객체 초기화 /// </summary> public MainWindow() { // Arduino 초기화 부분 try { arduinoSerial = new ArduinoSerial(); fileTrigger = new FileTrigger(@"../../../Web/", "messageLog.txt", arduinoSerial); } catch (Exception e) { Console.WriteLine(e.ToString()); } this.SourceInitialized += InitializeWindowSource; // 필요 변수 초기화 historyFolderPath = AppDomain.CurrentDomain.BaseDirectory + @"..\..\..\Web\static\image\History\"; logFolderPath = AppDomain.CurrentDomain.BaseDirectory + @".\Log\log.txt"; Console.WriteLine(historyFolderPath); // Get Speaker Source speaker = new SoundPlayer(@"..\..\Resource\interPhoneBell.wav"); speaker.LoadAsync(); // Get Default KinectSensor this.kinect = KinectSensor.GetDefault(); // for Handling Color Frame if (kinect != null) { this.CFReader = kinect.ColorFrameSource.OpenReader(); // 이벤트 핸들러 넘겨줌 this.CFReader.FrameArrived += this.SaveColorMap; FrameDescription colorFrameDescription = this.kinect.ColorFrameSource.CreateFrameDescription(ColorImageFormat.Bgra); colorBitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height, 96.0, 96.0, PixelFormats.Bgr32, null); // for Handling Body Frame this.BFReader = kinect.BodyFrameSource.OpenReader(); this.maxBodyCount = this.kinect.BodyFrameSource.BodyCount; // 이벤트 핸들러 넘겨줌 this.BFReader.FrameArrived += this.ObserveDoor; this.bodies = new Body[this.maxBodyCount]; // for Handling Face Frame this.kinect.Open(); } faceAnalysis = new FaceAnalysis(@"."); // 이미지 작성자의 인스턴스화 imageListwriter = WriteImageList.GetInstance(); this.DataContext = this; InitializeComponent(); }
public FileTrigger(string path, string fileName, ArduinoSerial serial) { this.serial = serial; this.fileName = fileName; this.watcher = new FileSystemWatcher(); this.watcher.Path = path; this.watcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName; this.watcher.Filter = "*.txt"; this.watcher.Created += watcher_Created; this.watcher.Changed += watcher_Created; this.watcher.EnableRaisingEvents = true; Console.WriteLine("Start File Trigger"); }