コード例 #1
0
ファイル: Config.cs プロジェクト: mbhul/RoboCOM
        private void ParseControllerConfig(XmlNode configRoot)
        {
            int temp_mapping = 0;

            for (int i = 0; i < (int)ChannelNumber.NUM_CHANNELS; i++)
            {
                channel_config[i] = new ChannelConfigValues();
                inputMapping[i]   = new ControllerProperty();

                temp_mapping    = int.Parse(configRoot.SelectNodes(String.Format(".//Channel[@param='{0}']", StringEnum.GetStringValue((ChannelNumber)i))).Item(0).Attributes["map"].Value);
                inputMapping[i] = (ControllerProperty)Math.Abs(temp_mapping);
                if (temp_mapping < 0)
                {
                    inputInverted[i] = true;
                }

                channel_config[i].MIN    = double.Parse(configRoot.SelectNodes(String.Format(".//Channel[@param='{0}']", StringEnum.GetStringValue((ChannelNumber)i))).Item(0).Attributes["min"].Value);
                channel_config[i].MAX    = double.Parse(configRoot.SelectNodes(String.Format(".//Channel[@param='{0}']", StringEnum.GetStringValue((ChannelNumber)i))).Item(0).Attributes["max"].Value);
                channel_config[i].CENTER = double.Parse(configRoot.SelectNodes(String.Format(".//Channel[@param='{0}']", StringEnum.GetStringValue((ChannelNumber)i))).Item(0).Attributes["default"].Value);

                precisionFormat[i] = configRoot.SelectNodes(String.Format(".//Channel[@param='{0}']", StringEnum.GetStringValue((ChannelNumber)i))).Item(0).Attributes["precision"].Value;
                channelGain[i]     = double.Parse(configRoot.SelectNodes(String.Format(".//Channel[@param='{0}']", StringEnum.GetStringValue((ChannelNumber)i))).Item(0).Attributes["gain"].Value);
                channelPrefix[i]   = configRoot.SelectNodes(String.Format(".//Channel[@param='{0}']", StringEnum.GetStringValue((ChannelNumber)i))).Item(0).InnerXml;
            }

            z_persist      = Boolean.Parse(configRoot.SelectNodes(String.Format(".//Channel[@param='{0}']", StringEnum.GetStringValue(ChannelNumber.CH1))).Item(0).Attributes["persist"].Value);
            z_accumulating = Boolean.Parse(configRoot.SelectNodes(String.Format(".//Channel[@param='{0}']", StringEnum.GetStringValue(ChannelNumber.CH1))).Item(0).Attributes["accum"].Value);

            chanSeparator     = configRoot.SelectNodes(".//ChannelSeparator").Item(0).InnerXml;
            stopCommand       = configRoot.SelectNodes(".//StopCommand").Item(0).InnerXml;
            cmdPrefixAbsolute = configRoot.SelectNodes(".//StartOfFrame[@type='absolute']").Item(0).InnerXml;
            cmdPrefixRelative = configRoot.SelectNodes(".//StartOfFrame[@type='relative']").Item(0).InnerXml;
        }
コード例 #2
0
 static public void DeselectPropertyPanel()
 {
     if (activeProperty != null)
     {
         activeProperty.Hide();
         activeProperty = null;
     }
 }
コード例 #3
0
ファイル: Config.cs プロジェクト: mbhul/RoboCOM
 private void InitArrays()
 {
     channel_config  = new ChannelConfigValues[(int)ChannelNumber.NUM_CHANNELS];
     inputMapping    = new ControllerProperty[(int)ChannelNumber.NUM_CHANNELS];
     precisionFormat = Enumerable.Repeat <String>("", (int)ChannelNumber.NUM_CHANNELS).ToArray();
     channelPrefix   = Enumerable.Repeat <String>("", (int)ChannelNumber.NUM_CHANNELS).ToArray();
     channelGain     = Enumerable.Repeat <double>(0.0, (int)ChannelNumber.NUM_CHANNELS).ToArray();
     inputInverted   = Enumerable.Repeat <bool>(false, (int)ChannelNumber.NUM_CHANNELS).ToArray();
 }
コード例 #4
0
        protected virtual void dragDrop(object sender, DragEventArgs e)
        {
            TreeNode      node       = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode");
            TagProperties properties = (TagProperties)node.Tag;

            property = (ControllerProperty)Activator.CreateInstance(properties.PropertyType);

            property.userController = this;
            property.SetPropertyName(node.FullPath.Replace("\\", " - "));

            PropertyPanelManager.SetPropertyPanel(property);
            UserControllerManager.Select(this);
            PropertyPanelManager.SetPropertyName();
            Refresh();
        }
コード例 #5
0
        /* Allows to change the property panel of which button active */
        static public void SetPropertyPanel(object sender)
        {
            if (activeProperty != null)
            {
                activeProperty.Hide();
            }

            if (sender == null)
            {
                defaultProperty.SetParents(propertyPanel);
                defaultProperty.Show();
                activeProperty = defaultProperty;
                return;
            }

            ControllerProperty property = (ControllerProperty)sender;

            property.SetParents(propertyPanel);
            property.Show();
            activeProperty = property;
        }
コード例 #6
0
ファイル: TextBoxBehavior.cs プロジェクト: atst1996/Liberfy
 set => this.SetValue(ControllerProperty, value);
コード例 #7
0
 get => (ShortcutController)GetValue(ControllerProperty); set => SetValue(ControllerProperty, value);
コード例 #8
0
 set => SetValue(ControllerProperty, value);
