Ejemplo n.º 1
0
        private void Inst_Lwc1(MipsInstruction inst)
        {
            if (!CheckCop1Usable())
            {
                CauseException = ExceptionCode.CopUnstable;
                return;
            }

            if (!CheckEvenOddAllowed(inst.Ft))
            {
                CauseFPUException(FPUExceptionType.Unimplemented);
                return;
            }

            Int64  address = ComputeAddress(inst);
            UInt32 value   = DataManipulator.LoadWordUnsigned(address);

            if (MipsState.CP0Regs.StatusReg.AdditionalFPR)
            {
                MipsState.Fpr.WriteFPRUnsigned(inst.Ft, value);
            }
            else
            {
                MipsState.Fpr.WriteFPR32Unsigned(inst.Ft, value);
            }
        }
Ejemplo n.º 2
0
        public void TestNdayMeanValues()
        {
            var pairs  = new DataManipulator().GetDayInfoFromStrings(DataManipulationTests.MockData);
            var prices = new[] { pairs[0].Close, pairs[1].Close };

            Assert.AreEqual(60.02m, StockMath.Mean(prices));
        }
Ejemplo n.º 3
0
        private Series CreateSerie(string wellPath, string wellMethod, ChartArea chartArea)
        {
            Well well = controller.GetWell(wellPath);
            Dictionary <string, List <decimal> > wellData = well.WellData();
            string         depthDataKey = wellData.First().Key;
            List <decimal> methodData   = wellData[wellMethod];
            Series         serie        = new Series(chartArea.Name);
            int            i            = 0;

            //создается набор данных для чарта где глубина по X - т.к. фильтрация делается только по Y
            foreach (decimal depthValue in wellData[depthDataKey])
            {
                decimal y = methodData[i]; decimal x = depthValue;
                serie.Points.AddXY(x, y);
                i += 1;
            }
            //фильтрация - fix! вынести в отдельный метод, значение передавать пока как параметр, в дальнейшем сделать для пользователя поле для ввода неактуального значения
            //еще далее добавить аналогичную фильтрацию для значений >x <x
            DataManipulator filter = new DataManipulator();

            filter.Filter(CompareMethod.EqualTo, well.NonActualValue, serie);
            Series serie1 = new Series(chartArea.Name);

            //меняются местами x и y для правильного отображения графиков
            foreach (var item in serie.Points)
            {
                double y = item.XValue;
                double x = item.YValues[0];
                serie1.Points.AddXY(x, y);
            }
            return(serie1);
        }
Ejemplo n.º 4
0
        public void ExportSensors
        (
            int roomIndex,
            string filePath
        )
        {
            IExcelExport export = new DataManipulator();
            DataTable    var    = new DataTable();

            var.Columns.Add("1");
            var.Columns.Add("2");
            var.Columns.Add("3");
            var.Columns.Add("4");
            foreach (var sensor in User.Rooms[roomIndex].ListSensors)
            {
                var.Rows.Add
                (
                    sensor.Name,
                    sensor.Fam,
                    sensor.State,
                    sensor.Data
                );
            }
            export.ExportFile(filePath, User.Rooms[roomIndex].Name, var);
        }
Ejemplo n.º 5
0
        private void Inst_Lbu(MipsInstruction inst)
        {
            try
            {
                if (!MipsState.Operating64BitMode)
                {
                    MipsState.WriteGPR32Signed(inst.Rt, DataManipulator.LoadByteUnsigned(ComputeAddress(inst)));
                }
                else
                {
                    MipsState.WriteGPRSigned(inst.Rt, DataManipulator.LoadByteUnsigned(ComputeAddress(inst)));
                }
            }
            catch (TLBException tlbe)
            {
                switch (tlbe.ExceptionType)
                {
                case TLBExceptionType.Invalid: CauseException = ExceptionCode.Invalid; break;

                case TLBExceptionType.Mod: CauseException = ExceptionCode.TlbMod; break;

                case TLBExceptionType.Refill: CauseException = ExceptionCode.TlbStore; break;

                default: break;
                }
            }
        }
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        DataManipulator myScript = (DataManipulator)target;


        if (GUILayout.Button("Add", GUILayout.Width(100)))
        {
            //myScript.Test();

            Manipulation  manipulation = new Manipulation();
            myScript.Manipulations.Add(manipulation);

        }

        if (GUILayout.Button("Activate selected", GUILayout.Width(100)))
        {
            //myScript.Test();
            myScript.Activate();

        }

        if (GUILayout.Button("Deactivate selected", GUILayout.Width(100)))
        {
            //myScript.Test();
            myScript.Deactivate();

        }

    }
