예제 #1
0
    public void CheckInput(ControlObject controlObject)
    {
        if (controlObject.menuRight)
        {
            ChangeModule(true);
        }
        if (controlObject.menuLeft)
        {
            ChangeModule(false);
        }
        if (controlObject.menuUp)
        {
            ChangeTier(true);
        }
        if (controlObject.menuDown)
        {
            ChangeTier(false);
        }

        if (controlObject.jump)
        {
            printDrivePort.SendPrintSignal(currentIndex);
        }

        if (controlObject.interact)
        {
            printDrivePort.RemovePrintDrive();
        }
    }
예제 #2
0
        protected override void UpdateControlObject()
        {
            base.UpdateControlObject();

            Fold();

            numericY.Visible = ControlObject.Type == "float2" || ControlObject.Type == "float3" || ControlObject.Type == "float4";
            numericZ.Visible = ControlObject.Type == "float3" || ControlObject.Type == "float4";
            numericA.Visible = ControlObject.Type == "float4";

            labelUIName.Text = ControlObject.GetControlObject("UIName")?.Value ?? ControlObject.Name;
            toolTip.SetToolTip(labelUIName, ControlObject.GetControlObject("UIHelp")?.Value);

            numericX.Maximum = Convert.ToDecimal(UIMaxX);
            numericY.Maximum = Convert.ToDecimal(UIMaxY);
            numericZ.Maximum = Convert.ToDecimal(UIMaxZ);
            numericA.Maximum = Convert.ToDecimal(UIMaxA);

            numericX.Minimum = Convert.ToDecimal(UIMinX);
            numericY.Minimum = Convert.ToDecimal(UIMinY);
            numericZ.Minimum = Convert.ToDecimal(UIMinZ);
            numericA.Minimum = Convert.ToDecimal(UIMinA);

            numericX.Increment = numericX.Maximum * 0.005m >= 0.01m ? numericX.Maximum * 0.005m : 0.01m;
            numericY.Increment = numericY.Maximum * 0.005m >= 0.01m ? numericY.Maximum * 0.005m : 0.01m;
            numericZ.Increment = numericZ.Maximum * 0.005m >= 0.01m ? numericZ.Maximum * 0.005m : 0.01m;
            numericA.Increment = numericA.Maximum * 0.005m >= 0.01m ? numericA.Maximum * 0.005m : 0.01m;

            numericX.Value = Convert.ToDecimal(ValueX);
            numericY.Value = Convert.ToDecimal(ValueY);
            numericZ.Value = Convert.ToDecimal(ValueZ);
            numericA.Value = Convert.ToDecimal(ValueA);
        }
 private async void BackButtonPress(Object sender, BackPressedEventArgs e)
 {
     e.Handled = true;
     if (_inspectionStarted)
     {
         ErrorWarningMessage message = new ErrorWarningMessage();
         if (await message.ReturnPageWarning(_localSettings.Values["Language"].ToString()) == "Ok")
         {
             int           itemIndex = _stepCounter - 2;
             ControlAnswer answer    = _answers[itemIndex];
             _controlQuestion = _questionList[itemIndex];
             if (itemIndex == 0)
             {
                 //_inspectionStarted = false;
                 _answers = new List <ControlAnswer>();
             }
             else
             {
                 _answers.RemoveAt(_stepCounter);
             }
             _stepCounter -= 1;
             ControlObject controlObject = new ControlObject(_controlQuestion, answer);
             this.Frame.Navigate(typeof(CommentPage), controlObject);
         }
     }
     else
     {
         if (Frame.CanGoBack)
         {
             this.NavigationCacheMode = NavigationCacheMode.Disabled;
             Frame.GoBack();
         }
     }
 }
    public void EnableObjectControlUIPanel()
    {
        ControlObject model = GameObject.Find(fileNameWithoutExtension).GetComponent <ControlObject>();

        model.ShowObject();
        objectControlUIPanel.SetActive(true);
    }
 /// <summary>
 /// Invoked when this page is about to be displayed in a Frame.
 /// </summary>
 /// <param name="e">Event data that describes how this page was reached.
 /// This parameter is typically used to configure the page.</param>
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     _controlObject         = e.Parameter as ControlObject;
     btnCapture.Content     = _localSettings.Values["Language"].ToString() == "nl" ? "Neem foto" : "Prenez une photo";
     btnNextCapture.Content = _localSettings.Values["Language"].ToString() == "nl" ? "Volgende foto" : "Prochaine photo";
     btnCaptureOk.Content   = _localSettings.Values["Language"].ToString() == "nl" ? "Volgende vraag" : "Prochaine question";
     StartCamera();
 }