コード例 #9
0
ファイル: ConfigForm.cs プロジェクト: mbhul/RoboCOM
        /********************************************************************************
        * FUNCTION:        checkActiveInput
        * Description:
        * Parameters:      N/A
        ********************************************************************************/
        private void checkActiveInput()
        {
            JoystickState state;
            double        max_diff  = 0.25;
            double        temp_diff = 0.0;

            bool[] buttons;

            state         = activeController.getState();
            buttons       = state.GetButtons().ToArray();
            inputInverted = false;

            for (int i = 0; i < (int)ControllerProperty.NUM_BUTTONS; i++)
            {
                if (buttons[i] == true)
                {
                    activeInput   = (ControllerProperty)(ControllerProperty.Button_1 + i);
                    inputSelected = true;
                    return;
                }
            }

            //Check JoystickState X axis
            temp_diff = (double)Math.Abs(state.X - prev_x) / (double)full_scale;
            if (temp_diff > max_diff)
            {
                max_diff    = temp_diff;
                activeInput = ControllerProperty.X;

                if ((state.X - prev_x) < 0)
                {
                    inputInverted = true;
                }

                inputSelected = true;
            }

            //Check JoystickState Y axis
            temp_diff = (double)Math.Abs(state.Y - prev_y) / (double)full_scale;
            if (temp_diff > max_diff)
            {
                max_diff    = temp_diff;
                activeInput = ControllerProperty.Y;

                if ((state.Y - prev_y) < 0)
                {
                    inputInverted = true;
                }

                inputSelected = true;
            }

            //Check JoystickState Z axis
            temp_diff = (double)Math.Abs(state.Z - prev_z) / (double)full_scale;
            if (temp_diff > max_diff)
            {
                max_diff    = temp_diff;
                activeInput = ControllerProperty.Z;

                if ((state.Z - prev_z) < 0)
                {
                    inputInverted = true;
                }

                inputSelected = true;
            }

            //Check JoystickState X rotation
            temp_diff = (double)Math.Abs(state.RotationX - prev_rotation_x) / (double)full_scale;
            if (temp_diff > max_diff)
            {
                max_diff    = temp_diff;
                activeInput = ControllerProperty.RotationX;

                if ((state.RotationX - prev_rotation_x) < 0)
                {
                    inputInverted = true;
                }

                inputSelected = true;
            }

            //Check JoystickState Y rotation
            temp_diff = (double)Math.Abs(state.RotationY - prev_rotation_y) / (double)full_scale;
            if (temp_diff > max_diff)
            {
                max_diff    = temp_diff;
                activeInput = ControllerProperty.RotationY;

                if ((state.RotationY - prev_rotation_y) < 0)
                {
                    inputInverted = true;
                }

                inputSelected = true;
            }

            //Check JoystickState Z rotation
            temp_diff = (double)Math.Abs(state.RotationZ - prev_rotation_z) / (double)full_scale;
            if (temp_diff > max_diff)
            {
                max_diff    = temp_diff;
                activeInput = ControllerProperty.RotationZ;

                if ((state.RotationZ - prev_rotation_z) < 0)
                {
                    inputInverted = true;
                }

                inputSelected = true;
            }
        }
コード例 #10
0
        /// <summary>
        /// Loads the configuration for the system.
        /// </summary>
        private void Load()
        {
            foreach (string resourceName in Assembly.GetExecutingAssembly().GetManifestResourceNames())
            {
                if (resourceName.EndsWith(".SystemConfiguration.xml"))
                {
                    using (Stream istrm = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))
                    {
                        XmlSerializer serializer = new XmlSerializer(typeof(Configuration));
                        m_configuration = (Configuration)serializer.Deserialize(istrm);
                    }
                }
            }

            if (m_configuration.Controllers != null)
            {
                for (int ii = 0; ii < m_configuration.Controllers.Length; ii++)
                {
                    ControllerConfiguration controller = m_configuration.Controllers[ii];

                    int blockAddress = m_position;
                    int offset       = m_position - blockAddress;

                    BlockConfiguration data = new BlockConfiguration()
                    {
                        Address    = blockAddress,
                        Name       = controller.Name,
                        Type       = controller.Type,
                        Properties = new List <BlockProperty>()
                    };

                    if (controller.Properties != null)
                    {
                        for (int jj = 0; jj < controller.Properties.Length; jj++)
                        {
                            ControllerProperty property   = controller.Properties[jj];
                            NodeId             dataTypeId = NodeId.Parse(property.DataType);
                            string             value      = property.Value;
                            Range range = null;

                            if (!String.IsNullOrEmpty(property.Range))
                            {
                                try
                                {
                                    NumericRange nr = NumericRange.Parse(property.Range);
                                    range = new Range()
                                    {
                                        High = nr.End, Low = nr.Begin
                                    };
                                }
                                catch (Exception)
                                {
                                    range = null;
                                }
                            }

                            data.Properties.Add(new BlockProperty()
                            {
                                Offset    = offset,
                                Name      = controller.Properties[jj].Name,
                                DataType  = dataTypeId,
                                Writeable = controller.Properties[jj].Writeable,
                                Range     = range
                            });

                            switch ((uint)dataTypeId.Identifier)
                            {
                            case DataTypes.Int32:
                            {
                                Write(blockAddress, offset, (int)TypeUtils.Cast(value, BuiltInType.Int32));
                                offset += 4;
                                break;
                            }

                            case DataTypes.Double:
                            {
                                Write(blockAddress, offset, (double)TypeUtils.Cast(value, BuiltInType.Double));
                                offset += 4;
                                break;
                            }
                            }
                        }
                    }

                    m_position            += offset;
                    m_blocks[blockAddress] = data;
                }
            }
        }