Ejemplo n.º 7
0
        private void Inst_Sdc1(MipsInstruction inst)
        {
            if (!CheckCop1Usable())
            {
                CauseException = ExceptionCode.CopUnstable;
                return;
            }

            if (!CheckEvenOddAllowed(inst.Ft))
            {
                return;
            }

            Int64  address = ComputeAddress(inst);
            UInt64 dword   = 0;

            if (MipsState.CP0Regs.StatusReg.AdditionalFPR)
            {
                dword = MipsState.Fpr.ReadFPRUnsigned(inst.Ft);
            }
            else
            {
                dword  = MipsState.Fpr.ReadFPR32Unsigned(inst.Ft) << 32;
                dword |= MipsState.Fpr.ReadFPRUnsigned(inst.Ft + 1);
            }

            DataManipulator.Store(address, dword);
        }
Ejemplo n.º 8
0
        //-----Solution External Interface-----
        public static void ProcessFileToFindNonStrictExtrema(String input_fname, String output_fname,
                                                             Double smoothing_parameter, char csv_split_symbol)
        {
            var init_data = new List <FullDataRow>();

            IO.ReadContents(csv_split_symbol, input_fname, init_data);

            var list_projection = new List <Double>();

            init_data.ForEach(delegate(FullDataRow elem) {
                list_projection.Add(elem.Amp);
            });

            if (init_data.Count > 1)
            {
                var smoothed_data = new List <Double>();
                DataManipulator.SmoothData(smoothing_parameter, list_projection, smoothed_data);

                var extrema_indices = new List <int>();
                ExtremaFinder.GetNonStrictExtremaIndices(smoothed_data, extrema_indices);

                var res_data = new List <OutDataRow>();
                GetElemsWithExtremaFromInitAndSmoothedProjection(extrema_indices, init_data, smoothed_data, res_data);

                IO.WriteContents(csv_split_symbol, output_fname, res_data);
            }
            // считаю, что у 1 точки нет окрестности
        }
Ejemplo n.º 9
0
        public void TestNdayVarianceValues()
        {
            var pairs  = new DataManipulator().GetDayInfoFromStrings(DataManipulationTests.MockData);
            var prices = new[] { pairs[0].Close, pairs[1].Close };

            Assert.AreEqual(99.6004, new StockMath().VariancePopulation(prices));
        }
Ejemplo n.º 10
0
        public void TestNDayStdDev()
        {
            var pairs  = new DataManipulator().GetDayInfoFromStrings(DataManipulationTests.MockData);
            var prices = new[] { pairs[0].Close, pairs[1].Close };

            Assert.AreEqual(Math.Sqrt(99.6004), StockMath.StandardDeviationPopulation(prices));
        }
Ejemplo n.º 11
0
        public void TurnScanOnOff(string tagType, string tagId, bool onOff)
        {
            lock (db)
            {
                if (tagType == "AI")
                {
                    AI tag = getByIdAI(tagId);
                    tag.OnOffScan = onOff;
                }
                else
                {
                    DI tag = getByIdDI(tagId);
                    tag.OnOffScan = onOff;
                }

                db.SaveChanges();
                DataManipulator.saveData();
                if (onOff)
                {
                    onChangeNotification($"Scan turned on.");
                }
                else
                {
                    onChangeNotification($"Scan turned off.");
                }
            }
        }
