Initial commit
This commit is contained in:
		
							
								
								
									
										128
									
								
								Handler/Project_form2/Class/ModelInfoM.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										128
									
								
								Handler/Project_form2/Class/ModelInfoM.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,128 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Text; | ||||
| using System.Drawing; | ||||
| using System.ComponentModel; | ||||
|  | ||||
| namespace Project | ||||
| { | ||||
|  | ||||
|     public class ModelInfoM | ||||
|     { | ||||
|         //스피드 값과, 위치값을 저장하면 된다. | ||||
|         public int idx { get; set; } | ||||
|         public string Title { get; set; } | ||||
|  | ||||
|         public Dictionary<int, PositionData[]> Position { get; set; } | ||||
|     | ||||
|  | ||||
|         public ModelInfoM() | ||||
|         { | ||||
|             idx = -1; | ||||
|             Title = string.Empty; | ||||
|             ClearDataPosition(); | ||||
|         } | ||||
|         void ClearDataPosition() | ||||
|         { | ||||
|             Position = new Dictionary<int, PositionData[]>(); | ||||
|             var motCount = Enum.GetNames(typeof(eAxis)).Length; | ||||
|             for (int i = 0; i < motCount; i++) | ||||
|             { | ||||
|                 var datas = new PositionData[64]; | ||||
|                 for (int j = 0; j < datas.Length; j++) | ||||
|                     datas[j] = new PositionData(-1, string.Empty, 0.0); | ||||
|  | ||||
|                 Position.Add(i, datas); | ||||
|             } | ||||
|         } | ||||
|       | ||||
|         public Boolean isSet | ||||
|         { | ||||
|             get | ||||
|             { | ||||
|                 if (idx == -1) return false; | ||||
|                 else return !Title.isEmpty(); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         public void ReadValue(DataSet1.MCModelRow dr) | ||||
|         { | ||||
|             idx = dr.idx; | ||||
|             Title = dr.Title; | ||||
|             ReadValuePosition(idx); | ||||
|         } | ||||
|  | ||||
|         public void ReadValue(int index) | ||||
|         { | ||||
|             var dr = Pub.mdm.dataSet.MCModel.Where(t => t.idx == index).FirstOrDefault(); | ||||
|             if (dr == null) | ||||
|             { | ||||
|                 idx = -1; | ||||
|                 Title = string.Empty; | ||||
|                 ClearDataPosition(); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 idx = dr.idx; | ||||
|                 Title = dr.Title; | ||||
|                 ReadValuePosition(idx); | ||||
|             } | ||||
|         } | ||||
|         public void ReadValue(string title) | ||||
|         { | ||||
|             ReadValue(title, Pub.mdm.dataSet.MCModel); | ||||
|         } | ||||
|         public void ReadValue(string title, DataSet1.MCModelDataTable dt) | ||||
|         { | ||||
|             var dr = dt.Where(t => t.Title == title).FirstOrDefault(); | ||||
|             if (dr == null) | ||||
|             { | ||||
|                 idx = -1; | ||||
|                 this.Title= string.Empty; | ||||
|                 ClearDataPosition(); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 idx = dr.idx; | ||||
|                 this.Title = dr.Title; | ||||
|                 ReadValuePosition(idx); | ||||
|             } | ||||
|         } | ||||
|         public void ReadValuePosition(int modelidx) | ||||
|         { | ||||
|             ReadValuePosition(modelidx, Pub.mdm.dataSet.MCModel); | ||||
|         } | ||||
|         public void ReadValuePosition(int modelidx, DataSet1.MCModelDataTable dt) | ||||
|         { | ||||
|             ClearDataPosition(); | ||||
|  | ||||
|             //각 모터별로 데이터를 가져온다 | ||||
|             int cnt = 0; | ||||
|             foreach (var data in Position) | ||||
|             { | ||||
|                 //해당 모터의 속도값을 가져온다 | ||||
|                 var drows = dt.Where(t => t.pidx == modelidx && t.PosIndex >= 0 && t.MotIndex == data.Key); | ||||
|                 foreach (DataSet1.MCModelRow dr in drows) | ||||
|                 { | ||||
|                     var item = data.Value[dr.PosIndex]; | ||||
|                     item.index = dr.PosIndex; | ||||
|                     item.title = dr.PosTitle; | ||||
|                     item.value = dr.Position; | ||||
|                     item.speed = dr.Speed; | ||||
|                     item.acc = dr.SpeedAcc; | ||||
|                     item.dcc = dr.SpeedDcc; | ||||
|                     data.Value[dr.PosIndex] = item; | ||||
|                     cnt += 1; | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             Pub.log.Add(String.Format("model {0} 의 위치 데이터 {1}건을 불러왔습니다", modelidx, cnt)); | ||||
|         } | ||||
|          | ||||
|     } | ||||
|  | ||||
|  | ||||
|     | ||||
|  | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 ChiKyun Kim
					ChiKyun Kim