예제 #6
0
        public CustomAction([NotNull] ControlObject control, [NotNull] ElementScope scope, [NotNull] string name, [NotNull] Action <ElementScope> action)
            : base(control, scope)
        {
            ArgumentUtility.CheckNotNullOrEmpty("name", name);
            ArgumentUtility.CheckNotNull("action", action);

            _name   = name;
            _action = action;
        }
 void OnClickMoveForward()
 {
     if (!buttonPressed)
     {
         ControlObject model = GameObject.Find(fileNameWithoutExtension).GetComponent <ControlObject>();
         model.TranslateObject((Vector3.forward * 0.01f) * inputSpeedModifier);
         buttonPressed = true;
     }
 }
 void OnClickRotateRight()
 {
     if (!buttonPressed)
     {
         ControlObject model = GameObject.Find(fileNameWithoutExtension).GetComponent <ControlObject>();
         model.RotateObject((Vector3.down * 1.0f) * inputSpeedModifier);
         buttonPressed = true;
     }
 }
        protected void HandleDoubleClick(object sender, MouseButtonEventArgs e)
        {
            ListBoxItem   li = e.Source as ListBoxItem;
            ControlObject o  = li.Content as ControlObject;

            //Aaron 02/10/2012
            //Commented the line below
            //txtCommand.Text.Se += "{" + o.Name + "}";
            //Added the line below to add text to the cursor
            txtCommand.Text = txtCommand.Text.Insert(txtCommand.SelectionStart, "{{" + o.Name + "}}");
        }
 void OnClickUnitScaleMicrometer()
 {
     if (!buttonPressed)
     {
         ControlObject model = GameObject.Find(fileNameWithoutExtension).GetComponent <ControlObject>();
         model.SetScale(0.001f);
         buttonPressed = true;
         DisableObjectUnitScaleUIPanel();
         EnableObjectControlUIPanel();
     }
 }
예제 #11
0
 /// <summary>
 /// Invoked when this page is about to be displayed in a Frame.
 /// </summary>
 /// <param name="e">Event data that describes how this page was reached.
 /// This parameter is typically used to configure the page.</param>
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     _controlObject  = e.Parameter as ControlObject;
     lblComment.Text = _localSettings.Values["Language"].ToString() == "nl"
         ? "Wenst u een opmerking te geven over:" + Environment.NewLine +
                       _controlObject.ControlQuestion.translations[0].question
         : "Voudriez-vous donner une remarque sur:" + Environment.NewLine +
                       _controlObject.ControlQuestion.translations[0].question;
     btnNext.Content = _localSettings.Values["Language"].ToString() == "nl"
         ? "Volgende vraag"
         : "Prochaine question";
 }
        private void btnOk_Nok_Click(object sender, RoutedEventArgs e)
        {
            _inspectionStarted = true;
            ControlAnswer controlAnswer = new ControlAnswer
            {
                controlQuestionId = _controlQuestion.id,
                startTime         = _startTimeQuestion.ToString("yyyy-MM-ddTHH:mm:sszzz"),
                testOk            = sender == btnOk
            };
            ControlObject controlObject = new ControlObject(_controlQuestion, controlAnswer);

            this.Frame.Navigate(typeof(PhotoPage), controlObject);
        }
예제 #13
0
        public FillWithAction(
            [NotNull] ControlObject control,
            [NotNull] ElementScope scope,
            [NotNull] string value,
            [NotNull] FinishInputWithAction finishInputWithAction)
            : base(control, scope)
        {
            ArgumentUtility.CheckNotNull("value", value);
            ArgumentUtility.CheckNotNull("finishInputWithAction", finishInputWithAction);

            _value = value;
            _finishInputWithAction = finishInputWithAction;
        }
 void OnClickScaleSmaller()
 {
     if (!buttonPressed)
     {
         if (scaleFactor > 0.05f)
         {
             scaleFactor           -= (0.05f * inputSpeedModifier);
             objectScaleUIText.text = "Scale: " + scaleFactor;
             ControlObject model = GameObject.Find(fileNameWithoutExtension).GetComponent <ControlObject>();
             model.ScaleObject(scaleFactor);
             buttonPressed = true;
         }
     }
 }