Ejemplo n.º 12
0
        public void addUpdateDI(string operation, string id, string description, string address, int scantime, bool onoffscan, string driver)
        {
            lock (db.DIs)
            {
                if (operation == "add")
                {
                    DI novi = new DI(id, description, address, scantime, onoffscan, driver);
                    db.DIs.Add(novi);

                    TagProcessing.DItags.Add(novi.Id, novi);
                    TagProcessing.DIthreads.Add(novi.Id, new Thread(() => TagProcessing.readDI(novi.Id)));
                    TagProcessing.DIthreads[novi.Id].Start();

                    db.SaveChanges();
                    DataManipulator.saveData();
                    return;
                }
                DI tag = getByIdDI(id);
                tag.Description = description;
                tag.Address     = address;
                tag.ScanTime    = scantime;
                tag.OnOffScan   = onoffscan;
                tag.Driver      = driver;
                db.SaveChanges();
                DataManipulator.saveData();

                TagProcessing.DItags.Remove(tag.Id);
                TagProcessing.DItags.Add(tag.Id, tag);
                TagProcessing.DIthreads.Remove(tag.Id);
                TagProcessing.DIthreads.Add(tag.Id, new Thread(() => TagProcessing.readAI(tag.Id)));
                TagProcessing.DIthreads[tag.Id].Start();

                onChangeNotification.Invoke("Operation succesful.");
            }
        }
Ejemplo n.º 13
0
        public void addUpdateDO(string operation, string id, string description, string address, double initval)
        {
            int initvalue = 0;

            if (initval > 0.5)
            {
                initvalue = 1;
            }
            lock (db.DOs)
            {
                if (operation == "add")
                {
                    DO novi = new DO(id, description, address, initvalue);
                    db.DOs.Add(novi);
                    db.SaveChanges();
                    DataManipulator.saveData();
                    return;
                }
                DO tag = getByIdDO(id);
                tag.Description = description;
                tag.Address     = address;
                tag.InitValue   = initvalue;
                db.SaveChanges();
                DataManipulator.saveData();
                onChangeNotification.Invoke("Operation succesful.");
            }
        }
Ejemplo n.º 14
0
        private void Inst_Swc1(MipsInstruction inst)
        {
            if (!CheckCop1Usable())
            {
                CauseException = ExceptionCode.CopUnstable;
                return;
            }

            if (!CheckEvenOddAllowed(inst.Ft))
            {
                return;
            }

            Int64  address = ComputeAddress(inst);
            UInt32 word    = 0;

            if (MipsState.CP0Regs.StatusReg.AdditionalFPR)
            {
                /* Store the hi word ? */
                word = (UInt32)(MipsState.Fpr.ReadFPRUnsigned(inst.Ft) >> 32);
            }
            else
            {
                word = MipsState.Fpr.ReadFPR32Unsigned(inst.Ft);
            }

            DataManipulator.Store(address, word);
        }
Ejemplo n.º 15
0
 /// <summary>
 ///     Initialize current properties for the site
 /// </summary>
 public CurrentProvider()
 {
     Person           = new Person();
     User             = new User();
     RequestBuilder   = new QBuilder();
     DataManipulation = new DataManipulator();
 }
Ejemplo n.º 16
0
        public void removeTagAlarm(string tagid, string id)
        {
            lock (db)
            {
                Alarm a = getAlarmById(id);
                if (a == null)
                {
                    onChangeNotification.Invoke("This alarm does not exist");
                    return;
                }
                AI tag = getByIdAI(a.AnalogTagId);
                if (tagid != tag.Id)
                {
                    onChangeNotification.Invoke("This alarm does not belong to chosen tag.");
                    return;
                }

                tag.Alarms.Remove(a);
                db.Alarms.Remove(a);

                db.SaveChanges();
                DataManipulator.saveData();
                onChangeNotification.Invoke("Alarm removed succesfully.");
            }
        }
Ejemplo n.º 17
0
        private void Inst_Lhu(MipsInstruction inst)
        {
            try
            {
                Int64 address = ComputeAddress(inst);

                if ((address & 1) != 0)
                {
                    CauseException = ExceptionCode.AddressErrorLoad;
                    return;
                }

                if (!MipsState.Operating64BitMode)
                {
                    MipsState.WriteGPR32Unsigned(inst.Rt, DataManipulator.LoadHalfwordUnsigned(address));
                }
                else
                {
                    MipsState.WriteGPRUnsigned(inst.Rt, DataManipulator.LoadHalfwordUnsigned(address));
                }
            }
            catch (TLBException tlbe)
            {
                switch (tlbe.ExceptionType)
                {
                case TLBExceptionType.Invalid: CauseException = ExceptionCode.Invalid; break;

                case TLBExceptionType.Mod: CauseException = ExceptionCode.TlbMod; break;

                case TLBExceptionType.Refill: CauseException = ExceptionCode.TlbStore; break;

                default: break;
                }
            }
        }
