2 using System.Collections.Generic;
8 namespace RobotIOControls
16 protected int m_iMinPulse = 544;
17 protected int m_iMaxPulse = 2400;
24 public override string Description {
get {
return "Controls a standard servo motor for a hinge joint using a Firmata controller";}set { }}
25 public override string WorkspaceImageName {
get {
return "RoboticsGUI.Graphics.HingeServoSmall.gif";}}
26 public override string ButtonImageName {
get {
return "RoboticsGUI.Graphics.HingeServoLarge.gif";}}
27 public override string PartType {
get {
return "FirmataHingeServo"; }}
28 public override string ModuleName {
get {
return "RoboticsAnimatSim"; } }
29 protected override Type GetLinkedPartDropDownTreeType() {
return typeof(AnimatGUI.TypeHelpers.DropDownTreeEditorNoFirstSelect);}
31 public virtual int MinPulse
33 get {
return m_iMinPulse; }
37 throw new System.Exception(
"Invalid minimum pulse time specified. Value: " + m_iMinPulse);
39 if (value >= m_iMaxPulse)
40 throw new System.Exception(
"The minimum pulse must be less than the maximum pulse of " + m_iMaxPulse);
42 SetSimData(
"MinPulse", value.ToString(),
true);
47 public virtual int MaxPulse
49 get {
return m_iMaxPulse; }
53 throw new System.Exception(
"Invalid maximum pulse time specified. Value: " + m_iMinPulse);
55 if (value <= m_iMinPulse)
56 throw new System.Exception(
"The maximum pulse must be greater than the minimum pulse of " + m_iMinPulse);
58 SetSimData(
"MaxPulse", value.ToString(),
true);
63 public virtual bool ResetToStartPos
68 SetSimData(
"ResetToStartPos", m_bResetToStartPos.ToString(),
true);
69 m_bResetToStartPos =
true;
73 public FirmataHingeServo(AnimatGUI.Framework.DataObject doParent)
76 m_strName =
"Standard Hinge Servo";
78 m_aryCompatiblePartTypes.Clear();
79 m_aryCompatiblePartTypes.Add(typeof(AnimatGUI.DataObjects.Physical.Joints.Hinge));
82 public override AnimatGUI.Framework.DataObject Clone(AnimatGUI.Framework.DataObject doParent,
bool bCutData, AnimatGUI.Framework.DataObject doRoot)
84 FirmataHingeServo doController =
new FirmataHingeServo(doParent);
88 protected override void CloneInternal(AnimatGUI.Framework.DataObject doOriginal,
bool bCutData, AnimatGUI.Framework.DataObject doRoot)
90 base.CloneInternal(doOriginal, bCutData, doRoot);
92 FirmataHingeServo servo = (FirmataHingeServo)doOriginal;
94 m_iMaxPulse = servo.m_iMaxPulse;
95 m_iMinPulse = servo.m_iMinPulse;
98 public override void BuildProperties(ref AnimatGuiCtrls.Controls.PropertyTable propTable)
100 base.BuildProperties(ref propTable);
102 propTable.Properties.Add(
new AnimatGuiCtrls.Controls.PropertySpec(
"Min Pulse",
this.MinPulse.GetType(),
"MinPulse",
"Properties",
"Minimum pulse duration of servo", this.MinPulse));
103 propTable.Properties.Add(
new AnimatGuiCtrls.Controls.PropertySpec(
"Max Pulse",
this.MaxPulse.GetType(),
"MaxPulse",
"Properties",
"Maximum pulse duration of servo", this.MaxPulse));
104 propTable.Properties.Add(
new AnimatGuiCtrls.Controls.PropertySpec(
"Reset To Start Pos",
this.ResetToStartPos.GetType(),
"ResetToStartPos",
105 "Properties",
"If true then it will reset the joint to a known position at the start the simulation", this.ResetToStartPos));
113 m_iMaxPulse = oXml.GetChildInt(
"MaxPulse", m_iMaxPulse);
114 m_iMinPulse = oXml.GetChildInt(
"MinPulse", m_iMinPulse);
115 m_bResetToStartPos = oXml.GetChildBool(
"ResetToStartPos", m_bResetToStartPos);
124 oXml.AddChildElement(
"MaxPulse", m_iMaxPulse);
125 oXml.AddChildElement(
"MinPulse", m_iMinPulse);
126 oXml.AddChildElement(
"ResetToStartPos", m_bResetToStartPos);
130 public override void SaveSimulationXml(
ManagedAnimatInterfaces.
IStdXml oXml, ref AnimatGUI.Framework.DataObject nmParentControl,
string strName =
"")
132 base.SaveSimulationXml(oXml, ref nmParentControl, strName);
135 oXml.AddChildElement(
"MaxPulse", m_iMaxPulse);
136 oXml.AddChildElement(
"MinPulse", m_iMinPulse);
137 oXml.AddChildElement(
"ResetToStartPos", m_bResetToStartPos);
bool m_bResetToStartPos
If true then when the simulation starts it will always reset the position of the servo to 0 to begin ...