예제 #15
0
파일: Test.cs 프로젝트: zwinlu/libiec61850
        public void ControlHandler()
        {
            IedModel iedModel = ConfigFileParser.CreateModelFromConfigFile("../../model.cfg");

            DataObject spcso1 = (DataObject)iedModel.GetModelNodeByShortObjectReference("GenericIO/GGIO1.SPCSO1");

            Assert.IsNotNull(spcso1);

            int handlerCalled = 0;

            IedServer iedServer = new IedServer(iedModel);

            iedServer.SetControlHandler(spcso1, delegate(ControlAction action, object parameter, MmsValue ctlVal, bool test) {
                byte [] orIdent = action.GetOrIdent();

                string orIdentStr = System.Text.Encoding.UTF8.GetString(orIdent, 0, orIdent.Length);

                Assert.AreEqual("TEST1234", orIdentStr);
                Assert.AreEqual(OrCat.MAINTENANCE, action.GetOrCat());

                Assert.AreSame(spcso1, action.GetControlObject());

                handlerCalled++;
                return(ControlHandlerResult.OK);
            }, null);

            iedServer.Start(10002);

            IedConnection connection = new IedConnection();

            connection.Connect("localhost", 10002);

            ControlObject controlClient = connection.CreateControlObject("simpleIOGenericIO/GGIO1.SPCSO1");

            controlClient.SetOrigin("TEST1234", OrCat.MAINTENANCE);

            Assert.IsNotNull(controlClient);

            controlClient.Operate(true);

            connection.Abort();

            Assert.AreEqual(1, handlerCalled);

            iedServer.Stop();

            iedServer.Destroy();
        }
예제 #16
0
        /// <inheritdoc/>
        protected override async void OnPointerPressed(PointerPressedEventArgs e)
        {
            base.OnPointerPressed(e);
            IsSelected = true;
            var tabitem = (e.Source as ILogical).GetParentTOfLogical <AuraTabItem>(); // sets the source

            if (this.GetParentTOfLogical <AuraTabView>() != null & tabitem != null & CanBeDragged)
            {
                var n = new ControlObject(tabitem);
                await DragDrop.DoDragDrop(e, n, (DragDropEffects)3);

                Debug.WriteLine("Drag started");
                //PseudoClasses.Add(":dragging");
            }
            e.Handled = true;
        }
예제 #17
0
        public static void Main(string[] args)
        {
            IedConnection con = new IedConnection();

            string hostname;

            if (args.Length > 0)
            {
                hostname = args[0];
            }
            else
            {
                hostname = "localhost";
            }

            Console.WriteLine("Connect to " + hostname);

            try
            {
                con.Connect(hostname, 102);

                string objectReference = "IEDM1CPUBHKW/DRCC1.DERStr";

                ControlObject control = con.CreateControlObject(objectReference);

                ControlModel controlModel = control.GetControlModel();

                Console.WriteLine(objectReference + " has control model " + controlModel.ToString());

                if (!control.Operate(true))
                {
                    Console.WriteLine("operate failed!");
                }



                con.Abort();
            }
            catch (IedConnectionException e)
            {
                Console.WriteLine(e.Message);
            }
        }
예제 #18
0
        public void ControlHandler()
        {
            IedModel iedModel = ConfigFileParser.CreateModelFromConfigFile("../../model.cfg");

            DataObject spcso1 = (DataObject)iedModel.GetModelNodeByShortObjectReference("GenericIO/GGIO1.SPCSO1");

            Assert.IsNotNull(spcso1);

            int handlerCalled = 0;

            IedServer iedServer = new IedServer(iedModel);

            iedServer.SetControlHandler(spcso1, delegate(DataObject controlObject, object parameter, MmsValue ctlVal, bool test) {
                handlerCalled++;
                return(ControlHandlerResult.OK);
            }, null);

            iedServer.Start(10002);

            IedConnection connection = new IedConnection();

            connection.Connect("localhost", 10002);

            ControlObject controlClient = connection.CreateControlObject("simpleIOGenericIO/GGIO1.SPCSO1");

            Assert.IsNotNull(controlClient);

            controlClient.Operate(true);

            connection.Abort();

            Assert.AreEqual(1, handlerCalled);

            iedServer.Stop();

            iedServer.Destroy();
        }
예제 #19
0
        public static void Main(string[] args)
        {
            IedConnection con = new IedConnection();

            string hostname;

            if (args.Length > 0)
            {
                hostname = args[0];
            }
            else
            {
                hostname = "localhost";
            }

            Console.WriteLine("Connect to " + hostname);

            try
            {
                con.Connect(hostname, 102);

                /* direct control with normal security */
                string objectReference = "simpleIOGenericIO/GGIO1.SPCSO1";

                ControlObject control = con.CreateControlObject(objectReference);

                ControlModel controlModel = control.GetControlModel();

                Console.WriteLine(objectReference + " has control model " + controlModel.ToString());

                if (controlModel != ControlModel.CONTROL_MODEL_STATUS_ONLY)
                {
                    control.Operate(true);
                }

                if (!control.Operate(true))
                {
                    Console.WriteLine("operate failed!");
                }

                /* direct control with enhanced security */
                objectReference = "simpleIOGenericIO/GGIO1.SPCSO3";
                control         = con.CreateControlObject(objectReference);

                controlModel = control.GetControlModel();
                Console.WriteLine(objectReference + " has control model " + controlModel.ToString());

                if (controlModel == ControlModel.CONTROL_MODEL_DIRECT_ENHANCED)
                {
                    control.SetCommandTerminationHandler(commandTerminationHandler, null);

                    control.Operate(true);

                    Thread.Sleep(1000);
                }



                con.Abort();
            }
            catch (IedConnectionException e)
            {
                Console.WriteLine(e.Message);
            }
        }
