Beispiel #1
0
 public Trigger_VM(MotionTrigger motionTrigger)
 {
     MotionTriggerFile = motionTrigger;
 }
 public Trigger_Control(MotionTrigger motionTrigger)
 {
     InitializeComponent();
     Trigger_VM  = new Trigger_VM(motionTrigger);
     DataContext = Trigger_VM;
 }
Beispiel #3
0
        public void analyzeFiles(List <string> list_filePaths)
        {
            int totalFiles = 0;

            Dictionary <byte, triggerData> triggerDataRange = new Dictionary <byte, triggerData>();
            Dictionary <byte, triggerData> triggerDataFrame = new Dictionary <byte, triggerData>();

            int filesWithFrame13_1Param  = 0;
            int filesWithFrame13_2Params = 0;

            //List<string> filesFalse = new List<string>();

            foreach (string filePath in list_filePaths)
            {
                totalFiles++;
                Debug.WriteLine("Reading file: " + filePath);

                bool hasFrame13_1Param  = false;
                bool hasFrame13_2Params = false;

                if (filePath == null || !filePath.EndsWith(".mset"))
                {
                    continue;
                }

                if (filePath.EndsWith("EX_0010.mset")) // Trigger param size in bytes for some reason
                {
                    continue;
                }

                using var stream = File.Open(filePath, FileMode.Open);
                if (!Bar.IsValid(stream))
                {
                    continue;
                }

                if (stream.Length == 0) // DUMMY
                {
                    continue;
                }

                Bar binarc = Bar.Read(stream); // ANB

                bool hasNonAnb = false;
                foreach (Bar.Entry barEntry in binarc)
                {
                    if (!Bar.IsValid(barEntry.Stream))
                    {
                        continue;
                    }

                    if (barEntry.Type == Bar.EntryType.Anb)
                    {
                        Bar anbBar = Bar.Read(barEntry.Stream);

                        foreach (Bar.Entry anbEntry in anbBar)
                        {
                            if (anbEntry.Type == Bar.EntryType.MotionTriggers && anbEntry.Stream.Length > 0)
                            {
                                MotionTrigger motionTriggerEntry = new MotionTrigger(anbEntry.Stream);

                                foreach (MotionTrigger.RangeTrigger rangeTrigger in motionTriggerEntry.RangeTriggerList)
                                {
                                    if (!triggerDataRange.ContainsKey(rangeTrigger.Trigger))
                                    {
                                        triggerDataRange.Add(rangeTrigger.Trigger, new triggerData());
                                    }

                                    triggerDataRange[rangeTrigger.Trigger].trigger = rangeTrigger.Trigger;
                                    triggerDataRange[rangeTrigger.Trigger].paramSize.Add(rangeTrigger.ParamSize);
                                }

                                foreach (MotionTrigger.FrameTrigger frameTrigger in motionTriggerEntry.FrameTriggerList)
                                {
                                    if (!triggerDataFrame.ContainsKey(frameTrigger.Trigger))
                                    {
                                        triggerDataFrame.Add(frameTrigger.Trigger, new triggerData());
                                    }

                                    triggerDataFrame[frameTrigger.Trigger].trigger = frameTrigger.Trigger;
                                    triggerDataFrame[frameTrigger.Trigger].paramSize.Add(frameTrigger.ParamSize);

                                    if (frameTrigger.Trigger == 13 && frameTrigger.ParamSize == 1)
                                    {
                                        hasFrame13_1Param = true;
                                    }
                                    if (frameTrigger.Trigger == 13 && frameTrigger.ParamSize == 2)
                                    {
                                        hasFrame13_2Params = true;
                                    }
                                }
                            }
                        }
                    }
                }
                if (hasFrame13_1Param)
                {
                    filesWithFrame13_1Param++;
                }
                if (hasFrame13_2Params)
                {
                    filesWithFrame13_2Params++;
                }
            }
            Debug.WriteLine("totalFiles: " + totalFiles);
            Debug.WriteLine("filesWithFrame13_1Param: " + filesWithFrame13_1Param);
            Debug.WriteLine("filesWithFrame13_2Params: " + filesWithFrame13_2Params);
            foreach (byte triggerRange in triggerDataRange.Keys)
            {
                Debug.WriteLine("Range Trigger [" + triggerRange + "] <" + string.Join(";", triggerDataRange[triggerRange].paramSize) + ">");
            }
            foreach (byte triggerFrame in triggerDataFrame.Keys)
            {
                Debug.WriteLine("Frame Trigger [" + triggerFrame + "] <" + string.Join(";", triggerDataFrame[triggerFrame].paramSize) + ">");
            }
        }