public void Create(long viewID, int w, int h, int d, ControllerParameters controlParams)
            {
                Debug.Assert(viewID > 0);
                Debug.Assert(w > 0 && h > 0 && d > 0);

                // Clean up first.
                Destroy();

                m_ViewID      = viewID;
                m_Textures    = new RenderTexture[k_NumBuffers];
                m_Identifiers = new RenderTargetIdentifier[k_NumBuffers];
                m_Params      = new Parameters[k_NumFrames];

                for (int i = 0; i < k_NumBuffers; i++)
                {
                    m_Textures[i]                   = new RenderTexture(w, h, 0, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Linear);
                    m_Textures[i].hideFlags         = HideFlags.HideAndDontSave;
                    m_Textures[i].filterMode        = FilterMode.Trilinear;   // Custom
                    m_Textures[i].dimension         = TextureDimension.Tex3D; // TODO: request the thick 3D tiling layout
                    m_Textures[i].volumeDepth       = d;
                    m_Textures[i].enableRandomWrite = true;
                    m_Textures[i].name              = CoreUtils.GetRenderTargetAutoName(w, h, RenderTextureFormat.ARGBHalf, String.Format("VBuffer{0}", i));
                    m_Textures[i].Create();

                    // TODO: clear the texture. Clearing 3D textures does not appear to work right now.

                    m_Identifiers[i] = new RenderTargetIdentifier(m_Textures[i]);
                }

                // Start with the same parameters for both frames. Then incrementally update them.
                Parameters parameters = new Parameters(w, h, d, controlParams);

                m_Params[0] = parameters;
                m_Params[1] = parameters;
            }
Example #2
0
    static void waitForGlobals(Controller myController)
    {
        //Set UserInteger0 to -1...
        ControllerParameters controllerParameters = myController.Parameters;

        controllerParameters.System.User.UserInteger0.Value = -1;
    }
                public Parameters(int w, int h, int d, ControllerParameters controlParams)
                {
                    resolution          = new Vector4(w, h, 1.0f / w, 1.0f / h);
                    sliceCount          = new Vector2(d, 1.0f / d);
                    depthEncodingParams = Vector4.zero; // C# doesn't allow function calls before all members have been init
                    depthDecodingParams = Vector4.zero; // C# doesn't allow function calls before all members have been init

                    Update(controlParams);
                }
                public void Update(ControllerParameters controlParams)
                {
                    float n = controlParams.vBufferNearPlane;
                    float f = controlParams.vBufferFarPlane;
                    float c = 2 - 2 * controlParams.depthSliceDistributionUniformity; // remap [0, 1] -> [2, 0]

                    depthEncodingParams = ComputeLogarithmicDepthEncodingParams(n, f, c);
                    depthDecodingParams = ComputeLogarithmicDepthDecodingParams(n, f, c);
                }
        public async Task <IControllerResult> Run(ControllerParameters parameters)
        {
            try {
                var questions = await QuestionsUseCase.List();

                return(new ListQuestionResult(true, "Question list retrieved", questions));
            } catch (Exception error) {
                return(new ListQuestionResult(false, error.Message, null));
            }
        }
        public void TestMethod()
        {
            ControllerParameters cParams = new ControllerParameters(0, 0, 0,
                                                                    new double[] { 0, 0 },
                                                                    new DateTime(1, 1, 1, 0, 0, 0),
                                                                    new DateTime(1, 1, 1, 0, 0, 30),
                                                                    1);
            PidController cont = new PidController(cParams, Transients);

            cont.SolveSimulation();
            ResultsToCsv(cont);
        }
Example #7
0
    /* static void updateGlobals(String[] commandStrings, Controller myController)
     * {
     *   for (int i = 0; i < 8; i++)
     *   {   //Update DGlobal parameters
     *       myController.Commands.Register.WriteDoubleGlobal(i, Convert.ToDouble(commandStrings[i+1]));
     *   }
     *
     *   //Update IGlobal parameter(s)
     *   myController.Commands.Register.WriteIntegerGlobal(0, Convert.ToInt32(commandStrings[9]));
     *
     *   //Set UserInteger0 to 1...
     *   ControllerParameters controllerParameters = myController.Parameters;
     *   controllerParameters.System.User.UserInteger0.Value = 1;
     *
     *   //pause 1000 ms to sync
     *   //System.Threading.Thread.Sleep(1000);
     *
     * }*/

    static void updateGlobals(String[] commandStrings, Controller myController)
    {
        for (int i = 0; i < commandStrings.Length - 2; i++)
        {   //Update DGlobal parameters
            myController.Commands.Register.WriteDoubleGlobal(i, Convert.ToDouble(commandStrings[i + 1]));
        }

        //Update IGlobal parameter(s)
        myController.Commands.Register.WriteIntegerGlobal(0, Convert.ToInt32(Convert.ToDouble(commandStrings[commandStrings.Length - 1])));

        //Set UserInteger0 to 1...
        ControllerParameters controllerParameters = myController.Parameters;

        controllerParameters.System.User.UserInteger0.Value = 1;

        //pause 1000 ms to sync
        //System.Threading.Thread.Sleep(1000);
    }