예제 #20
0
 public CheckAction([NotNull] ControlObject control, [NotNull] ElementScope scope)
     : base(control, scope)
 {
 }
예제 #21
0
 /// <summary>
 /// Checks if the button is enabled and clicks the button.
 /// </summary>
 public void Click()
 {
     ControlObject.Click();
 }
예제 #22
0
        private static void commandTerminationHandler(Object parameter, ControlObject control)
        {
            LastApplError lastApplError = control.GetLastApplError();

            Console.WriteLine("HANDLER CALLED! " + lastApplError.addCause);
        }
예제 #23
0
        public static void Main(string[] args)
        {
            IedConnection con = new IedConnection();

            string hostname;

            if (args.Length > 0)
            {
                hostname = args[0];
            }
            else
            {
                hostname = "localhost";
            }

            Console.WriteLine("Connect to " + hostname);

            try
            {
                con.Connect(hostname, 102);

                /* direct control with normal security or SBO with normal security */
                string objectReference = "simpleIOGenericIO/GGIO1.SPCSO1";

                ControlObject control = con.CreateControlObject(objectReference);

                ControlModel controlModel = control.GetControlModel();

                Console.WriteLine(objectReference + " has control model " + controlModel.ToString());


                switch (controlModel)
                {
                case ControlModel.STATUS_ONLY:
                    Console.WriteLine("Control is status-only!");
                    break;

                case ControlModel.DIRECT_NORMAL:
                case ControlModel.DIRECT_ENHANCED:
                    if (!control.Operate(true))
                    {
                        Console.WriteLine("operate failed!");
                    }
                    else
                    {
                        Console.WriteLine("operated successfully!");
                    }
                    break;

                case ControlModel.SBO_NORMAL:
                case ControlModel.SBO_ENHANCED:

                    if (control.Select())
                    {
                        if (!control.Operate(true))
                        {
                            Console.WriteLine("operate failed!");
                        }
                        else
                        {
                            Console.WriteLine("operated successfully!");
                        }
                    }
                    else
                    {
                        Console.WriteLine("Select failed!");
                    }

                    break;
                }

                /* direct control with enhanced security */
                objectReference = "simpleIOGenericIO/GGIO1.SPCSO3";
                control         = con.CreateControlObject(objectReference);

                controlModel = control.GetControlModel();
                Console.WriteLine(objectReference + " has control model " + controlModel.ToString());

                if (controlModel == ControlModel.DIRECT_ENHANCED)
                {
                    control.SetCommandTerminationHandler(commandTerminationHandler, null);

                    control.Operate(true);

                    Thread.Sleep(1000);
                }

                con.Abort();
            }
            catch (IedConnectionException e)
            {
                Console.WriteLine(e.Message);
            }

            // release all resources - do NOT use the object after this call!!
            con.Dispose();
        }
