Exemple #1
0
        public void SPUTest()
        {
            SPU testSPU1 = new SPU(0);
            SPU testSPU2 = new SPU(1);
            SPU testSPU3 = new SPU(2);

            Assert.AreEqual(0.19, testSPU1.CalculateRate(200, 3), 2);
            Assert.AreEqual(62.50, testSPU2.CalculateRate(500, 40), 2);
            Assert.AreEqual(71.25, testSPU3.CalculateRate(400, 38), 2);
        }
Exemple #2
0
 public BUS(GPU gpu, CDROM cdrom, SPU spu, JOYPAD joypad, TIMERS timers, MDEC mdec) {
     interruptController = new InterruptController();
     dma = new DMA(this);
     this.gpu = gpu;
     this.cdrom = cdrom;
     this.timers = timers;
     this.mdec = mdec;
     this.spu = spu;
     this.joypad = joypad;
 }
Exemple #3
0
 public BUS(IHostWindow window, Controller controller, CDROM cdrom)
 {
     interruptController = new InterruptController();
     dma        = new DMA(this);
     gpu        = new GPU(window);
     this.cdrom = cdrom;
     timers     = new TIMERS();
     joypad     = new JOYPAD(controller);
     mdec       = new MDEC();
     spu        = new SPU();
 }
        public void SPUTest()
        {
            SPU negativeValueTest = new SPU(-1, -2, "");

            Assert.AreEqual(0, negativeValueTest.Distance);
            Assert.AreEqual(0, negativeValueTest.Weight);
            Assert.AreEqual(null, negativeValueTest.SPUType);
            negativeValueTest.CalculateRate(-1, -2);
            Assert.AreEqual(0, negativeValueTest.Rate);

            //check to verify if different weights and classes were passsed in by the calculate rate method that it returns zero
            negativeValueTest = new SPU(1, 2, "");
            Assert.AreEqual(0, negativeValueTest.CalculateRate(1, 10));
            Assert.AreEqual(0, negativeValueTest.CalculateRate(12, 2));

            SPU fourDayTest = new SPU(1, 1, "4-day");

            Assert.AreEqual(1, fourDayTest.Distance);
            Assert.AreEqual(1, fourDayTest.Weight);
            Assert.AreEqual("4-day", fourDayTest.SPUType);
            fourDayTest.CalculateRate(1, 1);
            Assert.AreEqual(0.01, fourDayTest.Rate);
            Assert.AreEqual("SPU (4-day ground)", fourDayTest.DeliveryNameAndType);

            fourDayTest = new SPU(96, 96, "4-day");
            fourDayTest.CalculateRate(96, 96);
            Assert.AreEqual(46.08, fourDayTest.Rate);

            SPU twoDayTest = new SPU(1, 1, "2-day");

            Assert.AreEqual(1, twoDayTest.Distance);
            Assert.AreEqual(1, twoDayTest.Weight);
            Assert.AreEqual("2-day", twoDayTest.SPUType);
            twoDayTest.CalculateRate(1, 1);
            Assert.AreEqual(0.05, twoDayTest.Rate);
            Assert.AreEqual("SPU (2-day business)", twoDayTest.DeliveryNameAndType);

            twoDayTest = new SPU(255, 75, "2-day");
            twoDayTest.CalculateRate(255, 75);
            Assert.AreEqual(956.25, twoDayTest.Rate);

            SPU nextDayTest = new SPU(1, 1, "Next-day");

            Assert.AreEqual(1, nextDayTest.Distance);
            Assert.AreEqual(1, nextDayTest.Weight);
            Assert.AreEqual("Next-day", nextDayTest.SPUType);
            nextDayTest.CalculateRate(1, 1);
            Assert.AreEqual(0.08, nextDayTest.Rate);
            Assert.AreEqual("SPU (next-day)", nextDayTest.DeliveryNameAndType);

            nextDayTest = new SPU(25, 75, "Next-day");
            nextDayTest.CalculateRate(25, 75);
            Assert.AreEqual(140.63, nextDayTest.Rate);
        }