Ejemplo n.º 18
0
        protected override void Solve(out string answer)
        {
            DataManipulator manipulator = new DataManipulator();
            var             response    = manipulator.DoMagic();

            answer = string.Format("The first ten digits of the sum of the given one-hundred 50-digit numbers is: {0}",
                                   string.Concat(response.Take(10).Select(a => a.digit.ToString()))
                                   );
        }
Ejemplo n.º 19
0
        public UserControl1()
        {
            InitializeComponent();


            DBConnect       connection = new DBConnect();
            DataManipulator movies     = new DataManipulator();

            for (int i = 0; i < movies.MovieList.Count; i++)
            {
                Image       img       = new Image();
                ImageClass  images    = new ImageClass();
                var         result    = movies.MovieList[i].Poster;
                Stream      StreamObj = new MemoryStream(result);
                BitmapImage BitObj    = new BitmapImage();
                BitObj.BeginInit();
                BitObj.StreamSource = StreamObj;
                BitObj.EndInit();
                img.Source = BitObj;
                img.Height = 130;
                img.Width  = 130;
                img.HorizontalAlignment = HorizontalAlignment.Center;
                img.VerticalAlignment   = VerticalAlignment.Center;

                Label title   = new System.Windows.Controls.Label();
                Label rlsDate = new System.Windows.Controls.Label();
                Label genre   = new System.Windows.Controls.Label();
                Label lng     = new System.Windows.Controls.Label();
                Label rnTime  = new System.Windows.Controls.Label();
                Label price   = new System.Windows.Controls.Label();


                title.Content   = "Title: " + movies.MovieList[i].Title;
                rlsDate.Content = "Realise date: " + movies.MovieList[i].Releasedate;
                genre.Content   = "Genre: " + movies.MovieList[i].Genre;
                lng.Content     = "Language: " + movies.MovieList[i].Language;
                rnTime.Content  = "Runtime: " + movies.MovieList[i].Runtime;
                price.Content   = "Price: " + movies.MovieList[i].Price;

                DockPanel dock = new System.Windows.Controls.DockPanel();
                dock.Height = 200;
                Category.Children.Add(dock);
                dock.Children.Add(img);
                StackPanel newstack = new System.Windows.Controls.StackPanel();
                newstack.VerticalAlignment = VerticalAlignment.Center;
                title.FontSize             = 20;

                dock.Children.Add(newstack);
                newstack.Children.Add(title);
                newstack.Children.Add(genre);
                newstack.Children.Add(price);
                newstack.Children.Add(rlsDate);
                newstack.Children.Add(lng);
                newstack.Children.Add(rnTime);
                newstack.Children.Add(new Separator());
            }
        }
Ejemplo n.º 20
0
        public static void Main(String[] args)
        {
            DataManipulator dm = new DataManipulator();

            decimal[] closings = dm.GetListOfDailyClosingPrices("AMD", 100);
            Console.WriteLine(StockMath.VolatilityPriceChanges(closings) + "%");
            Console.WriteLine(StockMath.FormattedVolatilityPriceChangesFromTicker("AMD", 100));
            Console.WriteLine(StockMath.FormattedVolatilityPriceChangesFromTicker("GS", 100));
            Console.Read();
        }
Ejemplo n.º 21
0
        private void Inst_Swr(MipsInstruction inst)
        {
            /* Thanks to PJ64 */
            Int64  address = ComputeAddress(inst);
            Int32  offset  = (Int32)(address & 3);
            UInt32 value   = DataManipulator.LoadWordUnsigned(address & ~3);

            value &= SWRMask[offset];
            value += MipsState.ReadGPR32Unsigned(inst.Rt) << SWRShift[offset];
            DataManipulator.Store(address & ~3, value);
        }
Ejemplo n.º 22
0
 public void deleteDO(string id)
 {
     lock (db.DOs)
     {
         DO tag = getByIdDO(id);
         db.DOs.Remove(tag);
         db.SaveChanges();
         DataManipulator.saveData();
         onChangeNotification.Invoke("Operation succesful.");
     }
 }