예제 #24
0
        protected override void UpdateControlObject()
        {
            base.UpdateControlObject();

            if (ControlObject.Type == "float4")
            {
                enabledRows.Add(tableLayoutPanel.RowStyles[4]);
                enabledRows.Add(tableLayoutPanel.RowStyles[3]);
                enabledRows.Add(tableLayoutPanel.RowStyles[2]);
                enabledRows.Add(tableLayoutPanel.RowStyles[1]);
            }
            else if (ControlObject.Type == "float3")
            {
                tableLayoutPanel.RowStyles[4].Height = 0;

                enabledRows.Add(tableLayoutPanel.RowStyles[3]);
                enabledRows.Add(tableLayoutPanel.RowStyles[2]);
                enabledRows.Add(tableLayoutPanel.RowStyles[1]);
            }
            else if (ControlObject.Type == "float2")
            {
                tableLayoutPanel.RowStyles[4].Height = 0;
                tableLayoutPanel.RowStyles[3].Height = 0;

                enabledRows.Add(tableLayoutPanel.RowStyles[2]);
                enabledRows.Add(tableLayoutPanel.RowStyles[1]);
            }
            else if (ControlObject.Type == "float" || ControlObject.Type == "int")
            {
                tableLayoutPanel.RowStyles[4].Height = 0;
                tableLayoutPanel.RowStyles[3].Height = 0;
                tableLayoutPanel.RowStyles[2].Height = 0;

                enabledRows.Add(tableLayoutPanel.RowStyles[1]);
            }

            Fold();

            labelUIName.Image = IsColor ? Resources.color_swatch : null;
            labelUIName.Text  = $"{ControlObject.GetControlObject("UIName")?.Value ?? ControlObject.Name}";
            labelUIName.Update();
            toolTip.SetToolTip(labelUIName, ControlObject.GetControlObject("UIHelp")?.Value);

            trackX.Maximum = IsColor ? 100 : (int)(Convert.ToSingle(UIMaxX) * 100f);
            trackY.Maximum = IsColor ? 100 : (int)(Convert.ToSingle(UIMaxY) * 100f);
            trackZ.Maximum = IsColor ? 100 : (int)(Convert.ToSingle(UIMaxZ) * 100f);
            trackA.Maximum = IsColor ? 100 : (int)(Convert.ToSingle(UIMaxA) * 100f);

            trackX.Minimum = IsColor ? 0 : (int)(Convert.ToSingle(UIMinX) * 100f);
            trackY.Minimum = IsColor ? 0 : (int)(Convert.ToSingle(UIMinY) * 100f);
            trackZ.Minimum = IsColor ? 0 : (int)(Convert.ToSingle(UIMinZ) * 100f);
            trackA.Minimum = IsColor ? 0 : (int)(Convert.ToSingle(UIMinA) * 100f);

            trackX.LargeChange = ControlObject.Type == "int" ? 100 : (int)(trackX.Maximum * 0.05f);
            trackY.LargeChange = ControlObject.Type == "int" ? 100 : (int)(trackX.Maximum * 0.05f);
            trackZ.LargeChange = ControlObject.Type == "int" ? 100 : (int)(trackX.Maximum * 0.05f);
            trackA.LargeChange = ControlObject.Type == "int" ? 100 : (int)(trackX.Maximum * 0.05f);

            trackX.Value = (int)(Convert.ToSingle(ValueX) * 100f);
            trackY.Value = (int)(Convert.ToSingle(ValueY) * 100f);
            trackZ.Value = (int)(Convert.ToSingle(ValueZ) * 100f);
            trackA.Value = (int)(Convert.ToSingle(ValueA) * 100f);

            textX.Text = ValueX;
            textY.Text = ValueY;
            textZ.Text = ValueZ;
            textA.Text = ValueA;
        }
예제 #25
0
    public void CheckInput(ControlObject controlObject)
    {
        // Move
        if (snapping)
        {
            moveDirection = (controlObject.rightLeft * transform.right + controlObject.forwardBack * transform.forward).normalized;
        }
        else
        {
            moveDirection = (controlObject.rightLeft * transform.right + controlObject.forwardBack * transform.forward + controlObject.upDown * transform.up).normalized;
        }

        // Look/Rotate
        lookRotation += new Vector3(-controlObject.verticalLook, controlObject.horizontalLook, controlObject.roll);

        // Jump
        if (controlObject.jump && grounded)
        {
            Jump();
        }

        // Interact
        if (controlObject.interact)
        {
            RaycastHit?hit = GetComponentInChildren <PlayerCamera>().GetUsableTarget(useRange);
            if (hit != null && PlayerCamera.instance.checkForUsable)
            {
                hit.Value.collider.GetComponent <IUsable>().Use();
            }
        }

        // Shield Cells
        if (controlObject.chargeShieldCell && fuelSlot.connectedModule)
        {
            fuelSlot.connectedModule.GetComponent <FuelPack>().ChargeShields();
        }

        // Weapons
        if (controlObject.fire && weaponSlot.currentWeapon != null)
        {
            weaponSlot.currentWeapon.Fire();
        }
        if (controlObject.aim && weaponSlot.GetCurrentWeaponType() == GameTypes.PlayerWeaponType.MatterManipulator)
        {
            weaponSlot.GetComponentInChildren <MatterManipulator>().EquipFuelPack(fuelSlot);
        }
        if (controlObject.matterManipilator)
        {
            if ((weaponSlot.GetCurrentWeaponType() == GameTypes.PlayerWeaponType.MatterManipulator && !GetComponentInChildren <MatterManipulator>().IsHoldingObject()) ||
                weaponSlot.GetCurrentWeaponType() != GameTypes.PlayerWeaponType.MatterManipulator &&
                canEquip)
            {
                weaponSlot.SwitchWeapons();
            }
        }

        // TODO: REMOVE
        if (Input.GetKeyDown(KeyCode.L) && fuelSlot.connectedModule)
        {
            GetComponentInChildren <FuelPack>().AddFuel(500f);
        }
    }
