Esempio n. 1
0
        void parseChMap(string[] parms)
        {
            if (!BuildingChannelMap)
            {
                return;
            }
            if (parms[1] == "done")
            {
                BuildingChannelMap = false;
            }
            else if (parms[1] == "ins")
            {
                ChannelMappingData chMapData = new ChannelMappingData();
                int modeIndex = int.Parse(parms[2]);
                chMapData.Type           = (MappingType)int.Parse(parms[3]);
                chMapData.ServoIndices   = GetValueArrayFromString <int>(parms[4]);
                chMapData.ChannelIndices = GetValueArrayFromString <int>(parms[5]);
                chMapData.Positionning   = (PositionningType)int.Parse(parms[6]);

                chMapData.Params     = new decimal[chMapData.Type == MappingType.IK ? 2 : 0];
                chMapData.chMapIndex = chMapIndex++;

                ucMappingBase ucMapping = null;
                switch (chMapData.Type)
                {
                case MappingType.Direct:
                    ucMapping = new ucMappingDirect(inputCount, outputCount);
                    break;

                case MappingType.TankMix:
                    ucMapping = new ucMappingTankMix(inputCount, outputCount);
                    break;

                case MappingType.IK:
                    ucMapping = new ucMappingIK(inputCount, outputCount);
                    break;
                }
                ucMapping.chMapData           = chMapData;
                ucMapping.Top                 = buildHeight;
                buildHeight                  += ucMapping.Height;
                ucMapping.Width               = panelChannelMap.Width - 20;
                ucMapping.OnCommand          += OnCommandReceived;
                ucMapping.OnChMapTypeChanged += ucMapping_OnChMapTypeChanged;
                AddControlToContainer(panelChannelMap, ucMapping);
            }
            else if (parms[1] == "setParams")
            {
                // chMap setParams <modeIndex> <chMapIndex> <param1>,<param2>...
                int modeIndex  = int.Parse(parms[2]);
                int chMapIndex = int.Parse(parms[3]);

                List <ucMappingBase> controlList = new List <ucMappingBase>(panelChannelMap.Controls.OfType <ucMappingBase>());
                ucMappingIK          uc          = (ucMappingIK)controlList.Where(v => v.chMapData.chMapIndex == chMapIndex).FirstOrDefault();
                ChannelMappingData   chMapData   = uc.chMapData;
                chMapData.Params = GetValueArrayFromString <decimal>(parms[4]);
                uc.SetControlValues();
            }
        }
Esempio n. 2
0
        void ucMapping_OnChMapTypeChanged(object sender, ChMapTypeChangedEventArgs e)
        {
            if (updating)
            {
                return;
            }
            updating = true;
            ChannelMappingData chMapData = e.chMapData;
            ucMappingBase      ucMapping = null;

            switch (chMapData.Type)
            {
            case MappingType.Direct:
                ucMapping = new ucMappingDirect(inputCount, outputCount);
                Array.Resize(ref chMapData.ChannelIndices, 1);
                Array.Resize(ref chMapData.ServoIndices, 1);
                break;

            case MappingType.TankMix:
                ucMapping = new ucMappingTankMix(inputCount, outputCount);
                Array.Resize(ref chMapData.ChannelIndices, 2);
                Array.Resize(ref chMapData.ServoIndices, 2);
                break;

            case MappingType.IK:
                ucMapping = new ucMappingIK(inputCount, outputCount);
                Array.Resize(ref chMapData.ChannelIndices, 3);
                Array.Resize(ref chMapData.ServoIndices, 3);
                Array.Resize(ref chMapData.Params, 2);
                break;
            }
            ucMapping.chMapData = chMapData;
            //ucMapping.Top = ucMapping.Height * chMapData.chMapIndex;
            ucMapping.Width               = panelChannelMap.Width - 20;
            ucMapping.OnCommand          += OnCommandReceived;
            ucMapping.OnChMapTypeChanged += ucMapping_OnChMapTypeChanged;

            panelChannelMap.Controls.RemoveAt(chMapData.chMapIndex);
            AddControlToContainer(panelChannelMap, ucMapping);
            RearrangeMappingControls();
            updating = false;
        }
Esempio n. 3
0
        void AddNewChMap()
        {
            ChannelMappingData chMapData = new ChannelMappingData();

            chMapData.chMapIndex     = panelChannelMap.Controls.Count;
            chMapData.ServoIndices   = new int[] { 0 };
            chMapData.ChannelIndices = new int[] { 0 };
            chMapData.Params         = new decimal[0];
            chMapData.Type           = MappingType.Direct;
            chMapData.Positionning   = PositionningType.Absolute;
            chMapData.IsNew          = true;

            ucMappingBase ucMapping = new ucMappingDirect(inputCount, outputCount);;

            ucMapping.chMapData           = chMapData;
            ucMapping.Width               = panelChannelMap.Width - 20;
            ucMapping.Anchor             |= AnchorStyles.Right;
            ucMapping.Top                 = buildHeight;
            buildHeight                  += ucMapping.Height;
            ucMapping.OnCommand          += OnCommandReceived;
            ucMapping.OnChMapTypeChanged += new EventHandler <ChMapTypeChangedEventArgs>(ucMapping_OnChMapTypeChanged);
            AddControlToContainer(panelChannelMap, ucMapping);
            CreatingChMap = true;
        }