public static void GetFinalResult(bool displayResult)
        {
            MyTask endMessage = new MyTask("END", null);

            using (System.IO.StreamWriter file = new System.IO.StreamWriter("output.txt"))
            {
                foreach (var s in streams)
                {
                    DataExchange dataExt = new DataExchange(s.Value);
                    dataExt.writeStream(endMessage);
                    MyTask done = (MyTask)dataExt.readStream();

                    if (displayResult)
                    {
                        Console.WriteLine(done);
                    }

                    Tuple <string, int> res = (Tuple <string, int>)done.outputData;

                    file.WriteLine(res.Item1 + ", " + res.Item2);

                    s.Value.Close();
                }

                file.Close();
            }
        }
        /// <summary>
        /// Parse the configuration file
        /// </summary>
        /// <param name="frontUIData">front-backend data exchange</param>
        private void ParseConfig(DataExchange frontUIData)
        {
            string       configureFile = frontUIData.BackEndConfigFile;
            string       configureDir  = System.IO.Path.GetDirectoryName(configureFile);
            StreamReader ConfigReader  = new StreamReader(configureFile);
            string       strLine;

            string[] strArr;

            try
            {
                m_strLeftMatFileName  = _RootedPath(ConfigReader.ReadLine(), configureDir);
                m_strRightMatFileName = _RootedPath(ConfigReader.ReadLine(), configureDir);

                strLine         = ConfigReader.ReadLine();
                strArr          = strLine.Split(new char[] { ' ' });
                m_iReSizeHeight = Convert.ToInt32(strArr[0]);
                m_iReSizeWidth  = Convert.ToInt32(strArr[1]);

                strLine = ConfigReader.ReadLine();
                strArr  = strLine.Split(new char[] { ' ' });

                m_iLocalHeight = Convert.ToInt32(strArr[0]);
                m_iLocalWidth  = Convert.ToInt32(strArr[1]);

                if ((m_iLocalWidth == 0) || (m_iLocalHeight == 0))
                {
                    m_bGlocalTrans = false;
                }
                else
                {
                    m_bGlocalTrans = true;
                }

                ExchangeElement el = frontUIData.GetElement(0);

                if ((m_iReSizeHeight == (el.Height / 2)) && (m_iReSizeWidth == (el.Width / 2)))
                {
                    m_bDownSample = true;
                    m_bResize     = false;
                }
                else
                {
                    if ((m_iReSizeHeight == el.Height) && (m_iReSizeWidth == el.Width))
                    {
                        m_bDownSample = false;
                        m_bResize     = false;
                    }
                    else
                    {
                        m_bDownSample = false;
                        m_bResize     = true;
                    }
                }
            }
            catch
            {
                throw(new Exception("Exception: Configuration File Format Error"));
            }
        }
        public static void runServer()
        {
            NamedPipeServerStream pipeServer = new NamedPipeServerStream("mypipe", PipeDirection.InOut, numberOfInstance);

            pipeServer.WaitForConnection();
            Console.WriteLine("Connected to Server.");


            DataExchange dataExt = new DataExchange(pipeServer);

            MyTask inProgress = (MyTask)dataExt.readStream();

            Console.WriteLine(inProgress);


            if (inProgress.taskName == "SPLIT")
            {
                inProgress.outputData = Map((string)inProgress.inputData);
                inProgress.taskName   = "SPLIT RESULT";
                dataExt.writeStream(inProgress);
            }

            else if (inProgress.taskName == "SHUFFLE")
            {
                Reduce(inProgress, dataExt);
            }

            else if (inProgress.taskName == "CLEAR")
            {
                Console.Clear(); Console.WriteLine("\n\nwaiting for connection...");
            }
        }
        /// <summary>
        /// Project the list of image data in frontUIData into the embedding space
        /// </summary>
        /// <param name="frontUIData">Front Data Exchange</param>
        /// <returns></returns>
        private List <INumArray <double> > RankOneProjImgList(DataExchange frontUIData)
        {
            INumArray <double> l;
            INumArray <double> r;
            INumArray <double> data;
            INumArray <double> vecData;

            List <INumArray <double> > listImgVec = new List <INumArray <double> >();//list of projected image data

            int             nEl   = frontUIData.ElementCount;
            int             nProj = _leftMatrix.size1;
            ExchangeElement exEl;

            for (int i = 0; i < nEl; i++)
            {
                exEl = frontUIData.GetElement(i);
                data = GetData(exEl);

                vecData = ArrFactory.DoubleArray(nProj);
                for (int j = 0; j < nProj; j++)
                {
                    l          = (INumArray <double>)(_leftMatrix.GetCol(j));
                    r          = (INumArray <double>)(_rightMatrix.GetCol(j));
                    vecData[j] = (((INumArray <double>)(l.Transpose())).Mult(data).Mult(r))[0];
                }
                listImgVec.Add(vecData);
            }
            return(listImgVec);
        }
        public static void Reduce(List <Tuple <string, int> > input)
        {
            foreach (var tuple in input)
            {
                MyTask task = new MyTask("SHUFFLE", tuple);
                Console.WriteLine(task);

                lock (balanceLock)
                {
                    if (!streams.ContainsKey(tuple.Item1))
                    {
                        var pipe = new NamedPipeClientStream(".", "mypipe", PipeDirection.InOut);
                        pipe.Connect();

                        streams.TryAdd(tuple.Item1, pipe);
                    }

                    Stream value;
                    streams.TryGetValue(tuple.Item1, out value);

                    DataExchange dataExt = new DataExchange(value);

                    dataExt.writeStream(task);

                    //Thread.Sleep(50);
                }
            }
        }