예제 #26
0
 void Start()
 {
     currentInput = new ControlObject();
     LockMouse();
 }
예제 #27
0
            /// <exception cref="IedConnectionException">This exception is thrown if there is a connection or service error</exception>
            public ControlObject CreateControlObject(string objectReference)
            {
                ControlObject controlObject = new ControlObject (objectReference, connection, this);

                return controlObject;
            }
예제 #28
0
 private static void commandTerminationHandler(Object parameter, ControlObject control)
 {
     LastApplError lastApplError = control.GetLastApplError();
     Console.WriteLine("HANDLER CALLED! " + lastApplError.addCause);
 }
예제 #29
0
        protected override void UpdateControlObject()
        {
            ControlObject UIMax = ControlObject.GetControlObject("UIMax");

            if (UIMax != null)
            {
                switch (UIMax.Type)
                {
                case "int":
                case "float":
                    string[] value = parse(UIMax.Value);
                    if (value.Length >= 1)
                    {
                        _UIMaxX = value[0];
                        _UIMaxY = value[0];
                        _UIMaxZ = value[0];
                        _UIMaxA = value[0];
                    }
                    break;

                case "float2":
                    string[] float2 = parse(UIMax.Value);
                    if (float2.Length >= 2)
                    {
                        _UIMaxX = float2[0];
                        _UIMaxY = float2[1];
                    }
                    break;

                case "float3":
                    string[] float3 = parse(UIMax.Value);
                    if (float3.Length >= 3)
                    {
                        _UIMaxX = float3[0];
                        _UIMaxY = float3[1];
                        _UIMaxZ = float3[2];
                    }
                    break;

                case "float4":
                    string[] float4 = parse(UIMax.Value);
                    if (float4.Length >= 4)
                    {
                        _UIMaxX = float4[0];
                        _UIMaxY = float4[1];
                        _UIMaxZ = float4[2];
                        _UIMaxA = float4[3];
                    }
                    break;
                }
            }

            ControlObject UIMin = ControlObject.GetControlObject("UIMin");

            if (UIMin != null)
            {
                switch (UIMin.Type)
                {
                case "int":
                case "float":
                    string[] value = parse(UIMin.Value);
                    if (value.Length >= 1)
                    {
                        _UIMinX = value[0];
                        _UIMinY = value[0];
                        _UIMinZ = value[0];
                        _UIMinA = value[0];
                    }
                    break;

                case "float2":
                    string[] float2 = parse(UIMin.Value);
                    if (float2.Length >= 2)
                    {
                        _UIMinX = float2[0];
                        _UIMinY = float2[1];
                    }
                    break;

                case "float3":
                    string[] float3 = parse(UIMin.Value);
                    if (float3.Length >= 3)
                    {
                        _UIMinX = float3[0];
                        _UIMinY = float3[1];
                        _UIMinZ = float3[2];
                    }
                    break;

                case "float4":
                    string[] float4 = parse(UIMin.Value);
                    if (float4.Length >= 4)
                    {
                        _UIMinX = float4[0];
                        _UIMinY = float4[1];
                        _UIMinZ = float4[2];
                        _UIMinA = float4[3];
                    }
                    break;
                }
            }

            switch (ControlObject.Type)
            {
            case "int":
            case "float":
                string[] value = parse(ControlObject.Value);
                if (value.Length >= 1)
                {
                    _ValueX = value[0];
                    _ValueY = UIMinY;
                    _ValueZ = UIMinZ;
                    _ValueA = UIMinA;
                }
                break;

            case "float2":
                string[] float2 = parse(ControlObject.Value);
                if (float2.Length >= 2)
                {
                    _ValueX = float2[0];
                    _ValueY = float2[1];
                    _ValueZ = UIMinZ;
                    _ValueA = UIMinA;
                }
                break;

            case "float3":
                string[] float3 = parse(ControlObject.Value);
                if (float3.Length >= 3)
                {
                    _ValueX = float3[0];
                    _ValueY = float3[1];
                    _ValueZ = float3[2];
                    _ValueA = UIMinA;
                }
                break;

            case "float4":
                string[] float4 = parse(ControlObject.Value);
                if (float4.Length >= 4)
                {
                    _ValueX = float4[0];
                    _ValueY = float4[1];
                    _ValueZ = float4[2];
                    _ValueA = float4[3];
                }
                break;
            }

            string[] parse(string str)
            {
                Regex regex = new Regex(@"(float|float2|float3|float4|int)\((?<value>.*?)\)");

                if (regex.IsMatch(str))
                {
                    return(Regex.Replace(regex.Match(str).Groups["value"].Value, @"\s", "").Split(','));
                }

                return(new string[] { str, str, str, str }); //Length >= 4
            }
        }