Example #8
0
        public static async Task Run(IContainer container, ConsoleUser?user)
        {
            // Create the scope, resolve your IDateWriter,
            // use it, then dispose of the scope.
            using (var scope = container.BeginLifetimeScope())
            {
                var api   = scope.Resolve <ConsoleApi>();
                var ctrl  = scope.Resolve <ListQuestion>(); //new CreateQuestion();
                var param = new ControllerParameters();

                Console.WriteLine("Sending");
                var res = (ListQuestionResult)await api.Run(ctrl, param);

                Console.WriteLine($"> {res.Message}");
                Console.WriteLine($"> {res.Present()}");
                Console.WriteLine("");
            }
        }
        public async Task <IControllerResult> Run(ControllerParameters parameters)
        {
            try {
                if (!(parameters is ViewQuestionParameters))
                {
                    throw new Exception("Invalid parameters");
                }

                var param    = (ViewQuestionParameters)parameters;
                var question = await QuestionsUseCase.View(param.QuestionId);

                if (question == null)
                {
                    throw new Exception("Question not found");
                }

                return(new ViewQuestionResult(true, "Question retrieved", question));
            } catch (Exception error) {
                return(new ViewQuestionResult(false, error.Message, null));
            }
        }
        public async Task <IControllerResult> Run(User user, ControllerParameters parameters)
        {
            try {
                if (!(parameters is CreateQuestionParameters))
                {
                    throw new Exception("Invalid parameters");
                }

                var param = (CreateQuestionParameters)parameters;

                Question question        = new Question(param.Title, param.Message, user);
                var      createdQuestion = await QuestionsUseCase.Create(question);

                if (createdQuestion == null)
                {
                    return(new CreateQuestionResult(false, "Something went wrong while creating your question.", null));
                }

                return(new CreateQuestionResult(true, "Question created", createdQuestion));
            } catch (Exception error) {
                return(new CreateQuestionResult(false, error.Message, null));
            }
        }
Example #11
0
    public void OnTriggerExit2D(Collider2D other)
    {
        var parameters = other.gameObject.GetComponent<ControllerPhysicsVolume2D> ();

        if (parameters == null)
            return;

        _overrideParameters = null;
    }
Example #12
0
        public async Task <IControllerResult> Run(IAuthenticatedController controller, ControllerParameters parameters, ConsoleUser?user)
        {
            if (!(this.Authenticator is BasicAuth))
            {
                throw new Exception("Unsuportted authenticator for ConsoleAPI");
            }

            if (user == null)
            {
                throw new Exception("Must be authenticated");
            }

            var auth = (BasicAuth)this.Authenticator;

            auth.SetCredentials(user.Username, user.Password);

            var authenticatedUser = await auth.Authenticate();

            if (authenticatedUser == null)
            {
                throw new Exception("Invalid username/passowrd");
            }

            var result = await controller.Run(authenticatedUser, parameters);;

            return(result);
        }
Example #13
0
        public async Task <IControllerResult> Run(IController controller, ControllerParameters parameters)
        {
            var result = await controller.Run(parameters);

            return(result);
        }
Example #14
0
        public MainWindow()
        {
            InitializeComponent();
            ////Application Icon for tray.

            TrayMenu = Resources["TrayMenu"] as System.Windows.Controls.ContextMenu;
            ni       = new NotifyIcon();
            string path = AppDomain.CurrentDomain.BaseDirectory;

            ni.Icon         = new System.Drawing.Icon(@"Source\Main.ico");
            ni.Visible      = true;
            ni.DoubleClick +=
                delegate(object sender, EventArgs args)
            {
                if ((args as MouseEventArgs).Button == MouseButtons.Left)
                {
                    // по левой кнопке показываем или прячем окно
                    this.Show();
                    this.WindowState = WindowState.Normal;
                }
            };

            ni.Click += delegate(object sender, EventArgs args)
            {
                if ((args as MouseEventArgs).Button == MouseButtons.Right)
                {
                    // по правой кнопке (и всем остальным) показываем меню
                    TrayMenu.IsOpen = true;
                    Activate(); // нужно отдать окну фокус, см. ниже
                }
            };


            //Creating User Interfaces
            opcSettingsUC = new OPCServerSettingsUC {
                isEnableWritingChecked = true
            };
            dataAccessSettingsUC    = new DataAccessSettingsUC();
            parametersUC            = new ParametersUC();
            serverSynchronizationUC = new ServerSynchronizationUC();
            logUC = new LogUC();


            //При запуске приложения проверяется роль хоста (чтение IP из БД). Если при старте компьютера
            //приложение стучится к БД раньше, чем запустится SQL сервер, будет произведена попытка прочитать роль еще раз
            //(кол-во попыток - в теле конструкции 'for')

            Task.Run(() =>
            {
                for (int i = 0; i < 5; i++)
                {
                    controllerRole = DefineHostRole();
                    Dispatcher.Invoke(() => serverSynchronizationUC.ServerSyncRoleTextBox.Text = controllerRole.ToString());
                    if (controllerRole != HostRole.ERROR)
                    {
                        break;
                    }
                    WriteToLog("Attempt to define Server role. Reading from DataBase failed!");
                    Thread.Sleep(2000);
                }
            }).ContinueWith((o) =>
            {
                //Создаем класс-контейнер для хранения параметров для передачи в контроллер перед началом расчетов
                controllerParameters = new ControllerParameters
                {
                    isEnableWriting     = opcSettingsUC.isEnableWritingChecked,
                    ControllerRole      = this.controllerRole,
                    OpcServerName       = Properties.Settings.Default.OPCServerName,
                    OpcServerSubstring  = Properties.Settings.Default.OPCServerSubString,
                    SingleTagNamesForRW = serverSynchronizationUC.singleTagNamesForRW
                };

                //Start Calculations after launching
                if (controllerRole != HostRole.ERROR)
                {
                    Task.Run(async() => await StartOperation());
                }
                else
                {
                    WriteToLog("Невозможно определить хост-роль сервера");
                }
            });
        }