Exemple #6
0
        /// <summary>
        /// Initial Layout by MDS from the distance matrix calculated
        /// </summary>
        /// <param name="frontUIData">DataExchange Element</param>
        public void InitialLayout(DataExchange frontUIData)
        {
            frontUIData.RescaleCoordinates(0, _maxCoord[0], 0, _maxCoord[1]);

            int size0 = frontUIData.DistanceMatrix.GetLength(0);
            int size1 = frontUIData.DistanceMatrix.GetLength(1);

            double[,] mtxDistance = new double[size0, size1];
            Array.Copy(frontUIData.DistanceMatrix, mtxDistance, size0 * size1);

            double dStress = 0;

            //Multiple Dimension Scaling by Conjugate Gradient initialized by classical MDS
            double[,] arrDimRedData   = LibFaceSort.DimReduction.MultiDimScaling(mtxDistance, 2);
            double[,] arrDimRedDataCG = LibFaceSort.DimReduction.MultiDimScalingCG(mtxDistance, arrDimRedData, false, ref dStress);
            //Temporary hard code them

            double[,] arrMinMax = MinMax(arrDimRedDataCG);
            _minMaxMDS[0, 0]    = arrMinMax[0, 0];
            _minMaxMDS[0, 1]    = arrMinMax[1, 0];
            _minMaxMDS[1, 0]    = arrMinMax[0, 1];
            _minMaxMDS[1, 1]    = arrMinMax[1, 1];

            //double[,] Coord = RMapData2Screen(arrDimRedDataCG);
            double[,] Coord = MapData2Screen(arrDimRedDataCG);

            frontUIData.Coordinates = Coord;
            frontUIData.DataRect    = new System.Windows.Rect(0, 0, _maxCoord[0], _maxCoord[1]);
        }
        /// <summary>
        /// Parse the config file for LBP distances
        /// </summary>
        /// <param name="frontUIData">the data exchange data structure</param>
        private void ParseConfig(DataExchange frontUIData)
        {
            string       configureFile = frontUIData.BackEndConfigFile;
            string       configureDir  = System.IO.Path.GetDirectoryName(configureFile);
            StreamReader ConfigReader  = new StreamReader(configureFile);
            string       strLine;

            string[] strArr;

            try
            {
                _classifierFileName  = ConfigReader.ReadLine();
                _rectangularFileName = ConfigReader.ReadLine();

                _classifierFileName  = _RootedPath(_classifierFileName, configureDir);
                _rectangularFileName = _RootedPath(_rectangularFileName, configureDir);

                strLine    = ConfigReader.ReadLine();
                strArr     = strLine.Split();
                _imgHeight = Convert.ToInt32(strArr[0]);
                _imgWidth  = Convert.ToInt32(strArr[1]);
                strLine    = ConfigReader.ReadLine();
                strArr     = strLine.Split();
                _stage     = Convert.ToInt32(strArr[0]);
                _thresh    = Convert.ToSingle(strArr[1]);
            }
            catch
            {
                ConfigReader.Close();
                throw new Exception("Config file reading error!!");
            }

            ConfigReader.Close();
        }
