private string tempColumnText = null; //当前偏差变化率模糊论域的值 /// <summary> /// 根据传入的结构体初始化窗口的值 /// </summary> /// <param name="FStruct">传入的存放模糊控制块各值的结构体</param> public FuzzyForm1(FuzzyStruct FStruct) { InitializeComponent(); //结构体副本 newStruct = FStruct; //偏差模糊论域和偏差变化率模糊论域 RowValue.Text = FStruct.RowNum.ToString(); ColumnValue.Text = FStruct.ColumnNum.ToString(); //偏差模糊论域值 Rows.Clear(); int countR = Convert.ToInt32(FStruct.RowNum); for (int x = -1 * countR; x <= countR; x++) { Rows.Add(x.ToString()); } //偏差变化率模糊论域值 Columns.Clear(); int countC = Convert.ToInt32(FStruct.ColumnNum); for (int y = -1 * countC; y <= countC; y++) { Columns.Add(y.ToString()); } //偏差模糊论域数和偏差变化率模糊论域数 tempRowText = RowValue.Text; tempColumnText = ColumnValue.Text; //模糊控制表 ControlTableBox = FStruct.ControlTable; }
/// <summary> /// 将模糊控制表的数据列表转换成结构体 /// </summary> /// <param name="tempList">传入的列表</param> /// <returns>返回转换后的结构体</returns> public FuzzyStruct ListToStruct(List <string> tempList) { FuzzyStruct tempStruct = new FuzzyStruct(); //模糊论域数 tempStruct.RowNum = Convert.ToInt32(tempList[0]); tempStruct.ColumnNum = Convert.ToInt32(tempList[1]); //模糊控制表 string[,] tempTable = new string[tempStruct.RowNum * 2 + 1, tempStruct.ColumnNum * 2 + 1]; string[] tempI = tempList[tempList.Count - 1].Split(new char[] { ';' }); for (int i = 0; i < tempStruct.RowNum * 2 + 1; i++) { string[] tempJ = tempI[i].Split(new char[] { ',' }); for (int j = 0; j < tempStruct.ColumnNum * 2 + 1; j++) { tempTable[i, j] = tempJ[j]; } } tempStruct.ControlTable = tempTable; return(tempStruct); }
/// <summary> /// 将模糊控制块的结构体转换成列表 /// </summary> /// <param name="tempStuct">传入的结构体</param> /// <returns>返回转换后的列表</returns> public List <string> StructToList(FuzzyStruct tempStuct) { List <string> tempList = new List <string>(); //模糊论域数 tempList.Add(tempStuct.RowNum.ToString()); tempList.Add(tempStuct.ColumnNum.ToString()); //模糊控制表 List <string> Ctable = new List <string>(); for (int i = 0; i < tempStuct.RowNum * 2 + 1; i++) { List <string> row = new List <string>(); for (int j = 0; j < tempStuct.ColumnNum * 2 + 1; j++) { row.Add(tempStuct.ControlTable[i, j]); } Ctable.Add(String.Join(",", row.ToArray())); } tempList.Add(String.Join(";", Ctable.ToArray())); return(tempList); }
/// <summary> /// 将模糊控制表的数据列表转换成结构体 /// </summary> /// <param name="tempList">传入的列表</param> /// <returns>返回转换后的结构体</returns> public FuzzyStruct ListToStruct(List<string> tempList) { FuzzyStruct tempStruct = new FuzzyStruct(); //模糊论域数 tempStruct.RowNum = Convert.ToInt32(tempList[0]); tempStruct.ColumnNum = Convert.ToInt32(tempList[1]); //模糊控制表 string[,] tempTable = new string[tempStruct.RowNum * 2 + 1, tempStruct.ColumnNum * 2 + 1]; string[] tempI = tempList[tempList.Count - 1].Split(new char[] { ';' }); for (int i = 0; i < tempStruct.RowNum * 2 + 1; i++) { string[] tempJ = tempI[i].Split(new char[] { ',' }); for (int j = 0; j < tempStruct.ColumnNum * 2 + 1; j++) { tempTable[i, j] = tempJ[j]; } } tempStruct.ControlTable = tempTable; return tempStruct; }
/// <summary> /// 将模糊控制块的结构体转换成列表 /// </summary> /// <param name="tempStuct">传入的结构体</param> /// <returns>返回转换后的列表</returns> public List<string> StructToList(FuzzyStruct tempStuct) { List<string> tempList = new List<string>(); //模糊论域数 tempList.Add(tempStuct.RowNum.ToString()); tempList.Add(tempStuct.ColumnNum.ToString()); //模糊控制表 List<string> Ctable = new List<string>(); for (int i = 0; i < tempStuct.RowNum * 2 + 1; i++) { List<string> row = new List<string>(); for (int j = 0; j < tempStuct.ColumnNum * 2 + 1; j++) { row.Add(tempStuct.ControlTable[i, j]); } Ctable.Add(String.Join(",", row.ToArray())); } tempList.Add(String.Join(";", Ctable.ToArray())); return tempList; }