Exemple #5
0
        public ProjectPSX(IHostWindow window, string diskFilename)
        {
            controller = new DigitalController();
            memoryCard = new MemoryCard();
            cd         = new CD(diskFilename);
            spu        = new SPU(window);
            gpu        = new GPU(window);
            cdrom      = new CDROM(cd, spu);
            joypad     = new JOYPAD(controller, memoryCard);
            timers     = new TIMERS();
            mdec       = new MDEC();
            bus        = new BUS(gpu, cdrom, spu, joypad, timers, mdec);
            cpu        = new CPU(bus);

            bus.loadBios();
        }
Exemple #6
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            // Create a SaveFileDialog to request a path and file name to save to.
            SaveFileDialog saveFile1 = new SaveFileDialog();

            // Initialize the SaveFileDialog to specify the RTF extension for the file.
            saveFile1.DefaultExt = "*.SPU";
            saveFile1.Filter     = "SPU Emulator Files|*.SPU";

            // Determine if the user selected a file name from the saveFileDialog.
            if (saveFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK &&
                saveFile1.FileName.Length > 0)
            {
                // Save the contents of the RichTextBox into the file.
                SPU.SaveFile(saveFile1.FileName, RichTextBoxStreamType.PlainText);
            }
        }
Exemple #7
0
        private void toolStripButton10_Click(object sender, EventArgs e)
        {
            // Create an OpenFileDialog to request a file to open.
            OpenFileDialog openFile1 = new OpenFileDialog();

            // Initialize the OpenFileDialog to look for RTF files.
            openFile1.DefaultExt = "*.SPU";
            openFile1.Filter     = "SPU Files|*.SPU";

            // Determine whether the user selected a file from the OpenFileDialog.
            if (openFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK &&
                openFile1.FileName.Length > 0)
            {
                // Load the contents of the file into the RichTextBox.
                SPU.LoadFile(openFile1.FileName, RichTextBoxStreamType.PlainText);
            }
        }