Exemple #8
0
        private void writeEffectiveValueInPlc()
        {
            DataExchange.CoilNumber_15      = spiDomain.rollNumber;
            DataExchange.CoilSplitNumber_15 = spiDomain.subRollNumber;
            DataExchange.ColorCode_15       = spiDomain.colorCode;
            DataExchange.Width_15           = float.Parse(spiDomain.width);
            DataExchange.Thickness_15       = float.Parse(spiDomain.thickness);

            DataExchange.L_15        = float.Parse(this.textBox_CurrentL.Text);
            DataExchange.a_15        = float.Parse(this.textBox_CurrentA.Text);
            DataExchange.b_15        = float.Parse(this.textBox_CurrentB.Text);
            DataExchange.Altitude_15 = float.Parse(spiDomain.broadwise);
            DataExchange.L_STD_15    = float.Parse(spiDomain.std_L);
            DataExchange.a_STD_15    = float.Parse(spiDomain.std_a);
            DataExchange.b_STD_15    = float.Parse(spiDomain.std_b);

            DataExchange.StandardSrcMode_15 = absColorStd.standardSrcMode;// 当前选择的模式 1,2,3,4
            DataExchange.DeltaL_15          = float.Parse(spiDomain.deltaL);
            DataExchange.DeltaA_15          = float.Parse(spiDomain.deltaA);
            DataExchange.DeltaB_15          = float.Parse(spiDomain.deltaB);
            DataExchange.DeltaE_15          = float.Parse(spiDomain.deltaE);
            //     DataExchange.DeltaEMax_15 = ; // ΔE漏涂阈值,该值在参数页面设置
            DataExchange.DeltaLStd_15 = float.Parse(csDomain.deltaL_std);
            DataExchange.DeltaAStd_15 = float.Parse(csDomain.deltaA_std);
            DataExchange.DeltaBStd_15 = float.Parse(csDomain.deltaB_std);
            DataExchange.DeltaEStd_15 = float.Parse(csDomain.deltaE_std);
            //   DataExchange.InspectionCtrl_15 = ; // 该值发生变化时,给色差仪发送不同的命令
            //   DataExchange.SetPosition_15 = ; // 选择0,1,2,3对应人工位,进行模式选择后,写一次
            DataExchange.WritePlc1500();
        }
