Exemple #1
0
    void Start()
    {
        //if (!SystemParams.Instance().enableStereo) return;

#if !UNITY_EDITOR
        screenType = (BlendType)Enum.Parse(typeof(BlendType), SystemParams.Instance().stereoType, true);
#endif

        switch (screenType)
        {
        case BlendType.Blend1X2:
            this.gameObject.AddComponent <Blend1X2>();
            break;

        case BlendType.Blend1X3:
            this.gameObject.AddComponent <Blend1X3>();
            break;

        case BlendType.Stereo1X2:
            break;

        case BlendType.Stereo1X3:
            break;

        case BlendType.Stereo2X2:
            break;
        }
    }
        public void Clone_ObjectsWith3Params_ReturnsFullObjectCopy()
        {
            SystemParams systemParams = GetDefaultWith3Params();

            SystemParams cloned = systemParams.Clone();

            Assert.AreEqual(cloned.Count, systemParams.Count);
            Assert.AreEqual(cloned.DisplayText[0], systemParams.DisplayText[0]);
            Assert.AreEqual(cloned.DisplayText[1], systemParams.DisplayText[1]);
            Assert.AreEqual(cloned.ImageIndex, systemParams.ImageIndex);
            Assert.AreEqual(cloned.IsFilled, systemParams.IsFilled);
            Assert.AreEqual(cloned.SaveAsLuaTable(string.Empty),
                            systemParams.SaveAsLuaTable(string.Empty));

            var systemParamArr       = (SystemParam[])systemParams.Items;
            var clonedSystemParamArr = (SystemParam[])cloned.Items;

            for (int i = 0; i < systemParamArr.Length; i++)
            {
                Assert.AreEqual(systemParamArr[i].Name,
                                clonedSystemParamArr[i].Name);
                Assert.AreEqual(systemParamArr[i].LuaName,
                                clonedSystemParamArr[i].LuaName);
                Assert.AreEqual(systemParamArr[i].Meter,
                                clonedSystemParamArr[i].Meter);
            }
        }
Exemple #3
0
 public BoardUnit(ILog logger, IDatabaseService dataService, SystemParams param)
 {
     this._boardInfo   = new BoardInfo();
     this._logger      = logger;
     this._param       = param;
     this._dataService = dataService;
 }
Exemple #4
0
        public static bool InterceptWith(this FrameworkElement element, FrameworkElement secondElement)
        {
            var point1 = element.PointToScreen(new Point(0, 0));
            var point2 = secondElement.PointToScreen(new Point(0, 0));

            var dpiX = SystemParams.GetDpiX();
            var dpiY = SystemParams.GetDpiY();

            point1.X = point1.X * 96.0 / dpiX;
            point1.Y = point1.Y * 96.0 / dpiY;

            point2.X = point2.X * 96.0 / dpiX;
            point2.Y = point2.Y * 96.0 / dpiY;

            var rect = new Rect
            {
                Location = new Point(point1.X, point1.Y),
                Size     = new Size(element.ActualWidth, element.ActualHeight)
            };

            var rect2 = new Rect
            {
                Location = new Point(point2.X, point2.Y),
                Size     = new Size(secondElement.ActualWidth, secondElement.ActualHeight)
            };

            var a = rect.IntersectsWith(rect2);


            return(a);
        }
        public void ImageIndex_EmptyObject_ParamsManagerIndex()
        {
            var systemParams = new SystemParams();

            Assert.AreEqual(systemParams.ImageIndex,
                            ImageIndexEnum.ParamsManager);
        }
Exemple #6
0
        private BoardUnit GetBoardUnit()
        {
            ILog        log        = MockIlog();
            DtService36 db         = new DtService36(@"Data Source=shg-l80005754\SQLEXPRESS;Initial Catalog=BMS36;Persist Security Info=True;User ID=sa;Password=cml@shg629;Pooling=False");
            FetchPlans  fetchplans = FetchPlans.Inst("");

            fetchplans.FetchPlansList(db);
            Dictionary <string, string> ports = new Dictionary <string, string>();

            ports["OvenPort"] = "COM1";
            ports["Floor1"]   = "COM1";
            ports["Floor2"]   = "COM2";
            ports["Floor3"]   = "COM3";
            ports["Floor4"]   = "COM4";
            ports["Floor5"]   = "COM5";
            ports["Floor6"]   = "COM6";
            ports["Floor7"]   = "COM7";
            ports["Floor8"]   = "COM8";
            ports["Floor9"]   = "COM9";
            ports["Floor10"]  = "COM10";
            BoardFactory factroy = new BoardFactory(log, fetchplans, ports);
            SystemParams param   = new SystemParams();
            BoardUnit    unit    = new BoardUnit(log, db, param);

            return(unit);
        }
        public void Count_DefaultObjectAddParams_ReturnsCountOfParams()
        {
            var          systemParams0Params     = new SystemParams();
            SystemParams systemParamsWith3Params = GetDefaultWith3Params();

            Assert.AreEqual(0, systemParams0Params.Count);
            Assert.AreEqual(3, systemParamsWith3Params.Count);
        }
