Exemplo n.º 1
0
        }//end detectOne

        public CloudCoin detectCoin(CloudCoin cc, int milliSecondsToTimeOut)
        {
            returnCoin = cc;

            var t00 = Task.Factory.StartNew(() => detectOne(00, cc.nn, cc.sn, cc.ans[00], cc.pans[00], cc.getDenomination()));
            var t01 = Task.Factory.StartNew(() => detectOne(01, cc.nn, cc.sn, cc.ans[01], cc.pans[01], cc.getDenomination()));
            var t02 = Task.Factory.StartNew(() => detectOne(02, cc.nn, cc.sn, cc.ans[02], cc.pans[02], cc.getDenomination()));
            var t03 = Task.Factory.StartNew(() => detectOne(03, cc.nn, cc.sn, cc.ans[03], cc.pans[03], cc.getDenomination()));
            var t04 = Task.Factory.StartNew(() => detectOne(04, cc.nn, cc.sn, cc.ans[04], cc.pans[04], cc.getDenomination()));
            var t05 = Task.Factory.StartNew(() => detectOne(05, cc.nn, cc.sn, cc.ans[05], cc.pans[05], cc.getDenomination()));
            var t06 = Task.Factory.StartNew(() => detectOne(06, cc.nn, cc.sn, cc.ans[06], cc.pans[06], cc.getDenomination()));
            var t07 = Task.Factory.StartNew(() => detectOne(07, cc.nn, cc.sn, cc.ans[07], cc.pans[07], cc.getDenomination()));
            var t08 = Task.Factory.StartNew(() => detectOne(08, cc.nn, cc.sn, cc.ans[08], cc.pans[08], cc.getDenomination()));
            var t09 = Task.Factory.StartNew(() => detectOne(09, cc.nn, cc.sn, cc.ans[09], cc.pans[09], cc.getDenomination()));
            var t10 = Task.Factory.StartNew(() => detectOne(10, cc.nn, cc.sn, cc.ans[10], cc.pans[10], cc.getDenomination()));
            var t11 = Task.Factory.StartNew(() => detectOne(11, cc.nn, cc.sn, cc.ans[11], cc.pans[11], cc.getDenomination()));
            var t12 = Task.Factory.StartNew(() => detectOne(12, cc.nn, cc.sn, cc.ans[12], cc.pans[12], cc.getDenomination()));
            var t13 = Task.Factory.StartNew(() => detectOne(13, cc.nn, cc.sn, cc.ans[13], cc.pans[13], cc.getDenomination()));
            var t14 = Task.Factory.StartNew(() => detectOne(14, cc.nn, cc.sn, cc.ans[14], cc.pans[14], cc.getDenomination()));
            var t15 = Task.Factory.StartNew(() => detectOne(15, cc.nn, cc.sn, cc.ans[15], cc.pans[15], cc.getDenomination()));
            var t16 = Task.Factory.StartNew(() => detectOne(16, cc.nn, cc.sn, cc.ans[16], cc.pans[16], cc.getDenomination()));
            var t17 = Task.Factory.StartNew(() => detectOne(17, cc.nn, cc.sn, cc.ans[17], cc.pans[17], cc.getDenomination()));
            var t18 = Task.Factory.StartNew(() => detectOne(18, cc.nn, cc.sn, cc.ans[18], cc.pans[18], cc.getDenomination()));
            var t19 = Task.Factory.StartNew(() => detectOne(19, cc.nn, cc.sn, cc.ans[19], cc.pans[19], cc.getDenomination()));
            var t20 = Task.Factory.StartNew(() => detectOne(20, cc.nn, cc.sn, cc.ans[20], cc.pans[20], cc.getDenomination()));
            var t21 = Task.Factory.StartNew(() => detectOne(21, cc.nn, cc.sn, cc.ans[21], cc.pans[21], cc.getDenomination()));
            var t22 = Task.Factory.StartNew(() => detectOne(22, cc.nn, cc.sn, cc.ans[22], cc.pans[22], cc.getDenomination()));
            var t23 = Task.Factory.StartNew(() => detectOne(23, cc.nn, cc.sn, cc.ans[23], cc.pans[23], cc.getDenomination()));
            var t24 = Task.Factory.StartNew(() => detectOne(24, cc.nn, cc.sn, cc.ans[24], cc.pans[24], cc.getDenomination()));


            var taskList = new List <Task> {
                t00, t01, t02, t03, t04, t05, t06, t07, t08, t09, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24
            };

            Task.WaitAll(taskList.ToArray(), milliSecondsToTimeOut);
            //Get data from the detection agents

            for (int i = 0; i < 25; i++)
            {
                if (responseArray[i] != null)
                {
                    returnCoin.setPastStatus(responseArray[i].outcome, i);
                }
                else
                {
                    returnCoin.setPastStatus("undetected", i);
                };// should be pass, fail, error or undetected.
            }//end for each detection agent

            returnCoin.setAnsToPansIfPassed();
            returnCoin.calculateHP();
            returnCoin.gradeCoin(); // sets the grade and figures out what the file extension should be (bank, fracked, counterfeit, lost
            returnCoin.calcExpirationDate();
            returnCoin.grade();

            return(returnCoin);
        }//end detect coin