Exemple #9
0
        public override void Import(string selectedNids)
        {
            DataTable Table           = null;
            int       ProgressCounter = 0;
            DI6SubgroupTypeBuilder       SGBuilderObj = null;
            DI6SubgroupTypeInfo          SGInfoObj    = null;
            Dictionary <string, DataRow> FileWithNids = new Dictionary <string, DataRow>();

            DIConnection           SourceDBConnection  = null;
            DIQueries              SourceDBQueries     = null;
            DI6SubgroupTypeBuilder SourceSGTypeBuilder = null;

            //-- Step 1: Get TempTable with Sorted SourceFileName
            Table = this._TargetDBConnection.ExecuteDataTable(this.ImportQueries.GetImportSubgroupDimensions(selectedNids));

            //-- Step 2:Initialise Indicator Builder with Target DBConnection
            SGBuilderObj = new DI6SubgroupTypeBuilder(this.TargetDBConnection, this.TargetDBQueries);

            // Initialize progress bar
            this.RaiseProgressBarInitialize(selectedNids.Split(',').GetUpperBound(0) + 1);


            //-- Step 3: Import Nids for each SourceFile
            foreach (DataRow Row in Table.Copy().Rows)
            {
                try
                {
                    string SourceFileWPath = Convert.ToString(Row[MergetTemplateConstants.Columns.COLUMN_SOURCEFILENAME]);

                    SourceDBConnection = new DIConnection(DIServerType.MsAccess, String.Empty, String.Empty, SourceFileWPath, String.Empty, MergetTemplateConstants.DBPassword);
                    SourceDBQueries    = DataExchange.GetDBQueries(SourceDBConnection);

                    // get subgroup type info from source
                    SourceSGTypeBuilder = new DI6SubgroupTypeBuilder(SourceDBConnection, SourceDBQueries);
                    SGInfoObj           = SourceSGTypeBuilder.GetSubgroupTypeInfoByNid(Convert.ToInt32(Row[MergetTemplateConstants.Columns.COLUMN_SRCNID]));


                    // import subgroup type only if doesnt exist
                    SGBuilderObj.ImportSubgroupType(SGInfoObj, Convert.ToInt32(Row[MergetTemplateConstants.Columns.COLUMN_SRCNID]), SourceDBQueries, SourceDBConnection);
                    ProgressCounter += 1;
                    this.RaiseProgressBarIncrement(ProgressCounter);
                }
                catch (Exception ex) { ExceptionFacade.ThrowException(ex); }
                finally
                {
                    if (SourceDBConnection != null)
                    {
                        SourceDBConnection.Dispose();
                    }
                    if (SourceDBQueries != null)
                    {
                        SourceDBQueries.Dispose();
                    }
                }
            }
            this._AvailableTable = this.GetAvailableTable();
            this._UnmatchedTable = this.GetUnmatchedTable();
            // Close ProgressBar
            this.RaiseProgressBarClose();
        }
Exemple #10
0
        private void RingDoorbell()
        {
            DataExchange data     = EncompassApplication.Session.DataExchange;
            string       lockInfo = $"{EncompassHelper.User.FullName} Is Trying to Access Loan File #{Tag.LoanNumber}, Please Exit the File For A Moment";

            data.PostDataToUser(Tag.LockInfo.LockedBy, lockInfo);
        }
        /// <summary>
        /// The function to calculate the distance matrix of the elements listed in frontUIData
        /// </summary>
        /// <param name="frontUIData">front-backend Data Exchange</param>
        public void RankOneDistance(DataExchange frontUIData)
        {
            ParseConfig(frontUIData);
            string leftMat  = m_strLeftMatFileName;
            string rightMat = m_strRightMatFileName;

            _leftMatrix  = ArrFactory.DoubleArray(leftMat);
            _rightMatrix = ArrFactory.DoubleArray(rightMat);

            List <INumArray <double> > listImgVec = RankOneProjImgList(frontUIData);
            int nEl = listImgVec.Count;

            double[,] matrixDistance = new double[nEl, nEl];

            for (int i = 0; i < nEl; i++)
            {
                for (int j = i; j < nEl; j++)
                {
                    matrixDistance[i, j] = (listImgVec[i].Sub(listImgVec[j])).Magnitude();
                    matrixDistance[j, i] = matrixDistance[i, j];
                }
            }

            frontUIData.DistanceMatrix = matrixDistance;
        }
