Ejemplo n.º 1
0
        /// <summary>
        /// 更正解耦控件信息中数组属性的数组名并返回数组信息
        /// </summary>
        /// <param name="curCas">控件所在CASSVIEW容器</param>
        /// <param name="curCtrl">控件</param>
        /// <param name="ArrayCount">当前所用到队列编号</param>
        /// <returns>数组信息</returns>
        static public List <string[]> GetJieOuArray(CassView curCas, Control curCtrl, ref int ArrayCount)
        {
            List <string[]> ArrayInfos = new List <string[]>(); //返回信息数组
            int             count      = 2;                     //解耦路数
            //解耦属性中需要生成数组的属性
            List <string> NeedAddArray
                = new List <string>(new string[] { "比例", "积分", "微分", "设定值", "自动/手动", "控制量上限", "控制量下限", "控制量输出", "解耦矩阵的参数" });

            PropertyDescriptor configurationProperty = TypeDescriptor.GetProperties(curCtrl)["Configuration"];

            ControlTactic.SpecialControl.JieOu       ConvertTool = new ControlTactic.SpecialControl.JieOu();
            ControlTactic.SpecialControl.JieOuStruct tempStruct  = ConvertTool.ListToStruct((List <string>)configurationProperty.GetValue(curCtrl));

            ControlInfo JieOu = curCas.FindControlInfo(curCtrl);

            for (int i = 0; i < JieOu.VisibleFunctionProperty.Count; i++)
            {//在可视属性中找到解耦数进行赋值
                if (JieOu.VisibleFunctionProperty[i].Name == "解耦路数")
                {
                    JieOu.VisibleFunctionProperty[i].TheValue = tempStruct.JieOuNum;
                    count = tempStruct.JieOuNum;
                    break;
                }
            }
            //依次为比例、积分、微分、设定值、自动手动、控制量上限、控制量下限、控制量输出数组
            List <string>[] Attributes
                = new List <string>[] { new List <string>(), new List <string>(), new List <string>(), new List <string>(), new List <string>(), new List <string>(), new List <string>(), new List <string>() };
            foreach (List <string> attribute in tempStruct.JieOuAttribute)
            {//每个属性 依次由比例、积分、微分、设定值、自动手动、控制量上限、控制量下限、控制量输出组成
                Attributes[0].Add(attribute[0]);
                Attributes[1].Add(attribute[1]);
                Attributes[2].Add(attribute[2]);
                Attributes[3].Add(attribute[3]);
                Attributes[4].Add(new List <string>(new string[] { "自动", "手动" }).IndexOf(attribute[4]).ToString());//自动手动序号
                Attributes[5].Add(attribute[5]);
                Attributes[6].Add(attribute[6]);
                Attributes[7].Add(attribute[7]);
            }
            for (int i = 0; i < JieOu.UnvisibleFunctionProperty.Count; i++)
            {
                int index = NeedAddArray.IndexOf(JieOu.UnvisibleFunctionProperty[i].Name);
                if (index != -1)
                {//ArrayInfo顺序依次为控件PortName、属性VarName、类型、数组名、长度、数组
                    List <string> ArrayInfo = new List <string>();
                    JieOu.UnvisibleFunctionProperty[i].TheValue
                        = "configuration" + CassViewGenerator.ProjectNum + "_array" + (ArrayCount++).ToString();
                    ArrayInfo.Add(JieOu.CodeInfo[2]);
                    ArrayInfo.Add(JieOu.UnvisibleFunctionProperty[i].Name);
                    ArrayInfo.Add("fp32");
                    ArrayInfo.Add(JieOu.UnvisibleFunctionProperty[i].TheValue.ToString());
                    if (index == 8)
                    {
                        List <string> tempArray = new List <string>();
                        foreach (string element in tempStruct.JieOuTable)
                        {
                            tempArray.Add(element);
                        }
                        ArrayInfo.Add(tempArray.Count.ToString());
                        ArrayInfo.Add(String.Join(",", tempArray.ToArray()));
                    }
                    else
                    {
                        ArrayInfo.Add(Attributes[index].Count.ToString());
                        ArrayInfo.Add(String.Join(",", Attributes[index].ToArray()));
                    }
                    if (index == 4)
                    {//自动/手动为char型
                        ArrayInfo[2] = "uint8";
                    }
                    ArrayInfo.Add(JieOu.UnvisibleFunctionProperty[i].VarName);
                    ArrayInfos.Add(ArrayInfo.ToArray());
                }
                else if (JOUnuseArray.Contains(JieOu.UnvisibleFunctionProperty[i].Name))
                {//不使用的数组赋值
                    JieOu.UnvisibleFunctionProperty[i].TheValue
                        = "configuration" + CassViewGenerator.ProjectNum + "_array" + (ArrayCount++).ToString();
                    List <string> tempValue = new List <string>();//生成解耦路数个全0数组
                    for (int k = 0; k < count; k++)
                    {
                        tempValue.Add("0");
                    }
                    UnseeArray.Add(new string[] { null, null, "fp32", JieOu.UnvisibleFunctionProperty[i].TheValue.ToString(), count.ToString(), String.Join(",", tempValue.ToArray()) });
                }
            }
            return(ArrayInfos);
        }
        /// <summary>
        /// ��������ؼ���Ϣ���������Ե�������������������Ϣ
        /// </summary>
        /// <param name="curCas">�ؼ�����CASSVIEW����</param>
        /// <param name="curCtrl">�ؼ�</param>
        /// <param name="ArrayCount">��ǰ���õ����б��</param>
        /// <returns>������Ϣ</returns>
        public static List<string[]> GetJieOuArray(CassView curCas, Control curCtrl,ref int ArrayCount)
        {
            List<string[]> ArrayInfos = new List<string[]>();//������Ϣ����
            int count = 2;//����·��
            //������������Ҫ�������������
            List<string> NeedAddArray
                = new List<string>(new string[] { "����", "����", "΢��", "�趨ֵ", "�Զ�/�ֶ�", "����������", "����������", "���������", "�������IJ���" });

            PropertyDescriptor configurationProperty = TypeDescriptor.GetProperties(curCtrl)["Configuration"];
            ControlTactic.SpecialControl.JieOu ConvertTool = new ControlTactic.SpecialControl.JieOu();
            ControlTactic.SpecialControl.JieOuStruct tempStruct = ConvertTool.ListToStruct((List<string>)configurationProperty.GetValue(curCtrl));

            ControlInfo JieOu = curCas.FindControlInfo(curCtrl);
            for (int i = 0; i < JieOu.VisibleFunctionProperty.Count; i++)
            {//�ڿ����������ҵ����������и�ֵ
                if (JieOu.VisibleFunctionProperty[i].Name == "����·��")
                {
                    JieOu.VisibleFunctionProperty[i].TheValue = tempStruct.JieOuNum;
                    count = tempStruct.JieOuNum;
                    break;
                }
            }
            //����Ϊ���������֡�΢�֡��趨ֵ���Զ��ֶ������������ޡ����������ޡ��������������
            List<string>[] Attributes
                = new List<string>[] { new List<string>(), new List<string>(), new List<string>(), new List<string>(), new List<string>(), new List<string>(), new List<string>(), new List<string>() };
            foreach (List<string> attribute in tempStruct.JieOuAttribute)
            {//ÿ������ �����ɱ��������֡�΢�֡��趨ֵ���Զ��ֶ������������ޡ����������ޡ�������������
                Attributes[0].Add(attribute[0]);
                Attributes[1].Add(attribute[1]);
                Attributes[2].Add(attribute[2]);
                Attributes[3].Add(attribute[3]);
                Attributes[4].Add(new List<string>(new string[] { "�Զ�", "�ֶ�" }).IndexOf(attribute[4]).ToString());//�Զ��ֶ����
                Attributes[5].Add(attribute[5]);
                Attributes[6].Add(attribute[6]);
                Attributes[7].Add(attribute[7]);
            }
            for (int i = 0; i < JieOu.UnvisibleFunctionProperty.Count; i++)
            {
                int index = NeedAddArray.IndexOf(JieOu.UnvisibleFunctionProperty[i].Name);
                if (index != -1)
                {//ArrayInfo˳������Ϊ�ؼ�PortName������VarName�����͡������������ȡ�����
                    List<string> ArrayInfo = new List<string>();
                    JieOu.UnvisibleFunctionProperty[i].TheValue
                        = "configuration" + CassViewGenerator.ProjectNum + "_array" + (ArrayCount++).ToString();
                    ArrayInfo.Add(JieOu.CodeInfo[2]);
                    ArrayInfo.Add(JieOu.UnvisibleFunctionProperty[i].Name);
                    ArrayInfo.Add("fp32");
                    ArrayInfo.Add(JieOu.UnvisibleFunctionProperty[i].TheValue.ToString());
                    if (index == 8)
                    {
                        List<string> tempArray = new List<string>();
                        foreach (string element in tempStruct.JieOuTable)
                        {
                            tempArray.Add(element);
                        }
                        ArrayInfo.Add(tempArray.Count.ToString());
                        ArrayInfo.Add(String.Join(",", tempArray.ToArray()));
                    }
                    else
                    {
                        ArrayInfo.Add(Attributes[index].Count.ToString());
                        ArrayInfo.Add(String.Join(",", Attributes[index].ToArray()));
                    }
                    if (index == 4)
                    {//�Զ�/�ֶ�Ϊchar��
                        ArrayInfo[2] = "uint8";
                    }
                    ArrayInfo.Add(JieOu.UnvisibleFunctionProperty[i].VarName);
                    ArrayInfos.Add(ArrayInfo.ToArray());
                }
                else if (JOUnuseArray.Contains(JieOu.UnvisibleFunctionProperty[i].Name))
                {//��ʹ�õ����鸳ֵ
                    JieOu.UnvisibleFunctionProperty[i].TheValue
                        = "configuration" + CassViewGenerator.ProjectNum + "_array" + (ArrayCount++).ToString();
                    List<string> tempValue = new List<string>();//���ɽ���·����ȫ0����
                    for (int k = 0; k < count; k++)
                    { tempValue.Add("0"); }
                    UnseeArray.Add(new string[] { null, null, "fp32", JieOu.UnvisibleFunctionProperty[i].TheValue.ToString(), count.ToString(), String.Join(",", tempValue.ToArray()) });
                }
            }
            return ArrayInfos;
        }
        /// <summary>
        /// 更改解耦数目时解耦组态信息进行修改
        /// </summary>
        /// <param name="control">解耦控件</param>
        /// <param name="oldValue">修改前的解耦数</param>
        /// <param name="newValue">修改后的解耦数</param>
        private static void SetJoConfigInfo(Control control, int oldValue, int newValue)
        {
            PropertyDescriptor configurationProperty = TypeDescriptor.GetProperties(control)["Configuration"];
            ControlTactic.SpecialControl.JieOu ConvertTool = new ControlTactic.SpecialControl.JieOu();
            ControlTactic.SpecialControl.JieOuStruct tempStruct = ConvertTool.ListToStruct((List<string>)configurationProperty.GetValue(control));
            tempStruct.JieOuNum = newValue;//结构体中的解耦路数

            //结构体中每路解耦信息
            List<List<string>> tempAttribute = new List<List<string>>();
            for (int count = 0; count < tempStruct.JieOuNum; count++)
            {
                if (count > oldValue - 1)
                {
                    tempAttribute.Add(ControlTactic.SpecialControl.JieOuForm1.Original);//添加新解耦信息
                }
                else
                {
                    tempAttribute.Add(tempStruct.JieOuAttribute[count]);
                }
            }
            tempStruct.JieOuAttribute = tempAttribute;
            //结构体中的解耦表
            string[,] tempTable = new string[tempStruct.JieOuNum, tempStruct.JieOuNum];
            for (int i = 0; i < tempStruct.JieOuNum; i++)
            {
                for (int j = 0; j < tempStruct.JieOuNum; j++)
                {
                    if (i > oldValue - 1 || j > oldValue - 1)
                    { tempTable[i, j] = "0"; }
                    else
                    {
                        tempTable[i, j] = tempStruct.JieOuTable[i, j];
                    }
                }
            }
            tempStruct.JieOuTable = tempTable;
            configurationProperty.SetValue(control, ConvertTool.StructToList(tempStruct));
        }