Exemple #8
0
        private void TrayContextMenu_Activated(object sender, EventArgs e)
        {
            var mouseX = Control.MousePosition.X * 96 / SystemParams.GetDpiX();
            var mouseY = Control.MousePosition.Y * 96 / SystemParams.GetDpiY();

            Left = mouseX - ActualWidth < 0 ? mouseX : mouseX - ActualWidth;
            Top  = mouseY - ActualHeight < 0 ? mouseY : mouseY - ActualHeight;
        }
Exemple #9
0
    public static SystemParams Instance()
    {
        if (instance == null)
        {
            instance = new SystemParams();
        }

        return(instance);
    }
        public void SaveAsLuaTable_EmptyObject_ReturnsEmptyString(
            string prefix)
        {
            var systemParam = new SystemParams();

            string savedCode = systemParam.SaveAsLuaTable(prefix);

            Assert.IsEmpty(savedCode);
        }
Exemple #11
0
 public BoardManager(ILog logger, IDatabaseService dataService, IPosMapScheme posMapScheme, BoardFactory boardFactory, SystemParams param)
 {
     _Logger       = logger;
     _param        = param;
     _boardFactory = boardFactory;
     _dataService  = dataService;
     _posMapScheme = posMapScheme;
     _boardSet     = new List <BoardUnit>();
 }
        public void SetUpFromBaseTechObject_EmptyObject_Add3Params()
        {
            var          emptyDefaultParams = new SystemParams();
            SystemParams defaultWith3Params = GetDefaultWith3Params();

            emptyDefaultParams.SetUpFromBaseTechObject(defaultWith3Params);

            Assert.AreEqual(defaultWith3Params.Count, emptyDefaultParams.Count);
        }
        public void GetParam_EmptyObject_GetByNameOrLuaNameReturnsNull()
        {
            var systemParams = new SystemParams();

            SystemParam paramByName    = systemParams.GetParam("LuaName1");
            SystemParam paramByLuaName = systemParams.GetParam("Параметр 1");

            Assert.IsNull(paramByName);
            Assert.IsNull(paramByLuaName);
        }
        public void InsertCopy_EmptyObject_AddNotSystemParam()
        {
            var systemParams = new SystemParams();
            int expectedCountOfParameters = 0;

            var insertedItem = systemParams.InsertCopy(new SystemParams());

            Assert.IsNull(insertedItem);
            Assert.AreEqual(expectedCountOfParameters, systemParams.Count);
        }
Exemple #15
0
 public UnitManager(ILog logger, SystemParams param)
 {
     this.Log    = logger;
     this._param = param;
     Utility.Load(_targetFile, out _runList);
     if (_runList == null)
     {
         _runList = new List <Guid>();
     }
     _unitSet = new List <UnitEntry>();
 }
        public PriceCrossingSMA(IStockDataProvider dataProvider, ISystemDataLoader dataLoader,
                                ISlippage slippage, ICommission commission, ISystemExecutionLogger systemExecutionLogger)
        {
            _dataProvider          = dataProvider;
            _dataLoader            = dataLoader;
            _slippage              = slippage;
            _commission            = commission;
            _systemExecutionLogger = systemExecutionLogger;

            SystemParams.Set(PriceCrossingSMAParams.StockName, "");
            SystemParams.Set(PriceCrossingSMAParams.SMAPeriod, 20);
        }
        public void InsertCopy_EmptyObject_AddNewSystemParam()
        {
            var          systemParams            = new SystemParams();
            const string paramName               = "Параметр 1";
            var          systemParam             = new SystemParam(systemParams.GetIdx, paramName);
            const int    expectedParametersCount = 1;

            var insertedItem = systemParams.InsertCopy(systemParam);

            Assert.IsTrue(insertedItem.DisplayText[0].Contains(paramName));
            Assert.AreEqual(expectedParametersCount, systemParams.Count);
        }
        public void AddParam_EmptyObject_Add3Params()
        {
            var          emptyDefaultParams = new SystemParams();
            SystemParams defaultWith3Params = GetDefaultWith3Params();

            foreach (SystemParam sysPar in defaultWith3Params.Items)
            {
                emptyDefaultParams.AddParam(sysPar);
            }

            Assert.AreEqual(defaultWith3Params.Count, emptyDefaultParams.Count);
        }