Exemple #12
0
        private void DingBack(string LoanNumber)
        {
            DataExchange data       = EncompassApplication.Session.DataExchange;
            string       loanNumber = !string.IsNullOrEmpty(LoanNumber) ? LoanNumber : EncompassApplication.CurrentLoan.LoanNumber;
            string       locked     = $"{EncompassHelper.User.FullName} Is Out Of {DingBackBorrower} Loans #{LoanNumber}";

            data.PostDataToUser(DingBackID, locked);
        }
 private void OnGeneralSettingChange(object sender, RoutedEventArgs e)
 {
     if (ignoreEvents)
     {
         return;
     }
     DataExchange.UpdateGeneralSettingsFromGUI();
 }
        public void SetCanvasId(int id)
        {
            ignoreEvents       = true;
            this.canvasId.Text = id.ToString();
            ignoreEvents       = false;

            DataExchange.UpdateGeneralSettingsFromGUI();
        }
Exemple #15
0
        // ======================================================================================


        /// <summary>
        /// 将plc的值写入实时数据库
        /// </summary>
        private void writeRealTimeValueInPlc()
        {
            DataExchange.RecoilLength_15        = DataExchange.RecoilLength;
            DataExchange.No6Length_15           = DataExchange.No6Length;
            DataExchange.No5Length_15           = DataExchange.No5Length;
            DataExchange.ExitSectionSpeed_15    = DataExchange.ExitSectionSpeed;
            DataExchange.ProcessSectionSpeed_15 = DataExchange.ProcessSectionSpeed;
            DataExchange.TransTo1500();
        }
Exemple #16
0
 public void DisableAllUsers()
 {
     foreach (var user in users)
     {
         user.isEnabled = false;
     }
     DataExchange.UpdateUsersFromGUI();
     UpdateUserList();
 }
Exemple #17
0
        public override void Import(string selectedNids)
        {
            DataTable   Table                = null;
            int         ProgressCounter      = 0;
            UnitBuilder TrgUnitBuilderObj    = null;
            UnitBuilder SourceUnitBuilderObj = null;
            UnitInfo    SrcUnitInfoObj       = null;

            DIConnection SourceDBConnection = null;
            DIQueries    SourceDBQueries    = null;

            //-- Step 1: Get TempTable with Sorted SourceFileName
            Table = this._TargetDBConnection.ExecuteDataTable(this.ImportQueries.GetImportUnits(selectedNids));

            //-- Step 2:Initialise Indicator Builder with Target DBConnection
            TrgUnitBuilderObj = new UnitBuilder(this.TargetDBConnection, this.TargetDBQueries);

            // Initialize progress bar
            this.RaiseProgressBarInitialize(selectedNids.Split(',').GetUpperBound(0) + 1);

            //-- Step 3: Import Nids for each SourceFile
            foreach (DataRow Row in Table.Copy().Rows)
            {
                try
                {
                    string SourceFileWPath = Convert.ToString(Row[MergetTemplateConstants.Columns.COLUMN_SOURCEFILENAME]);

                    SourceDBConnection = new DIConnection(DIServerType.MsAccess, String.Empty, String.Empty, SourceFileWPath, String.Empty, MergetTemplateConstants.DBPassword);
                    SourceDBQueries    = DataExchange.GetDBQueries(SourceDBConnection);

                    SourceUnitBuilderObj = new UnitBuilder(SourceDBConnection, SourceDBQueries);
                    SrcUnitInfoObj       = SourceUnitBuilderObj.GetUnitInfo(FilterFieldType.NId, Convert.ToString(Row[MergetTemplateConstants.Columns.COLUMN_SRCNID]));

                    // Import Unit from Source
                    TrgUnitBuilderObj.ImportUnit(SrcUnitInfoObj, Convert.ToInt32(Row[MergetTemplateConstants.Columns.COLUMN_SRCNID]), SourceDBQueries, SourceDBConnection);
                    ProgressCounter += 1;
                    this.RaiseProgressBarIncrement(ProgressCounter);
                }
                catch (Exception ex) { ExceptionFacade.ThrowException(ex); }
                finally
                {
                    if (SourceDBConnection != null)
                    {
                        SourceDBConnection.Dispose();
                    }
                    if (SourceDBQueries != null)
                    {
                        SourceDBQueries.Dispose();
                    }
                }
            }
            this._AvailableTable = this.GetAvailableTable();
            this._UnmatchedTable = this.GetUnmatchedTable();
            // Close ProgressBar
            this.RaiseProgressBarClose();
        }