Exemple #8
0
        /// <summary>
        /// 通过多语言ID从MongoDB中获取Lucene格式的数据源
        /// 增加搜索排序功能.wangwei.2016-3-10
        /// </summary>
        /// <param name="cultureID"></param>
        /// <param name="spuID"></param>
        /// <returns></returns>
        private static List <LuceneSpuModel> Select(List <View_seo_keys_culture> viewSEOKeysCultureList, int cultureID, ref int spuID)
        {
            List <LuceneSpuModel>          luceneSpuModelList          = null;
            List <MongoDBSpuItemModel>     mongoDBSpuItemModelList     = Select(cultureID, spuID);
            List <MongoDBSpuListSortModel> mongoDBSpuListSortModelList = Select(cultureID, mongoDBSpuItemModelList.Select(item => item.SPUID).ToList(), EPlatform.PC端.GetValue());//获取排序信息

            if (mongoDBSpuItemModelList.Count == 0)
            {
                mongoDBSpuItemModelList = null;
                return(luceneSpuModelList);
            }
            spuID = mongoDBSpuItemModelList[mongoDBSpuItemModelList.Count - 1].SPUID;
            luceneSpuModelList = new List <LuceneSpuModel>(mongoDBSpuItemModelList.Count);
            SPU                     spu = null;
            List <string>           propertyList = null, requiredList = null;
            View_seo_keys_culture   viewSEOKeysCulture      = null;
            MongoDBSpuListSortModel mongoDBSpuListSortModel = null;
            string                  keys                    = string.Empty;
            decimal                 price                   = decimal.Zero;
            int                     saleCount               = 0;
            decimal                 disCount                = decimal.Zero;
            int                     customerRatingCount     = 0;

            foreach (MongoDBSpuItemModel model in mongoDBSpuItemModelList)
            {
                try
                {
                    spu = JsonHelper.ConvertStrToJsonT <SPU>(model.SPUJSON);
                }
                catch
                {
                }
                if (spu == null)
                {
                    continue;
                }
                else
                {//需要处理材质和颜色必选区值
                    TLZ.COM.Module.WebSite.BIZ.SPUBIZ.HandleRenderSPU(spu);
                }
                if (_StatusArrary.Contains(spu.Status) &&
                    spu.Render == EProduct_SPU_Modify_Render.显示)
                {
                    #region 拼接描述属性字符串
                    propertyList = new List <string>();
                    foreach (var property in spu.Properties)
                    {
                        if (property.IsShow)
                        {
                            foreach (var value in property.Values)
                            {
                                if (value.IsUsed)
                                {
                                    propertyList.Add(string.Format("{0}={1}", property.Text, value.Text));
                                }
                            }
                        }
                    }
                    propertyList.TrimExcess();
                    string propertyText = string.Join("&", propertyList);
                    #endregion

                    #region 拼接描必选区字符串
                    requiredList = new List <string>();
                    foreach (var required in spu.Requireds)
                    {
                        if (required.IsUsed)
                        {
                            if (!required.IsApplyAllValue)
                            {
                                foreach (var value in required.Values)
                                {
                                    if (value.IsUsed)
                                    {
                                        requiredList.Add(string.Format("{0}={1}", required.Text, value.Text));
                                    }
                                }
                            }
                        }
                    }
                    requiredList.TrimExcess();
                    string requiredText = string.Join("&", requiredList);
                    #endregion

                    propertyList.AddRange(requiredList);
                    propertyList.TrimExcess();
                    string nameValue = string.Join("&", propertyList); //既可以搜必选区又可以搜索描述属性
                    propertyList.Clear();
                    propertyList = null;
                    requiredList.Clear();
                    requiredList = null;

                    #region 设置排序数据
                    mongoDBSpuListSortModel = mongoDBSpuListSortModelList.Find(item => item.SPUID == model.SPUID);
                    if (mongoDBSpuListSortModel != null)
                    {
                        price               = mongoDBSpuListSortModel.ActivePrice > 0 ? mongoDBSpuListSortModel.ActivePrice : mongoDBSpuListSortModel.SellPrice;
                        saleCount           = mongoDBSpuListSortModel.SaleCount;
                        disCount            = price / mongoDBSpuListSortModel.MarketPrice;
                        customerRatingCount = mongoDBSpuListSortModel.CustomerRatingCount;
                    }
                    else
                    {
                        price               = decimal.Zero;
                        saleCount           = 0;
                        disCount            = decimal.Zero;
                        customerRatingCount = 0;
                    }
                    #endregion

                    #region 拼接返回列表
                    //从数据库获取产品keys信息,并且索引。wangwei
                    if (viewSEOKeysCultureList != null)
                    {
                        viewSEOKeysCulture = viewSEOKeysCultureList.Find(item => item.PID == spu.PID && item.CultureID == cultureID && item.PlatformJSON == JsonHelper.ConvertJsonToStr(spu.Platforms));
                        if (viewSEOKeysCulture != null)
                        {
                            keys = viewSEOKeysCulture.Keys;
                        }
                    }
                    luceneSpuModelList.Add(new LuceneSpuModel
                    {
                        SPUID  = model.SPUID,
                        Status = (int)spu.Status,
                        Title  = spu.Title,
                        // TitleNotAnalyzed=spu.Title,
                        LeiMuNameJSON    = spu.LeiMuNames,
                        ImageJSON        = JsonHelper.ConvertJsonToStr(spu.Images),
                        DescriptionFull  = spu.DescriptionFull,
                        PropertyText     = propertyText,
                        RequiredText     = requiredText,
                        NameValue        = nameValue,
                        CultureID        = spu.CultureID,
                        IsHot            = (int)spu.IsHot,
                        IsMutilColor     = (int)spu.IsMutilColor,
                        UpTime           = spu.UpTime,
                        DescriptionShort = spu.DescriptionShort,
                        PID                 = spu.PID,
                        Sort                = spu.Sort,
                        Price               = price,
                        SaleCount           = saleCount,
                        DisCount            = disCount,
                        CustomerRatingCount = customerRatingCount,
                        Keys                = keys
                    });
                    #endregion
                }
            }
            mongoDBSpuItemModelList.Clear();
            mongoDBSpuItemModelList = null;
            luceneSpuModelList.TrimExcess();
            return(luceneSpuModelList);
        }