Exemple #19
0
        public BBTrend(IStockDataProvider dataProvider, ISystemDataLoader dataLoader,
                       ISlippage slippage, ICommission commission, ISystemExecutionLogger systemExecutionLogger)
        {
            _dataProvider          = dataProvider;
            _dataLoader            = dataLoader;
            _slippage              = slippage;
            _commission            = commission;
            _systemExecutionLogger = systemExecutionLogger;

            SystemParams.Set(BBTrendParams.StockName, "");
            SystemParams.Set(BBTrendParams.BBPeriod, 20);
            SystemParams.Set(BBTrendParams.BBSigmaWidth, 2f);
        }
        public void DisplayText_ObjectWith3Params_ReturnsTextWithObjectsCount()
        {
            SystemParams systemParams        = GetDefaultWith3Params();
            var          expectedDisplayText = new string[]
            {
                $"Системные параметры ({systemParams.Count})",
                string.Empty
            };

            Assert.AreEqual(expectedDisplayText[0],
                            systemParams.DisplayText[0]);
            Assert.AreEqual(expectedDisplayText[1],
                            systemParams.DisplayText[1]);
        }
Exemple #21
0
    public void CopyFrom(SystemParams target)
    {
        Type targetType  = target.GetType();
        var  targetInfos = targetType.GetFields();

        Type thisType  = this.GetType();
        var  thisInfos = thisType.GetFields();

        for (int i = 0; i < thisInfos.Length; i++)
        {
            object v = Convert.ChangeType(targetInfos[i].GetValue(target), thisInfos[i].FieldType);
            thisInfos[i].SetValue(this, v);
        }
    }
Exemple #22
0
        private void TurnOffSidebarMode()
        {
            if (_appSettings.WindowPlacement != null)
            {
                var width = _appSettings.WindowPlacement.NormalPosition.Right -
                            _appSettings.WindowPlacement.NormalPosition.Left;
                Width = width * 96 / SystemParams.GetDpiX();
            }
            else
            {
                Width = DefaultWidth;
            }

            SaveWindowsPlacement();
        }
        public void GetParam_ObjectWithParam_GetByLuaNameOrNameReturnsParam()
        {
            var          systemParams = new SystemParams();
            const string paramName    = "Параметр 1";
            const string paramLuaName = "LuaName1";
            var          systemParam  = new SystemParam(systemParams.GetIdx,
                                                        paramName, 0, "шт", paramLuaName);

            systemParams.AddParam(systemParam);

            SystemParam paramByName    = systemParams.GetParam(paramName);
            SystemParam paramByLuaName = systemParams.GetParam(paramLuaName);

            Assert.AreEqual(systemParam, paramByName);
            Assert.AreEqual(systemParam, paramByLuaName);
        }
        public override void Prepare()
        {
            SignalsPriceCrossingSMA signals = new SignalsPriceCrossingSMA(
                SystemParams.Get(PriceCrossingSMAParams.StockName).As <string>(),
                StockData.Types.StockDataRange.Daily,
                SystemParams.Get(PriceCrossingSMAParams.SMAPeriod).As <int>(),
                _dataLoader, _dataProvider,
                new MMSignalVolumeForAllCash(_commission));

            _dataDefinitionProvider = signals;
            _signalGeneratorOnOpen  = null;
            _signalGeneratorOnClose = signals;
            //_commission = null;
            //_slippage = null;
            _mmPositionCloseCalculator = null;
        }
        public SimplexMultiFunds(IStockDataProvider dataProvider, ISystemDataLoader dataLoader,
                                 ISlippage slippage, ICommission commission, ISystemExecutionLogger systemExecutionLogger)
        {
            _dataProvider          = dataProvider;
            _dataLoader            = dataLoader;
            _slippage              = slippage;
            _commission            = commission;
            _systemExecutionLogger = systemExecutionLogger;

            SystemParams.Set(SimplexMultiFundsParams.AvgProfitRange, 3);
            SystemParams.Set(SimplexMultiFundsParams.AvgChangeRange, 6);
            SystemParams.Set(SimplexMultiFundsParams.AcceptableSingleDD, 0.1);
            SystemParams.Set(SimplexMultiFundsParams.RiskSigmaMultiplier, 2.0);
            SystemParams.Set(SimplexMultiFundsParams.MaxSinglePositionSize, 0.8);
            SystemParams.Set(SimplexMultiFundsParams.MaxPortfolioRisk, 0.8);
            SystemParams.Set(SimplexMultiFundsParams.TruncateBalanceToNthPlace, 3);
        }