Exemple #18
0
        public override void Import(string selectedNids)
        {
            DataTable   Table           = null;
            int         ProgressCounter = 0;
            AreaBuilder AreaBuilderObj  = null;
            AreaInfo    AreaInfoObj     = null;
            Dictionary <string, DataRow> FileWithNids = new Dictionary <string, DataRow>();

            DIConnection SourceDBConnection = null;
            DIQueries    SourceDBQueries    = null;

            // Initialize progress bar
            this.RaiseProgressBarInitialize(selectedNids.Split(',').GetUpperBound(0) + 1);


            //////-- Step 1: Get TempTable with Sorted SourceFileName
            ////Table = this._TargetDBConnection.ExecuteDataTable(this.ImportQueries.GetImportAreas(this._CurrentTemplateFileNameWPath,selectedNids));

            //-- Step 2:Initialise Indicator Builder with Target DBConnection
            AreaBuilderObj = new AreaBuilder(this.TargetDBConnection, this.TargetDBQueries);

            ////-- Step 3: Import Nids for each SourceFile
            //foreach (DataRow Row in Table.Copy().Rows)
            //{
            try
            {
                SourceDBConnection = new DIConnection(DIServerType.MsAccess, String.Empty, String.Empty, this._CurrentTemplateFileNameWPath, String.Empty, MergetTemplateConstants.DBPassword);
                SourceDBQueries    = DataExchange.GetDBQueries(SourceDBConnection);

                // AreaInfoObj = this.GetIndicatorInfo(Row);

                //AreaBuilderObj.ImportArea(selectedNids, 1, SourceDBConnection, SourceDBQueries);
                //AreaBuilderObj.ImportAreaMaps(selectedNids, 1, SourceDBConnection, SourceDBQueries);

                AreaBuilderObj.ImportArea(selectedNids, DICommon.SplitString(selectedNids, ",").Length, SourceDBConnection, SourceDBQueries, true);
                ProgressCounter += 1;
                this.RaiseProgressBarIncrement(ProgressCounter);
            }
            catch (Exception ex) { ExceptionFacade.ThrowException(ex); }
            finally
            {
                if (SourceDBConnection != null)
                {
                    SourceDBConnection.Dispose();
                }
                if (SourceDBQueries != null)
                {
                    SourceDBQueries.Dispose();
                }
            }
            //}
            this._UnmatchedTable = this.GetUnmatchedTable();
            this._AvailableTable = this.GetAvailableTable();
            // Close ProgressBar
            this.RaiseProgressBarClose();
        }
Exemple #19
0
        public ClipboardMonitor(Window window)
        {
            this.WindowInteropHelper = new WindowInteropHelper(window);
            this.WindowInteropHelper.EnsureHandle();

            this.HwndSource = HwndSource.FromHwnd(this.WindowInteropHelper.Handle);
            this.HwndSource.AddHook(new HwndSourceHook(WndProc));

            this.NextClipboardViewerHandle = DataExchange.SetClipboardViewer(this.WindowInteropHelper.Handle);
        }
 private void OnChatSend(object sender, RoutedEventArgs e)
 {
     if (ignoreEvents)
     {
         return;
     }
     if (DataExchange.CreateChatMessage(chatTextBox.Text, (bool)globalChatMode.IsChecked ? 0 : GetCanvasId()))
     {
         chatTextBox.Text = "";
     }
 }
Exemple #21
0
 /// <summary>
 /// 从房产的webservice中获取数据到临时表中去
 /// </summary>
 /// <returns>批次号</returns>
 public string GetDataFromFCWebservice(IDictionary <string, string> dicParam)
 {
     try
     {
         DataExchange dataExchange = new DataExchange();
         return(dataExchange.DataExtort(dicParam));
     }
     catch (Exception ex) {
         throw new Exception(ex.Message);
     }
 }