예제 #30
0
        public ResultValueModel WriteCMD(string hostip, Int32 port, bool operate, string cmdaddress)
        {   //instance
            IedConnection con = new IedConnection();

            try
            {   //connection
                con.Connect(hostip, port);
                //create control object
                ControlObject control      = con.CreateControlObject(cmdaddress);
                ControlModel  controlModel = control.GetControlModel();
                //result variable
                dynamic ValueTuple = null;

                //validate control model type
                if (controlModel == ControlModel.DIRECT_ENHANCED)
                {
                    control.SetCommandTerminationHandler(commandTerminationHandler, null);
                    ValueTuple = control.Operate(operate);
                }
                else if (controlModel == ControlModel.DIRECT_NORMAL)
                {
                    control.SetCommandTerminationHandler(commandTerminationHandler, null);
                    ValueTuple = control.Operate(operate);
                }
                else if (controlModel == ControlModel.SBO_ENHANCED)
                {
                    //set handler
                    control.SetCommandTerminationHandler(commandTerminationHandler, null);
                    //set SynchroCheck
                    control.SetSynchroCheck(true);
                    //set InterlockCheck
                    control.SetInterlockCheck(true);
                    //validate  cmd select
                    if (control.SelectWithValue(true))
                    {
                        //operate  cmd
                        ValueTuple = control.Operate(operate);
                    }
                    else if (control.SelectWithValue(false))
                    {
                        //operate  cmd
                        ValueTuple = control.Operate(operate);
                    }
                    else if (control.Select())
                    {
                        //operate  cmd
                        ValueTuple = control.Operate(operate);
                    }
                    else
                    {
                        ValueTuple = "SBO cmd not selected!";
                        //insert logs into db
                        Submission dbinsert = new Submission
                        {
                            CreatedAt = DateTime.Now,
                            Content   = ValueTuple
                        };
                        _subSvc.Create(dbinsert);
                    }
                }
                else
                {
                    ValueTuple = "CMD type is not DIRECT_ENHANCED or DIRECT_NORMAL or SBO_ENHANCED kindly Check!";
                    //insert logs into db
                    Submission dbinsert = new Submission
                    {
                        CreatedAt = DateTime.Now,
                        Content   = ValueTuple
                    };
                    _subSvc.Create(dbinsert);
                }

                //con close
                con.Abort();

                //result
                Value_Result listresult = new Value_Result
                {
                    Address = cmdaddress,
                    Value   = ValueTuple,
                };
                ResultValueModel result = new ResultValueModel
                {
                    data         = listresult,
                    error        = false,
                    errormessage = null
                };
                //destroy instance
                con.Dispose();
                //result
                return(result);
            }
            catch (IedConnectionException e)
            {
                ResultValueModel result = new ResultValueModel()
                {
                    data         = null,
                    error        = true,
                    errormessage = e.Message.ToString()
                };
                //insert logs into db
                Submission dbinsert = new Submission
                {
                    CreatedAt = DateTime.Now,
                    Content   = e.Message.ToString()
                };
                _subSvc.Create(dbinsert);
                //destroy result
                con.Dispose();
                //result
                return(result);
            }
        }
예제 #31
0
            /// <exception cref="IedConnectionException">This exception is thrown if there is a connection or service error</exception>
            public ControlObject CreateControlObject(string objectReference)
            {
                ControlObject controlObject = new ControlObject(objectReference, connection);

                return(controlObject);
            }
