AnimatLab  2
Test
DynamixelUSBServo.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 
6 namespace RoboticsGUI
7 {
8  namespace RobotIOControls
9  {
10  namespace DynamixelUSB
11  {
12 
13  public abstract class DynamixelUSBServo : RoboticsGUI.RobotIOControls.DynamixelServo
14  {
15  protected int m_iUpdateAllParamsCount = 10;
16  protected int m_iUpdateQueueIndex = -1;
17 
18  public override string ModuleName { get { return "RoboticsAnimatSim"; } }
19  protected override System.Type GetLinkedPartDropDownTreeType() { return typeof(AnimatGUI.TypeHelpers.DropDownTreeEditorNoFirstSelect); }
20 
21  public virtual int UpdateAllParamsCount
22  {
23  get { return m_iUpdateAllParamsCount; }
24  set
25  {
26  if (value <= 0)
27  throw new System.Exception("Invalid Update All Params Count specified. (" + value.ToString() + "). It must be greater than zero.");
28  SetSimData("UpdateAllParamsCount", value.ToString(), true);
29  m_iUpdateAllParamsCount = value;
30  }
31  }
32 
33  public virtual int UpdateQueueIndex
34  {
35  get { return m_iUpdateQueueIndex; }
36  set
37  {
38  if (value <= -1)
39  throw new System.Exception("Invalid Update Queue Index specified. (" + m_iUpdateAllParamsCount.ToString() + "). It must be greater than zero or -1.");
40  SetSimData("UpdateQueueIndex", value.ToString(), true);
41  m_iUpdateQueueIndex = value;
42  }
43  }
44 
45  public DynamixelUSBServo(AnimatGUI.Framework.DataObject doParent)
46  : base(doParent)
47  {
48  m_strName = "Servo";
49  }
50 
51  protected override void CloneInternal(AnimatGUI.Framework.DataObject doOriginal, bool bCutData, AnimatGUI.Framework.DataObject doRoot)
52  {
53  base.CloneInternal(doOriginal, bCutData, doRoot);
54 
55  DynamixelUSBServo servo = (DynamixelUSBServo)doOriginal;
56 
57  m_iUpdateAllParamsCount = servo.m_iUpdateAllParamsCount;
58  m_iUpdateQueueIndex = servo.m_iUpdateQueueIndex;
59  }
60 
61  public override void BuildProperties(ref AnimatGuiCtrls.Controls.PropertyTable propTable)
62  {
63  base.BuildProperties(ref propTable);
64 
65  propTable.Properties.Add(new AnimatGuiCtrls.Controls.PropertySpec("Update All Params Count", this.UpdateAllParamsCount.GetType(), "UpdateAllParamsCount",
66  "Properties", "How many update loops to go through before updating all params (voltage, load, etc.)", this.UpdateAllParamsCount));
67 
68  propTable.Properties.Add(new AnimatGuiCtrls.Controls.PropertySpec("Update Queue Index", this.UpdateQueueIndex.GetType(), "UpdateQueueIndex",
69  "Properties", "Dynamixel motors can be updated in a round robin fashion. To do this change their queue index. " +
70  "To have it updated every time set the index to -1.", this.UpdateAllParamsCount));
71  }
72 
73  public override void LoadData(ManagedAnimatInterfaces.IStdXml oXml)
74  {
75  base.LoadData(oXml);
76 
77  oXml.IntoElem();
78  m_iUpdateAllParamsCount = oXml.GetChildInt("UpdateAllParamsCount", m_iUpdateAllParamsCount);
79  m_iUpdateQueueIndex = oXml.GetChildInt("UpdateQueueIndex", m_iUpdateQueueIndex);
80  oXml.OutOfElem();
81  }
82 
83  public override void SaveData(ManagedAnimatInterfaces.IStdXml oXml)
84  {
85  base.SaveData(oXml);
86 
87  oXml.IntoElem();
88  oXml.AddChildElement("UpdateAllParamsCount", m_iUpdateAllParamsCount);
89  oXml.AddChildElement("UpdateQueueIndex", m_iUpdateQueueIndex);
90  oXml.OutOfElem();
91  }
92 
93  public override void SaveSimulationXml(ManagedAnimatInterfaces.IStdXml oXml, ref AnimatGUI.Framework.DataObject nmParentControl, string strName = "")
94  {
95  base.SaveSimulationXml(oXml, ref nmParentControl, strName);
96 
97  oXml.IntoElem();
98  oXml.AddChildElement("UpdateAllParamsCount", m_iUpdateAllParamsCount);
99  oXml.AddChildElement("UpdateQueueIndex", m_iUpdateQueueIndex);
100  oXml.OutOfElem();
101  }
102 
103  }
104  }
105  }
106 }