Exemple #22
0
 // 初始化PLC连接
 private void initPlcConnection()
 {
     try
     {
         DataExchange.Init();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #23
0
        private void OnDeleteUserClick(object sender, RoutedEventArgs e)
        {
            if (ignoreEvents)
            {
                return;
            }
            User user = GetSelectedUser();

            users.Remove(user);
            DataExchange.UpdateUsersFromGUI();
            UpdateUserList();
        }
        public fStundenplanersteller(DataExchange data, Boolean bStundenplanLaden)
        {
            InitializeComponent();

            if (bStundenplanLaden)
                öffnenToolStripMenuItem_Click(null, null);

            if (data != null && data.Stundenaufbau != null)
            {
                Speicher(data.Stundenaufbau, data.Schule);
            }
        }
        public static void clearServerConsole()
        {
            MyTask clearTask = new MyTask("CLEAR", null);

            var pipe = new NamedPipeClientStream(".", "mypipe", PipeDirection.InOut);

            pipe.Connect();

            DataExchange dataExt = new DataExchange(pipe);

            dataExt.writeStream(clearTask);
        }
Exemple #26
0
 private void readPlc_2_3()
 {
     for (; ;)
     {
         if (run == 0)
         {
             return;
         }
         DataExchange.ReadPlc2_3();
         Thread.CurrentThread.Join(READPLC_ELAPSE); // 暂停20毫秒
     }
 }
        /// <summary>
        /// Calculate the LBP distance
        /// </summary>
        /// <param name="frontUIData"></param>
        public void LBPDistance(DataExchange frontUIData)
        {
            ParseConfig(frontUIData);

            List <Image>    listFilteredImage = new List <Image>();
            int             nEl = frontUIData.ElementCount;
            ExchangeElement exEl = null;
            Image           filteredImage = null;
            LBPFilter       lbpFilter = new LBPFilter(1, 8, true, true);
            int             i, j;

            for (i = 0; i < nEl; i++)
            {
                exEl          = frontUIData.GetElement(i);
                filteredImage = GetData(exEl, lbpFilter);
                listFilteredImage.Add(filteredImage);
            }

            SparseFilterExample  example;
            LBPIntegralHistogrom lbpHist1 = new LBPIntegralHistogrom();
            LBPIntegralHistogrom lbpHist2 = new LBPIntegralHistogrom();

            StrongClassifier  strongClassifier   = LoadClassifier(_classifierFileName);
            RectangularFilter rectangularFilters = LoadFilterSet(_rectangularFileName);

            List <int> listRectangularIndices = GetFilterIndex(strongClassifier);

            float[]  score    = new float[2];
            double[] expScore = new double[2];

            double[,] distanceMatrix = new double[nEl, nEl];

            for (i = 0; i < nEl; i++)
            {
                lbpHist1.Create(listFilteredImage[i], lbpFilter.m_nFilterRange + 1);
                for (j = 0; j < i; j++)
                {
                    lbpHist2.Create(listFilteredImage[j], lbpFilter.m_nFilterRange + 1);
                    example = CreateFilterResponses(lbpHist1, lbpHist2,
                                                    rectangularFilters, listRectangularIndices);
                    score[0] = score[1] = 0;
                    score    = strongClassifier.Vote(example, score, _stage);

                    expScore[0]          = Math.Exp(Convert.ToDouble(score[0]));
                    expScore[1]          = Math.Exp(Convert.ToDouble(score[1]));
                    distanceMatrix[i, j] = expScore[0] / (expScore[0] + expScore[1]) + 0.05;
                    distanceMatrix[j, i] = distanceMatrix[i, j];
                }
            }
            frontUIData.DistanceMatrix = distanceMatrix;
        }
Exemple #28
0
        public async Task TestGetLastUpdateFromWebApi()
        {
            var DB = new DataBase();
            var PY = DB.GetPropertyAsync().Result ?? new Property();

            PY.WebApiAddress      = WebApiUrl;
            PY.GetMovieLastUpdate = DateTime.Now.AddDays(-5);
            int r = await DB.UpdatePropertyAsync(PY);

            var DE = new DataExchange();
            await DE.UpdateDataFromWebApi();

            Assert.AreNotEqual(1, 0);
        }
Exemple #29
0
        public void SetUserTokens(Guid id, string phpSessId, string authToken)
        {
            var user = GetUser(id);

            if (user == null)
            {
                return;
            }
            user.authToken = authToken;
            user.phpSessId = phpSessId;
            UpdateUserList();
            DataExchange.UpdateUsersFromGUI();
            Launcher.Save();
        }
Exemple #30
0
        private void OnDisableUser(object sender, RoutedEventArgs e)
        {
            if (ignoreEvents)
            {
                return;
            }

            if (userList.SelectedItem == null)
            {
                return;
            }
            GetSelectedUser().isEnabled = false;
            loginButton.IsEnabled       = true;
            DataExchange.UpdateUsersFromGUI();
        }
Exemple #31
0
        public async Task <IResult> Patch(DataExchange data)
        {
            if (!await Services.AdminHelper.IsAdminAsync(Context.Request.UserID))
            {
                return(Forbidden);
            }
            if (data == null)
            {
                return(BadRequest);
            }

            await DB.RunInTransactionAsync(db => data.Patch(db));

            return(OK);
        }
 private void translateAsync(byte[] uploadedFile, DataExchange.ServiceDataFormat inputFormat, DataExchange.ServiceDataFormat outputFormat, string outFile,string address)
 {
     try
     {
         DataExchange.DataTranslationClient client = new DataExchange.DataTranslationClient();
         IAsyncResult asyncResult = client.Begintranslate(new DataExchange.ServiceTranslationInfo
            {
                Data = uploadedFile,
                InputFormat = inputFormat,
                OutputFormat = outputFormat
            }, callback, client);
         Global.fileNames.Add(asyncResult.AsyncWaitHandle.SafeWaitHandle, outFile);
         Global.addresses.Add(asyncResult.AsyncWaitHandle.SafeWaitHandle, address);
         Global.clients.Add(asyncResult.AsyncWaitHandle.SafeWaitHandle, client);
     }
     catch (Exception ex)
     {
         Global.logger.log(ex.Message, Logger.LogType.ERROR);
     }
 }
        public IMusicfilesConverter GetCDMusicConverter(DataExchange.AlbumDescriptor ICDInfo, string Outdir, bool BigBrute = false, int Cdnumber = 0)
        {
            bool res = BassCd.BASS_CD_IsReady(Cdnumber);

            if ((!BigBrute) && (res == false))
                return null;

            return new CDConverter(ICDInfo, LameFromCD(Cdnumber), Outdir, Cdnumber);
        }
        private void simulateAsync(byte[] modelFile,byte[] weatherFile,DataExchange.ServiceDataFormat modelFormat,DataExchange.ServiceSimulationType simulationType,string outFile)
        {
            try
            {
                DataExchange.DataSimulationClient client = new DataExchange.DataSimulationClient();
                IAsyncResult asyncResult = client.Beginsimulate(new DataExchange.ServiceSimulationInfo
                {
                    Data = modelFile,
                    WeatherData = weatherFile,
                    ModelFormat = modelFormat,
                    Type = simulationType
                }, callback, client);
                Global.clients.Add(asyncResult.AsyncWaitHandle.SafeWaitHandle, client);
                Global.fileNames.Add(asyncResult.AsyncWaitHandle.SafeWaitHandle, outFile);
                Global.addresses.Add(asyncResult.AsyncWaitHandle.SafeWaitHandle, Request.UserHostAddress);

            }
            catch(Exception ex)
            {
                Global.logger.log(ex.Message, Logger.LogType.ERROR);
            }
        }