Exemple #26
0
        public override void Prepare()
        {
            SignalsBBTrend signals = new SignalsBBTrend(
                SystemParams.Get(BBTrendParams.StockName).As <string>(),
                StockData.Types.StockDataRange.Daily,
                SystemParams.Get(BBTrendParams.BBPeriod).As <int>(),
                SystemParams.Get(BBTrendParams.BBSigmaWidth).As <float>(),
                _dataLoader, _dataProvider,
                new MMSignalVolumeOneItem());

            _dataDefinitionProvider = signals;
            _signalGeneratorOnOpen  = null;
            _signalGeneratorOnClose = signals;
            //_commission = null;
            //_slippage = null;
            _mmPositionCloseCalculator = null;
        }
Exemple #27
0
    //如果文件存在则读取文件
    private static void ReadConfig()
    {
        StreamReader sr    = new StreamReader(configPath);
        var          sjson = sr.ReadToEnd();
        SystemParams tps;

        try
        {
            tps = JsonUtility.FromJson <SystemParams>(sjson);
            SystemParams.Instance().CopyFrom(tps);
            sr.Close();
        }
        catch (Exception)
        {
            sr.Close();
            UpdateConfig();
        }
    }
Exemple #28
0
    //@brief 此处可重新创建config文件并将这些预设写入
    public static void UpdateConfig()
    {
        try
        {
            configPath = "/../config/config.txt";
            //获取文件路径
            configPath = string.Format("{0}{1}", Application.dataPath, configPath);

            if (File.Exists(configPath))
            {
                File.Delete(configPath);
            }

            FileStream   fs = new FileStream(configPath, FileMode.Create);
            StreamWriter sw = new StreamWriter(fs);

            var sjson = JsonUtility.ToJson(SystemParams.Instance());

            //将Json逐行写入配置文件
            var jsontowrite = sjson.Split(',');

            for (int i = 0; i < jsontowrite.Length; i++)
            {
                if (i != jsontowrite.Length - 1)
                {
                    sw.WriteLine(jsontowrite[i] + ",");
                }
                else
                {
                    sw.WriteLine(jsontowrite[i]);
                }
            }

            sw.Flush();
            sw.Close();
            fs.Close();
        }
        catch (IOException e)
        {
            Debug.Log(e);
        }
    }
        public void SaveAsLuaTable_ObjectWith3Params_ReturnsCodeLuaForSave(
            string prefix)
        {
            SystemParams systemParams = GetDefaultWith3Params();
            string       expectedCode = string.Empty;

            expectedCode += prefix + "system_parameters" + " =\n";
            expectedCode += prefix + "\t{\n";
            var systemParamArr = (SystemParam[])systemParams.Items;

            foreach (var systemParam in systemParamArr)
            {
                expectedCode += systemParam.SaveAsLuaTable(prefix + "\t");
            }
            expectedCode += prefix + "\t},\n";

            string savedCode = systemParams.SaveAsLuaTable(prefix);

            Assert.AreEqual(expectedCode, savedCode);
        }
Exemple #30
0
        public BoardManager(ILog logger, IDatabaseService dbService, IPosMapScheme posMapScheme, BoardFactory boardFactory, SystemParams param)
        {
            _Logger       = logger;
            _param        = param;
            _boardFactory = boardFactory;
            _posMapScheme = posMapScheme;

            Utility.Load(targetFile, out this._boardSet);
            if (this._boardSet == null)
            {
                this._boardSet = new List <BoardEntry>();
            }
            foreach (var entry in this._boardSet)
            {
                if (entry.Flag == BoardState.READY)
                {
                    ChangeBoardState(entry.BoardName, BoardState.LOADED);
                }
            }
            this._validBoardSet = new List <BoardEntry>();
        }