Ejemplo n.º 23
0
        private void Inst_Sh(MipsInstruction inst)
        {
            Int64 address = ComputeAddress(inst);

            if ((address & 1) != 0)
            {
                CauseException = ExceptionCode.AddressErrorStore;
                return;
            }

            DataManipulator.Store(address, (UInt16)MipsState.ReadGPRUnsigned(inst.Rt));
        }
Ejemplo n.º 24
0
 public void deleteDI(string id)
 {
     lock (db.DIs)
     {
         DI tag = getByIdDI(id);
         db.DIs.Remove(tag);
         TagProcessing.AItags.Remove(id);
         TagProcessing.AIthreads.Remove(id);
         db.SaveChanges();
         DataManipulator.saveData();
         onChangeNotification.Invoke("Operation succesful.");
     }
 }
Ejemplo n.º 25
0
        private void Inst_Sw(MipsInstruction inst)
        {
            Int64 address = ComputeAddress(inst);

            if ((address & 3) != 0)
            {
                CauseException = ExceptionCode.AddressErrorStore;
            }
            else
            {
                DataManipulator.Store(address, MipsState.ReadGPR32Unsigned(inst.Rt));
            }
        }
        public void TestDailyCloses(int n)
        {
            DataManipulator dm = new DataManipulator();

            var a = dm.GetListOfDailyClosingPrices("GS", n);

            var content = new WebConnection().GetDailyStockDataFromTicker("GS", n);
            var info    = dm.GetStockInfoArrayGivenRawString(content);
            var pairs   = dm.GetDayInfoFromStrings(info);

            var b = dm.GetListOfDailyClosingPrices(pairs);

            Assert.AreEqual(a, b);
        }
Ejemplo n.º 27
0
 /// <summary>
 ///     Initialize current provider for the site (make a full copy)
 /// </summary>
 /// <param name="copiedProvider">Source for the copy</param>
 public CurrentProvider
 (
     CurrentProvider copiedProvider
 )
 {
     Person = new Person
              (
         copiedProvider.Person
              );
     User = new User
            (
         copiedProvider.User
            );
     RequestBuilder   = new QBuilder();
     DataManipulation = new DataManipulator();
 }
Ejemplo n.º 28
0
 private void Inst_Ldr(MipsInstruction inst)
 {
     if (MipsState.Operating64BitMode)
     {
         /* Thanks to PJ64 Implementation */
         Int64  address = ComputeAddress(inst);
         Int32  offset  = (Int32)(address & 7);
         UInt64 value   = DataManipulator.LoadDoublewordUnsigned(address & ~7);
         MipsState.WriteGPRUnsigned(inst.Rt, MipsState.ReadGPRUnsigned(inst.Rt) & LDRMask[offset]);
         MipsState.WriteGPRUnsigned(inst.Rt, MipsState.ReadGPRUnsigned(inst.Rt) + (value >> LDRShift[offset]));
     }
     else
     {
         CauseException = ExceptionCode.ReservedInstruction;
     }
 }
Ejemplo n.º 29
0
 private void Inst_Sdr(MipsInstruction inst)
 {
     if (MipsState.Operating64BitMode)
     {
         /* Thanks to PJ64 implementation */
         Int64  address = ComputeAddress(inst);
         Int32  offset  = (Int32)(address & 7);
         UInt64 value   = DataManipulator.LoadDoublewordUnsigned(address & ~7);
         value &= SDRMask[offset];
         value += MipsState.ReadGPRUnsigned(inst.Rt) << SDLShift[offset];
         DataManipulator.Store(address & ~7, value);
     }
     else
     {
         CauseException = ExceptionCode.ReservedInstruction;
     }
 }
Ejemplo n.º 30
0
 public void changeValueAO(string id, double value)
 {
     lock (db.AOs)
     {
         AO tag = getByIdAO(id);
         foreach (AO t in db.AOs)
         {
             if (t.Address == tag.Address)
             {
                 t.InitValue = value;
             }
         }
         db.SaveChanges();
         DataManipulator.saveData();
         onChangeNotification.Invoke("Value changed.");
     }
 }