예제 #32
0
    public void CheckInput(ControlObject controlObject)
    {
        // Toggle Power
        if (controlObject.jump && assistMode != GameTypes.AssistMode.Quantum)
        {
            if (powered)
            {
                TogglePower(false);
            }
            else if (!powered && FuelAvailable() && !busy)
            {
                TogglePower(true);
            }
        }

        if (powered)
        {
            if (FuelAvailable())
            {
                // Thruster control
                if (thrusters)
                {
                    switch (assistMode)
                    {
                    case GameTypes.AssistMode.NoAssist:
                        thrusters.SetThrottle(controlObject.forwardBack);
                        shipComputer.UpdateThrottleGauge(thrusters.GetThrottle());
                        fuelPack.DrainFuel(Mathf.Abs(thrusters.GetThrottle()) / thrusters.efficiency * Time.deltaTime);
                        break;

                    case GameTypes.AssistMode.Hover:
                        thrusters.SetThrottle(controlObject.forwardBack / 2f);
                        shipComputer.UpdateThrottleGauge(thrusters.GetThrottle());
                        fuelPack.DrainFuel(Mathf.Abs(thrusters.GetThrottle() / thrusters.efficiency * Time.deltaTime));
                        break;

                    case GameTypes.AssistMode.Astro:
                        thrusters.AdjustAstroThrottle(controlObject.forwardBack * astroThrottleSensitivity * Time.deltaTime);
                        shipComputer.UpdateThrottleGauge(thrusters.GetAstroThrottle());
                        fuelPack.DrainFuel(thrusters.GetAstroFuel() * Time.deltaTime);
                        break;
                    }
                }

                // Booster control
                if (boosters)
                {
                    Vector3 torque;
                    if (!freeLook)
                    {
                        torque = new Vector3(-controlObject.verticalLook, controlObject.horizontalLook * yawMultiplier, controlObject.roll);
                    }
                    else
                    {
                        torque = new Vector3(0f, 0f, controlObject.roll);
                    }

                    switch (assistMode)
                    {
                    case GameTypes.AssistMode.NoAssist:
                    case GameTypes.AssistMode.Astro:
                        boosters.SetThrottle(controlObject.rightLeft, controlObject.upDown, torque);
                        fuelPack.DrainFuel((Mathf.Abs(controlObject.rightLeft) + Mathf.Abs(controlObject.upDown)) / boosters.efficiency * Time.deltaTime);
                        if (assistMode == GameTypes.AssistMode.Astro)
                        {
                            fuelPack.DrainFuel(1f / thrusters.efficiency * Time.deltaTime);                                               // Idle burn rate
                        }
                        break;

                    case GameTypes.AssistMode.Hover:
                        boosters.SetThrottle(controlObject.rightLeft / 2f, controlObject.upDown / 2f, torque);
                        fuelPack.DrainFuel((Mathf.Abs(controlObject.rightLeft) / 2f + Mathf.Abs(controlObject.upDown)) / 2f / boosters.efficiency * Time.deltaTime);
                        fuelPack.DrainFuel(1f / boosters.efficiency * Time.deltaTime);     // Idle burn rate
                        break;
                    }
                }

                // Quantum Drive
                if (thrusters && boosters && quantumDrive)
                {
                    if (controlObject.quantumJump)
                    {
                        quantumDrive.PickTarget();
                    }

                    if (assistMode == GameTypes.AssistMode.Quantum && quantumDrive.IsJumping())
                    {
                        fuelPack.DrainFuel(1f / quantumDrive.efficiency * Time.deltaTime); // Quantum burn rate
                    }
                }

                shipComputer.UpdateFuelGauge(fuelPack.GetFuelPercentage());

                // Assist Modes
                if (controlObject.changeAssist)
                {
                    switch (assistMode)
                    {
                    case GameTypes.AssistMode.NoAssist:
                        ChangeAssistMode(previousAssistMode);
                        break;

                    case GameTypes.AssistMode.Hover:
                        if (boosters && thrusters)
                        {
                            ChangeAssistMode(GameTypes.AssistMode.Astro);
                        }
                        break;

                    case GameTypes.AssistMode.Astro:
                        ChangeAssistMode(GameTypes.AssistMode.Hover);
                        break;
                    }
                }
                if (controlObject.toggleAssist && assistMode != GameTypes.AssistMode.Quantum)
                {
                    if (assistMode != GameTypes.AssistMode.NoAssist)
                    {
                        previousAssistMode = assistMode;
                        ChangeAssistMode(GameTypes.AssistMode.NoAssist);
                    }
                    else
                    {
                        ChangeAssistMode(previousAssistMode);
                    }
                }

                // Speedometer
                shipComputer.UpdateSpeedometer(rb.velocity.magnitude, transform.InverseTransformDirection(rb.velocity).z < -0.5f);

                // Light
                if (controlObject.light)
                {
                    if (lightOn)
                    {
                        shipLight.TogglePower(false);
                        lightOn = false;
                    }
                    else
                    {
                        shipLight.TogglePower(true);
                        lightOn = true;
                    }
                }
            }
            else
            {
                TogglePower(false);
            }
        }
        else if (controlObject.interact && !busy)
        {
            StartCoroutine("ExitShip");
        }

        // Shield Cells
        if (controlObject.chargeShieldCell && fuelPack)
        {
            fuelPack.ChargeShields();
        }

        // Camera
        if (controlObject.aim)
        {
            if (freeLook)
            {
                freeLook = false;
            }
            else
            {
                freeLook = true;
            }
        }
        if (controlObject.changeCamera && !busy)
        {
            PlayerCamera.instance.TogglePerspective();
        }

        if (freeLook)
        {
            FreeLook(controlObject.horizontalLook, controlObject.verticalLook);
        }
        else
        {
            ResetCameraRig();
        }
    }