예제 #1
0
 public Match(List<Position> positions,Position center,Creates creates)
 {
     InvolvedPositions = positions;
     Center = center;
     if (!InvolvedPositions.Contains(center))
         InvolvedPositions.Add(center);
     Creates = creates;
     IsValid = true;
 }
예제 #2
0
            public static void Create(CreateInterceptor interceptor)
            {
                Type type = interceptor.GetType();

                if (Creates.ContainsKey(type))
                {
                    return;
                }
                Creates.Add(type, interceptor);
            }
        public void Anomalychoosen()
        {
            // clear the reports (for the case the user changed the dll)
            this.report_size = 0;
            this.anomaly_reports.Clear();
            this.real_flight_path  = Client.client_instance.From_reg;
            this.real_flight_path += "\\reg_flight.csv";
            if (this.dll_path == null)
            {
                return;
            }
            // first wrap the string!
            IntPtr pDll = NativeMethods.LoadLibrary(dll_path);
            IntPtr pAddressOfFunctionToCall = NativeMethods.GetProcAddress(pDll, "CreatestringWrapper");
            CreatestringWrapper wrap        = (CreatestringWrapper)Marshal.GetDelegateForFunctionPointer(
                pAddressOfFunctionToCall,
                typeof(CreatestringWrapper));
            IntPtr a = wrap(learning_flight_path);
            // create a csv file!
            IntPtr           pDll2 = NativeMethods.LoadLibrary(dll_path);
            IntPtr           pAddressOfFunctionToCall2 = NativeMethods.GetProcAddress(pDll2, "createTimeSeries");
            createTimeSeries toCsv = (createTimeSeries)Marshal.GetDelegateForFunctionPointer(
                pAddressOfFunctionToCall2,
                typeof(createTimeSeries));
            IntPtr time_series = toCsv(a, 42);

            // create the Detector and learn
            IntPtr  pDll3 = NativeMethods.LoadLibrary(dll_path);
            IntPtr  pAddressOfFunctionToCall3 = NativeMethods.GetProcAddress(pDll3, "Creates");
            Creates createAndDetect           = (Creates)Marshal.GetDelegateForFunctionPointer(
                pAddressOfFunctionToCall3,
                typeof(Creates));
            IntPtr detector = createAndDetect(time_series);

            /*
             * now we find the anomaly
             */
            IntPtr anomly_wrapper      = wrap(this.real_flight_path);
            IntPtr anomaly_time_series = toCsv(anomly_wrapper, 42);

            // anomaly data
            IntPtr      pDll4 = NativeMethods.LoadLibrary(dll_path);
            IntPtr      pAddressOfFunctionToCall4 = NativeMethods.GetProcAddress(pDll4, "anomalyData");
            anomalyData anomalyD = (anomalyData)Marshal.GetDelegateForFunctionPointer(
                pAddressOfFunctionToCall4,
                typeof(anomalyData));
            IntPtr anomaly_report = anomalyD(detector, anomaly_time_series);

            // find the number of anomaly data
            IntPtr        pDll5 = NativeMethods.LoadLibrary(dll_path);
            IntPtr        pAddressOfFunctionToCall5 = NativeMethods.GetProcAddress(pDll5, "anomalyLength");
            anomalyLength anomalyLength             = (anomalyLength)Marshal.GetDelegateForFunctionPointer(
                pAddressOfFunctionToCall5,
                typeof(anomalyLength));
            double n = anomalyLength(anomaly_report);

            // initalize the first and second element dll
            IntPtr pDll6 = NativeMethods.LoadLibrary(dll_path);
            IntPtr pAddressOfFunctionToCall6 = NativeMethods.GetProcAddress(pDll6, "anomalyFirstElemnet");
            anomalyFirstElemnet anomalyFirst = (anomalyFirstElemnet)Marshal.GetDelegateForFunctionPointer(
                pAddressOfFunctionToCall6, typeof(anomalyFirstElemnet));

            IntPtr pDll7 = NativeMethods.LoadLibrary(dll_path);
            IntPtr pAddressOfFunctionToCall7 = NativeMethods.GetProcAddress(pDll7, "anomalyScondElemnet");
            anomalyScondElemnet anomalyScond = (anomalyScondElemnet)Marshal.GetDelegateForFunctionPointer(
                pAddressOfFunctionToCall7,
                typeof(anomalyScondElemnet));

            IntPtr      pDll8 = NativeMethods.LoadLibrary(dll_path);
            IntPtr      pAddressOfFunctionToCall8 = NativeMethods.GetProcAddress(pDll8, "anomalyTime");
            anomalyTime anomalyTime = (anomalyTime)Marshal.GetDelegateForFunctionPointer(
                pAddressOfFunctionToCall8,
                typeof(anomalyTime));

            string[] path_parts;
            path_parts = this.dll_path.Split('\\');
            string detector_name = path_parts[path_parts.Length - 1];

            for (int i = 0; i < n; i++)
            {
                int    first_index  = anomalyFirst(anomaly_report, i);
                string first        = Client.client_instance.xmlPlace(first_index);
                int    second_index = anomalyScond(anomaly_report, i);
                string second       = Client.client_instance.xmlPlace(second_index);
                int    num          = anomalyTime(anomaly_report, i);
                string num_time     = convertToTime(num);
                anomaly_reports.Add(new anomalyReport(first, second, num_time, detector_name));
            }
            this.report_size = anomaly_reports.Count();
        }