aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Web/Tango.MachineService/Hubs/ExternalBridgeHub.cs
blob: 9b7f734d2502faeb8a5d145319c630635b1938db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
using Microsoft.AspNet.SignalR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using Tango.Integration.ExternalBridge.Web;

namespace Tango.MachineService.Hubs
{
    public class ExternalBridgeHub : Hub
    {
        private static List<ExternalBridgeInfo> _externalBridges;
        private static List<MachineSession> _sessions;

        public class ExternalBridgeInfo
        {
            public String ConnectionID { get; set; }
            public MachineInfo MachineInfo { get; set; }
        }

        public class MachineSession
        {
            public String SessionID { get; set; }
            public String ReceiverConnectionID { get; set; }
            public String ControllerConnectionID { get; set; }
            public ExternalBridgeInfo ExternalBridge { get; set; }

            public MachineSession()
            {
                SessionID = Guid.NewGuid().ToString();
            }
        }

        static ExternalBridgeHub()
        {
            _externalBridges = new List<ExternalBridgeInfo>();
            _sessions = new List<MachineSession>();
        }

        public void RegisterMachine(MachineInfo machineInfo)
        {
            _externalBridges.RemoveAll(x => x.MachineInfo.SerialNumber == machineInfo.SerialNumber);
            _sessions.RemoveAll(x => x.ExternalBridge.ConnectionID == Context.ConnectionId);

            machineInfo.IPAddress = GetIpAddress();

            _externalBridges.Add(new ExternalBridgeInfo()
            {
                MachineInfo = machineInfo,
                ConnectionID = Context.ConnectionId,
            });
        }

        public void UnregisterMachine()
        {
            _externalBridges.RemoveAll(x => x.ConnectionID == Context.ConnectionId);
            _sessions.RemoveAll(x => x.ExternalBridge.ConnectionID == Context.ConnectionId);
        }

        public String Ping()
        {
            return "Ping";
        }

        public List<MachineInfo> GetAvailableMachines()
        {
            return _externalBridges.Select(x => x.MachineInfo).ToList();
        }

        public String CreateSession(String serialNumber)
        {
            var externalBridge = _externalBridges.SingleOrDefault(x => x.MachineInfo.SerialNumber == serialNumber);

            if (externalBridge != null)
            {
                var existingSession = GetSession();

                if (existingSession != null)
                {
                    _sessions.Remove(existingSession);
                }

                MachineSession session = new MachineSession();
                session.ControllerConnectionID = Context.ConnectionId;
                session.ExternalBridge = externalBridge;
                _sessions.Add(session);
                Clients.Client(externalBridge.ConnectionID).OnSessionCreated(session.SessionID);
                return session.SessionID;
            }

            return null;
        }

        public void JoinSession(String sessionID)
        {
            var session = _sessions.SingleOrDefault(x => x.SessionID == sessionID);

            if (session != null)
            {
                session.ReceiverConnectionID = Context.ConnectionId;
                Clients.Client(session.ControllerConnectionID).SessionCreated();
            }
        }

        public void Write(List<byte[]> dataCollection)
        {
            var connectionID = GetOtherSideConnectionID();

            if (connectionID != null)
            {
                Clients.Client(connectionID).DataAvailable(dataCollection);
            }
        }

        public void LeaveSession()
        {
            var connectionID = GetOtherSideConnectionID();
            ClearSession();
            Clients.Client(connectionID).OnSessionClosed();
        }

        public override Task OnDisconnected(bool stopCalled)
        {
            _externalBridges.RemoveAll(x => x.ConnectionID == Context.ConnectionId);
            _sessions.RemoveAll(x => x.ControllerConnectionID == Context.ConnectionId || x.ReceiverConnectionID == Context.ConnectionId || x.ExternalBridge.ConnectionID == Context.ConnectionId);
            return base.OnDisconnected(stopCalled);
        }

        private void ClearSession()
        {
            _sessions.RemoveAll(x => x.ControllerConnectionID == Context.ConnectionId || x.ReceiverConnectionID == Context.ConnectionId);
        }

        private MachineSession GetSession()
        {
            return _sessions.SingleOrDefault(x => x.ReceiverConnectionID == Context.ConnectionId || x.ControllerConnectionID == Context.ConnectionId);
        }

        private String GetOtherSideConnectionID()
        {
            var session = GetSession();

            if (session != null)
            {
                String connectionID = String.Empty;

                if (session.ReceiverConnectionID == Context.ConnectionId)
                {
                    connectionID = session.ControllerConnectionID;
                }
                else
                {
                    connectionID = session.ReceiverConnectionID;
                }

                return connectionID;
            }

            return null;
        }

        protected string GetIpAddress()
        {
            try
            {
                string ipAddress;
                object tempObject;

                Context.Request.Environment.TryGetValue("server.RemoteIpAddress", out tempObject);

                if (tempObject != null)
                {
                    ipAddress = (string)tempObject;
                }
                else
                {
                    ipAddress = "";
                }

                return ipAddress;
            }
            catch
            {
                return String.Empty;
            }
        }
    }
}
bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: HardwareMotor.proto
#pragma warning disable 1591, 0612, 3021
#region Designer generated code

using pb = global::Google.Protobuf;
using pbc = global::Google.Protobuf.Collections;
using pbr = global::Google.Protobuf.Reflection;
using scg = global::System.Collections.Generic;
namespace Tango.PMR.Hardware {

  /// <summary>Holder for reflection information generated from HardwareMotor.proto</summary>
  public static partial class HardwareMotorReflection {

    #region Descriptor
    /// <summary>File descriptor for HardwareMotor.proto</summary>
    public static pbr::FileDescriptor Descriptor {
      get { return descriptor; }
    }
    private static pbr::FileDescriptor descriptor;

    static HardwareMotorReflection() {
      byte[] descriptorData = global::System.Convert.FromBase64String(
          string.Concat(
            "ChNIYXJkd2FyZU1vdG9yLnByb3RvEhJUYW5nby5QTVIuSGFyZHdhcmUaF0hh",
            "cmR3YXJlTW90b3JUeXBlLnByb3RvIo4GCg1IYXJkd2FyZU1vdG9yEkAKEUhh",
            "cmR3YXJlTW90b3JUeXBlGAEgASgOMiUuVGFuZ28uUE1SLkhhcmR3YXJlLkhh",
            "cmR3YXJlTW90b3JUeXBlEhQKDE1pbkZyZXF1ZW5jeRgCIAEoBRIUCgxNYXhG",
            "cmVxdWVuY3kYAyABKAUSFAoMU2V0TWljcm9TdGVwGAQgASgFEhEKCU1pY3Jv",
            "U3RlcBgFIAEoBRIWCg5NYXhDaGFuZ2VTbG9wZRgGIAEoARIdChVIaWdoTGVu",
            "Z3RoTWljcm9TZWNvbmQYByABKAESEwoLU3BlZWRNYXN0ZXIYCCABKAgSFQoN",
            "UHVsc2VQZXJSb3VuZBgJIAEoBRIUCgxQdWxsZXlSYWRpdXMYCiABKAESEgoK",
            "Q29uZmlnV29yZBgLIAEoBRIbChNEaXJlY3Rpb25UaHJlYWRXaXplGAwgASgI",
            "EhAKCEt2YWxIb2xkGA0gASgFEg8KB0t2YWxSdW4YDiABKAUSDwoHS3ZhbEFj",
            "YxgPIAEoBRIPCgdLdmFsRGVjGBAgASgFEhwKFE92ZXJDdXJyZW50VGhyZXNo",
            "b2xkGBEgASgFEhYKDlN0YWxsVGhyZXNob2xkGBIgASgFEiEKGVRoZXJtYWxD",
            "b21wZW5zYXRpb25GYWN0b3IYEyABKAUSHAoUTG93U3BlZWRPcHRpbWl6YXRp",
            "b24YFCABKAgSDQoFU3RTbHAYFSABKAUSDgoGSW50U3BkGBYgASgFEhAKCEZu",
            "U2xwQWNjGBcgASgFEhAKCEZuU2xwRGVjGBggASgFEg0KBUZzU3BkGBkgASgF",
            "EhAKCEdhdGVDZmcxGBogASgFEhAKCEdhdGVDZmcyGBsgASgFEhAKCFRWYWxI",
            "b2xkGBwgASgFEg8KB1RWYWxSdW4YHSABKAUSDwoHVFZhbEFjYxgeIAEoBRIP",
            "CgdUVmFsRGVjGB8gASgFEg0KBVRGYXN0GCAgASgFEg4KBlRPbk1pbhghIAEo",
            "BRIPCgdUT2ZmTWluGCIgASgFEhUKDVAwMUNvbmZpZ1dvcmQYIyABKAVCHgoc",
            "Y29tLnR3aW5lLnRhbmdvLnBtci5oYXJkd2FyZWIGcHJvdG8z"));
      descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
          new pbr::FileDescriptor[] { global::Tango.PMR.Hardware.HardwareMotorTypeReflection.Descriptor, },
          new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] {
            new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Hardware.HardwareMotor), global::Tango.PMR.Hardware.HardwareMotor.Parser, new[]{ "HardwareMotorType", "MinFrequency", "MaxFrequency", "SetMicroStep", "MicroStep", "MaxChangeSlope", "HighLengthMicroSecond", "SpeedMaster", "PulsePerRound", "PulleyRadius", "ConfigWord", "DirectionThreadWize", "KvalHold", "KvalRun", "KvalAcc", "KvalDec", "OverCurrentThreshold", "StallThreshold", "ThermalCompensationFactor", "LowSpeedOptimization", "StSlp", "IntSpd", "FnSlpAcc", "FnSlpDec", "FsSpd", "GateCfg1", "GateCfg2", "TValHold", "TValRun", "TValAcc", "TValDec", "TFast", "TOnMin", "TOffMin", "P01ConfigWord" }, null, null, null)
          }));
    }
    #endregion

  }
  #region Messages
  public sealed partial class HardwareMotor : pb::IMessage<HardwareMotor> {
    private static readonly pb::MessageParser<HardwareMotor> _parser = new pb::MessageParser<HardwareMotor>(() => new HardwareMotor());
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public static pb::MessageParser<HardwareMotor> Parser { get { return _parser; } }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public static pbr::MessageDescriptor Descriptor {
      get { return global::Tango.PMR.Hardware.HardwareMotorReflection.Descriptor.MessageTypes[0]; }
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    pbr::MessageDescriptor pb::IMessage.Descriptor {
      get { return Descriptor; }
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public HardwareMotor() {
      OnConstruction();
    }

    partial void OnConstruction();

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public HardwareMotor(HardwareMotor other) : this() {
      hardwareMotorType_ = other.hardwareMotorType_;
      minFrequency_ = other.minFrequency_;
      maxFrequency_ = other.maxFrequency_;
      setMicroStep_ = other.setMicroStep_;
      microStep_ = other.microStep_;
      maxChangeSlope_ = other.maxChangeSlope_;
      highLengthMicroSecond_ = other.highLengthMicroSecond_;
      speedMaster_ = other.speedMaster_;
      pulsePerRound_ = other.pulsePerRound_;
      pulleyRadius_ = other.pulleyRadius_;
      configWord_ = other.configWord_;
      directionThreadWize_ = other.directionThreadWize_;
      kvalHold_ = other.kvalHold_;
      kvalRun_ = other.kvalRun_;
      kvalAcc_ = other.kvalAcc_;
      kvalDec_ = other.kvalDec_;
      overCurrentThreshold_ = other.overCurrentThreshold_;
      stallThreshold_ = other.stallThreshold_;
      thermalCompensationFactor_ = other.thermalCompensationFactor_;
      lowSpeedOptimization_ = other.lowSpeedOptimization_;
      stSlp_ = other.stSlp_;
      intSpd_ = other.intSpd_;
      fnSlpAcc_ = other.fnSlpAcc_;
      fnSlpDec_ = other.fnSlpDec_;
      fsSpd_ = other.fsSpd_;
      gateCfg1_ = other.gateCfg1_;
      gateCfg2_ = other.gateCfg2_;
      tValHold_ = other.tValHold_;
      tValRun_ = other.tValRun_;
      tValAcc_ = other.tValAcc_;
      tValDec_ = other.tValDec_;
      tFast_ = other.tFast_;
      tOnMin_ = other.tOnMin_;
      tOffMin_ = other.tOffMin_;
      p01ConfigWord_ = other.p01ConfigWord_;
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public HardwareMotor Clone() {
      return new HardwareMotor(this);
    }

    /// <summary>Field number for the "HardwareMotorType" field.</summary>
    public const int HardwareMotorTypeFieldNumber = 1;
    private global::Tango.PMR.Hardware.HardwareMotorType hardwareMotorType_ = 0;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public global::Tango.PMR.Hardware.HardwareMotorType HardwareMotorType {
      get { return hardwareMotorType_; }
      set {
        hardwareMotorType_ = value;
      }
    }

    /// <summary>Field number for the "MinFrequency" field.</summary>
    public const int MinFrequencyFieldNumber = 2;
    private int minFrequency_;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public int MinFrequency {
      get { return minFrequency_; }
      set {
        minFrequency_ = value;
      }
    }

    /// <summary>Field number for the "MaxFrequency" field.</summary>
    public const int MaxFrequencyFieldNumber = 3;
    private int maxFrequency_;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public int MaxFrequency {
      get { return maxFrequency_; }
      set {
        maxFrequency_ = value;
      }
    }

    /// <summary>Field number for the "SetMicroStep" field.</summary>
    public const int SetMicroStepFieldNumber = 4;
    private int setMicroStep_;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public int SetMicroStep {
      get { return setMicroStep_; }
      set {
        setMicroStep_ = value;
      }
    }

    /// <summary>Field number for the "MicroStep" field.</summary>
    public const int MicroStepFieldNumber = 5;
    private int microStep_;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public int MicroStep {
      get { return microStep_; }
      set {
        microStep_ = value;
      }
    }

    /// <summary>Field number for the "MaxChangeSlope" field.</summary>
    public const int MaxChangeSlopeFieldNumber = 6;
    private double maxChangeSlope_;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public double MaxChangeSlope {
      get { return maxChangeSlope_; }
      set {
        maxChangeSlope_ = value;
      }
    }

    /// <summary>Field number for the "HighLengthMicroSecond" field.</summary>
    public const int HighLengthMicroSecondFieldNumber = 7;
    private double highLengthMicroSecond_;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public double HighLengthMicroSecond {
      get { return highLengthMicroSecond_; }
      set {
        highLengthMicroSecond_ = value;
      }
    }

    /// <summary>Field number for the "SpeedMaster" field.</summary>
    public const int SpeedMasterFieldNumber = 8;
    private bool speedMaster_;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public bool SpeedMaster {
      get { return speedMaster_; }
      set {
        speedMaster_ = value;
      }
    }

    /// <summary>Field number for the "PulsePerRound" field.</summary>
    public const int PulsePerRoundFieldNumber = 9;
    private int pulsePerRound_;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public int PulsePerRound {
      get { return pulsePerRound_; }
      set {
        pulsePerRound_ = value;
      }
    }

    /// <summary>Field number for the "PulleyRadius" field.</summary>
    public const int PulleyRadiusFieldNumber = 10;
    private double pulleyRadius_;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public double PulleyRadius {
      get { return pulleyRadius_; }
      set {
        pulleyRadius_ = value;
      }
    }

    /// <summary>Field number for the "ConfigWord" field.</summary>
    public const int ConfigWordFieldNumber = 11;
    private int configWord_;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public int ConfigWord {
      get { return configWord_; }
      set {
        configWord_ = value;
      }
    }

    /// <summary>Field number for the "DirectionThreadWize" field.</summary>
    public const int DirectionThreadWizeFieldNumber = 12;
    private bool directionThreadWize_;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public bool DirectionThreadWize {
      get { return directionThreadWize_; }
      set {
        directionThreadWize_ = value;
      }
    }

    /// <summary>Field number for the "KvalHold" field.</summary>
    public const int KvalHoldFieldNumber = 13;
    private int kvalHold_;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public int KvalHold {
      get { return kvalHold_; }
      set {
        kvalHold_ = value;
      }
    }

    /// <summary>Field number for the "KvalRun" field.</summary>
    public const int KvalRunFieldNumber = 14;
    private int kvalRun_;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public int KvalRun {
      get { return kvalRun_; }
      set {
        kvalRun_ = value;
      }
    }

    /// <summary>Field number for the "KvalAcc" field.</summary>
    public const int KvalAccFieldNumber = 15;
    private int kvalAcc_;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public int KvalAcc {
      get { return kvalAcc_; }
      set {
        kvalAcc_ = value;
      }
    }

    /// <summary>Field number for the "KvalDec" field.</summary>
    public const int KvalDecFieldNumber = 16;
    private int kvalDec_;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public int KvalDec {
      get { return kvalDec_; }
      set {
        kvalDec_ = value;
      }
    }

    /// <summary>Field number for the "OverCurrentThreshold" field.</summary>
    public const int OverCurrentThresholdFieldNumber = 17;
    private int overCurrentThreshold_;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public int OverCurrentThreshold {
      get { return overCurrentThreshold_; }
      set {
        overCurrentThreshold_ = value;
      }
    }

    /// <summary>Field number for the "StallThreshold" field.</summary>
    public const int StallThresholdFieldNumber = 18;
    private int stallThreshold_;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public int StallThreshold {
      get { return stallThreshold_; }
      set {
        stallThreshold_ = value;
      }
    }

    /// <summary>Field number for the "ThermalCompensationFactor" field.</summary>
    public const int ThermalCompensationFactorFieldNumber = 19;
    private int thermalCompensationFactor_;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public int ThermalCompensationFactor {
      get { return thermalCompensationFactor_; }
      set {
        thermalCompensationFactor_ = value;
      }
    }

    /// <summary>Field number for the "LowSpeedOptimization" field.</summary>
    public const int LowSpeedOptimizationFieldNumber = 20;
    private bool lowSpeedOptimization_;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public bool LowSpeedOptimization {
      get { return lowSpeedOptimization_; }
      set {
        lowSpeedOptimization_ = value;
      }
    }

    /// <summary>Field number for the "StSlp" field.</summary>
    public const int StSlpFieldNumber = 21;
    private int stSlp_;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public int StSlp {
      get { return stSlp_; }
      set {
        stSlp_ = value;
      }
    }

    /// <summary>Field number for the "IntSpd" field.</summary>
    public const int IntSpdFieldNumber = 22;
    private int intSpd_;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public int IntSpd {
      get { return intSpd_; }
      set {
        intSpd_ = value;
      }
    }

    /// <summary>Field number for the "FnSlpAcc" field.</summary>
    public const int FnSlpAccFieldNumber = 23;
    private int fnSlpAcc_;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public int FnSlpAcc {
      get { return fnSlpAcc_; }
      set {
        fnSlpAcc_ = value;
      }
    }

    /// <summary>Field number for the "FnSlpDec" field.</summary>
    public const int FnSlpDecFieldNumber = 24;
    private int fnSlpDec_;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public int FnSlpDec {
      get { return fnSlpDec_; }
      set {
        fnSlpDec_ = value;
      }
    }

    /// <summary>Field number for the "FsSpd" field.</summary>
    public const int FsSpdFieldNumber = 25;
    private int fsSpd_;
    /// <summary>
    ///The speed in which the motor moves to full step operation.
    /// </summary>
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public int FsSpd {
      get { return fsSpd_; }
      set {
        fsSpd_ = value;
      }
    }

    /// <summary>Field number for the "GateCfg1" field.</summary>
    public const int GateCfg1FieldNumber = 26;
    private int gateCfg1_;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public int GateCfg1 {
      get { return gateCfg1_; }
      set {
        gateCfg1_ = value;
      }
    }

    /// <summary>Field number for the "GateCfg2" field.</summary>
    public const int GateCfg2FieldNumber = 27;
    private int gateCfg2_;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public int GateCfg2 {
      get { return gateCfg2_; }
      set {
        gateCfg2_ = value;
      }
    }

    /// <summary>Field number for the "TValHold" field.</summary>
    public const int TValHoldFieldNumber = 28;
    private int tValHold_;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public int TValHold {
      get { return tValHold_; }
      set {
        tValHold_ = value;
      }
    }

    /// <summary>Field number for the "TValRun" field.</summary>
    public const int TValRunFieldNumber = 29;
    private int tValRun_;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public int TValRun {
      get { return tValRun_; }
      set {
        tValRun_ = value;
      }
    }

    /// <summary>Field number for the "TValAcc" field.</summary>
    public const int TValAccFieldNumber = 30;
    private int tValAcc_;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public int TValAcc {
      get { return tValAcc_; }
      set {
        tValAcc_ = value;
      }
    }

    /// <summary>Field number for the "TValDec" field.</summary>
    public const int TValDecFieldNumber = 31;
    private int tValDec_;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public int TValDec {
      get { return tValDec_; }
      set {
        tValDec_ = value;
      }
    }

    /// <summary>Field number for the "TFast" field.</summary>
    public const int TFastFieldNumber = 32;
    private int tFast_;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public int TFast {
      get { return tFast_; }
      set {
        tFast_ = value;
      }
    }

    /// <summary>Field number for the "TOnMin" field.</summary>
    public const int TOnMinFieldNumber = 33;
    private int tOnMin_;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public int TOnMin {
      get { return tOnMin_; }
      set {
        tOnMin_ = value;
      }
    }

    /// <summary>Field number for the "TOffMin" field.</summary>
    public const int TOffMinFieldNumber = 34;
    private int tOffMin_;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public int TOffMin {
      get { return tOffMin_; }
      set {
        tOffMin_ = value;
      }
    }

    /// <summary>Field number for the "P01ConfigWord" field.</summary>
    public const int P01ConfigWordFieldNumber = 35;
    private int p01ConfigWord_;
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public int P01ConfigWord {
      get { return p01ConfigWord_; }
      set {
        p01ConfigWord_ = value;
      }
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public override bool Equals(object other) {
      return Equals(other as HardwareMotor);
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public bool Equals(HardwareMotor other) {
      if (ReferenceEquals(other, null)) {
        return false;
      }
      if (ReferenceEquals(other, this)) {
        return true;
      }
      if (HardwareMotorType != other.HardwareMotorType) return false;
      if (MinFrequency != other.MinFrequency) return false;
      if (MaxFrequency != other.MaxFrequency) return false;
      if (SetMicroStep != other.SetMicroStep) return false;
      if (MicroStep != other.MicroStep) return false;
      if (MaxChangeSlope != other.MaxChangeSlope) return false;
      if (HighLengthMicroSecond != other.HighLengthMicroSecond) return false;
      if (SpeedMaster != other.SpeedMaster) return false;
      if (PulsePerRound != other.PulsePerRound) return false;
      if (PulleyRadius != other.PulleyRadius) return false;
      if (ConfigWord != other.ConfigWord) return false;
      if (DirectionThreadWize != other.DirectionThreadWize) return false;
      if (KvalHold != other.KvalHold) return false;
      if (KvalRun != other.KvalRun) return false;
      if (KvalAcc != other.KvalAcc) return false;
      if (KvalDec != other.KvalDec) return false;
      if (OverCurrentThreshold != other.OverCurrentThreshold) return false;
      if (StallThreshold != other.StallThreshold) return false;
      if (ThermalCompensationFactor != other.ThermalCompensationFactor) return false;
      if (LowSpeedOptimization != other.LowSpeedOptimization) return false;
      if (StSlp != other.StSlp) return false;
      if (IntSpd != other.IntSpd) return false;
      if (FnSlpAcc != other.FnSlpAcc) return false;
      if (FnSlpDec != other.FnSlpDec) return false;
      if (FsSpd != other.FsSpd) return false;
      if (GateCfg1 != other.GateCfg1) return false;
      if (GateCfg2 != other.GateCfg2) return false;
      if (TValHold != other.TValHold) return false;
      if (TValRun != other.TValRun) return false;
      if (TValAcc != other.TValAcc) return false;
      if (TValDec != other.TValDec) return false;
      if (TFast != other.TFast) return false;
      if (TOnMin != other.TOnMin) return false;
      if (TOffMin != other.TOffMin) return false;
      if (P01ConfigWord != other.P01ConfigWord) return false;
      return true;
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public override int GetHashCode() {
      int hash = 1;
      if (HardwareMotorType != 0) hash ^= HardwareMotorType.GetHashCode();
      if (MinFrequency != 0) hash ^= MinFrequency.GetHashCode();
      if (MaxFrequency != 0) hash ^= MaxFrequency.GetHashCode();
      if (SetMicroStep != 0) hash ^= SetMicroStep.GetHashCode();
      if (MicroStep != 0) hash ^= MicroStep.GetHashCode();
      if (MaxChangeSlope != 0D) hash ^= MaxChangeSlope.GetHashCode();
      if (HighLengthMicroSecond != 0D) hash ^= HighLengthMicroSecond.GetHashCode();
      if (SpeedMaster != false) hash ^= SpeedMaster.GetHashCode();
      if (PulsePerRound != 0) hash ^= PulsePerRound.GetHashCode();
      if (PulleyRadius != 0D) hash ^= PulleyRadius.GetHashCode();
      if (ConfigWord != 0) hash ^= ConfigWord.GetHashCode();
      if (DirectionThreadWize != false) hash ^= DirectionThreadWize.GetHashCode();
      if (KvalHold != 0) hash ^= KvalHold.GetHashCode();
      if (KvalRun != 0) hash ^= KvalRun.GetHashCode();
      if (KvalAcc != 0) hash ^= KvalAcc.GetHashCode();
      if (KvalDec != 0) hash ^= KvalDec.GetHashCode();
      if (OverCurrentThreshold != 0) hash ^= OverCurrentThreshold.GetHashCode();
      if (StallThreshold != 0) hash ^= StallThreshold.GetHashCode();
      if (ThermalCompensationFactor != 0) hash ^= ThermalCompensationFactor.GetHashCode();
      if (LowSpeedOptimization != false) hash ^= LowSpeedOptimization.GetHashCode();
      if (StSlp != 0) hash ^= StSlp.GetHashCode();
      if (IntSpd != 0) hash ^= IntSpd.GetHashCode();
      if (FnSlpAcc != 0) hash ^= FnSlpAcc.GetHashCode();
      if (FnSlpDec != 0) hash ^= FnSlpDec.GetHashCode();
      if (FsSpd != 0) hash ^= FsSpd.GetHashCode();
      if (GateCfg1 != 0) hash ^= GateCfg1.GetHashCode();
      if (GateCfg2 != 0) hash ^= GateCfg2.GetHashCode();
      if (TValHold != 0) hash ^= TValHold.GetHashCode();
      if (TValRun != 0) hash ^= TValRun.GetHashCode();
      if (TValAcc != 0) hash ^= TValAcc.GetHashCode();
      if (TValDec != 0) hash ^= TValDec.GetHashCode();
      if (TFast != 0) hash ^= TFast.GetHashCode();
      if (TOnMin != 0) hash ^= TOnMin.GetHashCode();
      if (TOffMin != 0) hash ^= TOffMin.GetHashCode();
      if (P01ConfigWord != 0) hash ^= P01ConfigWord.GetHashCode();
      return hash;
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public override string ToString() {
      return pb::JsonFormatter.ToDiagnosticString(this);
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public void WriteTo(pb::CodedOutputStream output) {
      if (HardwareMotorType != 0) {
        output.WriteRawTag(8);
        output.WriteEnum((int) HardwareMotorType);
      }
      if (MinFrequency != 0) {
        output.WriteRawTag(16);
        output.WriteInt32(MinFrequency);
      }
      if (MaxFrequency != 0) {
        output.WriteRawTag(24);
        output.WriteInt32(MaxFrequency);
      }
      if (SetMicroStep != 0) {
        output.WriteRawTag(32);
        output.WriteInt32(SetMicroStep);
      }
      if (MicroStep != 0) {
        output.WriteRawTag(40);
        output.WriteInt32(MicroStep);
      }
      if (MaxChangeSlope != 0D) {
        output.WriteRawTag(49);
        output.WriteDouble(MaxChangeSlope);
      }
      if (HighLengthMicroSecond != 0D) {
        output.WriteRawTag(57);
        output.WriteDouble(HighLengthMicroSecond);
      }
      if (SpeedMaster != false) {
        output.WriteRawTag(64);
        output.WriteBool(SpeedMaster);
      }
      if (PulsePerRound != 0) {
        output.WriteRawTag(72);
        output.WriteInt32(PulsePerRound);
      }
      if (PulleyRadius != 0D) {
        output.WriteRawTag(81);
        output.WriteDouble(PulleyRadius);
      }
      if (ConfigWord != 0) {
        output.WriteRawTag(88);
        output.WriteInt32(ConfigWord);
      }
      if (DirectionThreadWize != false) {
        output.WriteRawTag(96);
        output.WriteBool(DirectionThreadWize);
      }
      if (KvalHold != 0) {
        output.WriteRawTag(104);
        output.WriteInt32(KvalHold);
      }
      if (KvalRun != 0) {
        output.WriteRawTag(112);
        output.WriteInt32(KvalRun);
      }
      if (KvalAcc != 0) {
        output.WriteRawTag(120);
        output.WriteInt32(KvalAcc);
      }
      if (KvalDec != 0) {
        output.WriteRawTag(128, 1);
        output.WriteInt32(KvalDec);
      }
      if (OverCurrentThreshold != 0) {
        output.WriteRawTag(136, 1);
        output.WriteInt32(OverCurrentThreshold);
      }
      if (StallThreshold != 0) {
        output.WriteRawTag(144, 1);
        output.WriteInt32(StallThreshold);
      }
      if (ThermalCompensationFactor != 0) {
        output.WriteRawTag(152, 1);
        output.WriteInt32(ThermalCompensationFactor);
      }
      if (LowSpeedOptimization != false) {
        output.WriteRawTag(160, 1);
        output.WriteBool(LowSpeedOptimization);
      }
      if (StSlp != 0) {
        output.WriteRawTag(168, 1);
        output.WriteInt32(StSlp);
      }
      if (IntSpd != 0) {
        output.WriteRawTag(176, 1);
        output.WriteInt32(IntSpd);
      }
      if (FnSlpAcc != 0) {
        output.WriteRawTag(184, 1);
        output.WriteInt32(FnSlpAcc);
      }
      if (FnSlpDec != 0) {
        output.WriteRawTag(192, 1);
        output.WriteInt32(FnSlpDec);
      }
      if (FsSpd != 0) {
        output.WriteRawTag(200, 1);
        output.WriteInt32(FsSpd);
      }
      if (GateCfg1 != 0) {
        output.WriteRawTag(208, 1);
        output.WriteInt32(GateCfg1);
      }
      if (GateCfg2 != 0) {
        output.WriteRawTag(216, 1);
        output.WriteInt32(GateCfg2);
      }
      if (TValHold != 0) {
        output.WriteRawTag(224, 1);
        output.WriteInt32(TValHold);
      }
      if (TValRun != 0) {
        output.WriteRawTag(232, 1);
        output.WriteInt32(TValRun);
      }
      if (TValAcc != 0) {
        output.WriteRawTag(240, 1);
        output.WriteInt32(TValAcc);
      }
      if (TValDec != 0) {
        output.WriteRawTag(248, 1);
        output.WriteInt32(TValDec);
      }
      if (TFast != 0) {
        output.WriteRawTag(128, 2);
        output.WriteInt32(TFast);
      }
      if (TOnMin != 0) {
        output.WriteRawTag(136, 2);
        output.WriteInt32(TOnMin);
      }
      if (TOffMin != 0) {
        output.WriteRawTag(144, 2);
        output.WriteInt32(TOffMin);
      }
      if (P01ConfigWord != 0) {
        output.WriteRawTag(152, 2);
        output.WriteInt32(P01ConfigWord);
      }
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public int CalculateSize() {
      int size = 0;
      if (HardwareMotorType != 0) {
        size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) HardwareMotorType);
      }
      if (MinFrequency != 0) {
        size += 1 + pb::CodedOutputStream.ComputeInt32Size(MinFrequency);
      }
      if (MaxFrequency != 0) {
        size += 1 + pb::CodedOutputStream.ComputeInt32Size(MaxFrequency);
      }
      if (SetMicroStep != 0) {
        size += 1 + pb::CodedOutputStream.ComputeInt32Size(SetMicroStep);
      }
      if (MicroStep != 0) {
        size += 1 + pb::CodedOutputStream.ComputeInt32Size(MicroStep);
      }
      if (MaxChangeSlope != 0D) {
        size += 1 + 8;
      }
      if (HighLengthMicroSecond != 0D) {
        size += 1 + 8;
      }
      if (SpeedMaster != false) {
        size += 1 + 1;
      }
      if (PulsePerRound != 0) {
        size += 1 + pb::CodedOutputStream.ComputeInt32Size(PulsePerRound);
      }
      if (PulleyRadius != 0D) {
        size += 1 + 8;
      }
      if (ConfigWord != 0) {
        size += 1 + pb::CodedOutputStream.ComputeInt32Size(ConfigWord);
      }
      if (DirectionThreadWize != false) {
        size += 1 + 1;
      }
      if (KvalHold != 0) {
        size += 1 + pb::CodedOutputStream.ComputeInt32Size(KvalHold);
      }
      if (KvalRun != 0) {
        size += 1 + pb::CodedOutputStream.ComputeInt32Size(KvalRun);
      }
      if (KvalAcc != 0) {
        size += 1 + pb::CodedOutputStream.ComputeInt32Size(KvalAcc);
      }
      if (KvalDec != 0) {
        size += 2 + pb::CodedOutputStream.ComputeInt32Size(KvalDec);
      }
      if (OverCurrentThreshold != 0) {
        size += 2 + pb::CodedOutputStream.ComputeInt32Size(OverCurrentThreshold);
      }
      if (StallThreshold != 0) {
        size += 2 + pb::CodedOutputStream.ComputeInt32Size(StallThreshold);
      }
      if (ThermalCompensationFactor != 0) {
        size += 2 + pb::CodedOutputStream.ComputeInt32Size(ThermalCompensationFactor);
      }
      if (LowSpeedOptimization != false) {
        size += 2 + 1;
      }
      if (StSlp != 0) {
        size += 2 + pb::CodedOutputStream.ComputeInt32Size(StSlp);
      }
      if (IntSpd != 0) {
        size += 2 + pb::CodedOutputStream.ComputeInt32Size(IntSpd);
      }
      if (FnSlpAcc != 0) {
        size += 2 + pb::CodedOutputStream.ComputeInt32Size(FnSlpAcc);
      }
      if (FnSlpDec != 0) {
        size += 2 + pb::CodedOutputStream.ComputeInt32Size(FnSlpDec);
      }
      if (FsSpd != 0) {
        size += 2 + pb::CodedOutputStream.ComputeInt32Size(FsSpd);
      }
      if (GateCfg1 != 0) {
        size += 2 + pb::CodedOutputStream.ComputeInt32Size(GateCfg1);
      }
      if (GateCfg2 != 0) {
        size += 2 + pb::CodedOutputStream.ComputeInt32Size(GateCfg2);
      }
      if (TValHold != 0) {
        size += 2 + pb::CodedOutputStream.ComputeInt32Size(TValHold);
      }
      if (TValRun != 0) {
        size += 2 + pb::CodedOutputStream.ComputeInt32Size(TValRun);
      }
      if (TValAcc != 0) {
        size += 2 + pb::CodedOutputStream.ComputeInt32Size(TValAcc);
      }
      if (TValDec != 0) {
        size += 2 + pb::CodedOutputStream.ComputeInt32Size(TValDec);
      }
      if (TFast != 0) {
        size += 2 + pb::CodedOutputStream.ComputeInt32Size(TFast);
      }
      if (TOnMin != 0) {
        size += 2 + pb::CodedOutputStream.ComputeInt32Size(TOnMin);
      }
      if (TOffMin != 0) {
        size += 2 + pb::CodedOutputStream.ComputeInt32Size(TOffMin);
      }
      if (P01ConfigWord != 0) {
        size += 2 + pb::CodedOutputStream.ComputeInt32Size(P01ConfigWord);
      }
      return size;
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public void MergeFrom(HardwareMotor other) {
      if (other == null) {
        return;
      }
      if (other.HardwareMotorType != 0) {
        HardwareMotorType = other.HardwareMotorType;
      }
      if (other.MinFrequency != 0) {
        MinFrequency = other.MinFrequency;
      }
      if (other.MaxFrequency != 0) {
        MaxFrequency = other.MaxFrequency;
      }
      if (other.SetMicroStep != 0) {
        SetMicroStep = other.SetMicroStep;
      }
      if (other.MicroStep != 0) {
        MicroStep = other.MicroStep;
      }
      if (other.MaxChangeSlope != 0D) {
        MaxChangeSlope = other.MaxChangeSlope;
      }
      if (other.HighLengthMicroSecond != 0D) {
        HighLengthMicroSecond = other.HighLengthMicroSecond;
      }
      if (other.SpeedMaster != false) {
        SpeedMaster = other.SpeedMaster;
      }
      if (other.PulsePerRound != 0) {
        PulsePerRound = other.PulsePerRound;
      }
      if (other.PulleyRadius != 0D) {
        PulleyRadius = other.PulleyRadius;
      }
      if (other.ConfigWord != 0) {
        ConfigWord = other.ConfigWord;
      }
      if (other.DirectionThreadWize != false) {
        DirectionThreadWize = other.DirectionThreadWize;
      }
      if (other.KvalHold != 0) {
        KvalHold = other.KvalHold;
      }
      if (other.KvalRun != 0) {
        KvalRun = other.KvalRun;
      }
      if (other.KvalAcc != 0) {
        KvalAcc = other.KvalAcc;
      }
      if (other.KvalDec != 0) {
        KvalDec = other.KvalDec;
      }
      if (other.OverCurrentThreshold != 0) {
        OverCurrentThreshold = other.OverCurrentThreshold;
      }
      if (other.StallThreshold != 0) {
        StallThreshold = other.StallThreshold;
      }
      if (other.ThermalCompensationFactor != 0) {
        ThermalCompensationFactor = other.ThermalCompensationFactor;
      }
      if (other.LowSpeedOptimization != false) {
        LowSpeedOptimization = other.LowSpeedOptimization;
      }
      if (other.StSlp != 0) {
        StSlp = other.StSlp;
      }
      if (other.IntSpd != 0) {
        IntSpd = other.IntSpd;
      }
      if (other.FnSlpAcc != 0) {
        FnSlpAcc = other.FnSlpAcc;
      }
      if (other.FnSlpDec != 0) {
        FnSlpDec = other.FnSlpDec;
      }
      if (other.FsSpd != 0) {
        FsSpd = other.FsSpd;
      }
      if (other.GateCfg1 != 0) {
        GateCfg1 = other.GateCfg1;
      }
      if (other.GateCfg2 != 0) {
        GateCfg2 = other.GateCfg2;
      }
      if (other.TValHold != 0) {
        TValHold = other.TValHold;
      }
      if (other.TValRun != 0) {
        TValRun = other.TValRun;
      }
      if (other.TValAcc != 0) {
        TValAcc = other.TValAcc;
      }
      if (other.TValDec != 0) {
        TValDec = other.TValDec;
      }
      if (other.TFast != 0) {
        TFast = other.TFast;
      }
      if (other.TOnMin != 0) {
        TOnMin = other.TOnMin;
      }
      if (other.TOffMin != 0) {
        TOffMin = other.TOffMin;
      }
      if (other.P01ConfigWord != 0) {
        P01ConfigWord = other.P01ConfigWord;
      }
    }

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
    public void MergeFrom(pb::CodedInputStream input) {
      uint tag;
      while ((tag = input.ReadTag()) != 0) {
        switch(tag) {
          default:
            input.SkipLastField();
            break;
          case 8: {
            hardwareMotorType_ = (global::Tango.PMR.Hardware.HardwareMotorType) input.ReadEnum();
            break;
          }
          case 16: {
            MinFrequency = input.ReadInt32();
            break;
          }
          case 24: {
            MaxFrequency = input.ReadInt32();
            break;
          }
          case 32: {
            SetMicroStep = input.ReadInt32();
            break;
          }
          case 40: {
            MicroStep = input.ReadInt32();
            break;
          }
          case 49: {
            MaxChangeSlope = input.ReadDouble();
            break;
          }
          case 57: {
            HighLengthMicroSecond = input.ReadDouble();
            break;
          }
          case 64: {
            SpeedMaster = input.ReadBool();
            break;
          }
          case 72: {
            PulsePerRound = input.ReadInt32();
            break;
          }
          case 81: {
            PulleyRadius = input.ReadDouble();
            break;
          }
          case 88: {
            ConfigWord = input.ReadInt32();
            break;
          }
          case 96: {
            DirectionThreadWize = input.ReadBool();
            break;
          }
          case 104: {
            KvalHold = input.ReadInt32();
            break;
          }
          case 112: {
            KvalRun = input.ReadInt32();
            break;
          }
          case 120: {
            KvalAcc = input.ReadInt32();
            break;
          }
          case 128: {
            KvalDec = input.ReadInt32();
            break;
          }
          case 136: {
            OverCurrentThreshold = input.ReadInt32();
            break;
          }
          case 144: {
            StallThreshold = input.ReadInt32();
            break;
          }
          case 152: {
            ThermalCompensationFactor = input.ReadInt32();
            break;
          }
          case 160: {
            LowSpeedOptimization = input.ReadBool();
            break;
          }
          case 168: {
            StSlp = input.ReadInt32();
            break;
          }
          case 176: {
            IntSpd = input.ReadInt32();
            break;
          }
          case 184: {
            FnSlpAcc = input.ReadInt32();
            break;
          }
          case 192: {
            FnSlpDec = input.ReadInt32();
            break;
          }
          case 200: {
            FsSpd = input.ReadInt32();
            break;
          }
          case 208: {
            GateCfg1 = input.ReadInt32();
            break;
          }
          case 216: {
            GateCfg2 = input.ReadInt32();
            break;
          }
          case 224: {
            TValHold = input.ReadInt32();
            break;
          }
          case 232: {
            TValRun = input.ReadInt32();
            break;
          }
          case 240: {
            TValAcc = input.ReadInt32();
            break;
          }
          case 248: {
            TValDec = input.ReadInt32();
            break;
          }
          case 256: {
            TFast = input.ReadInt32();
            break;
          }
          case 264: {
            TOnMin = input.ReadInt32();
            break;
          }
          case 272: {
            TOffMin = input.ReadInt32();
            break;
          }
          case 280: {
            P01ConfigWord = input.ReadInt32();
            break;
          }
        }
      }
    }

  }

  #endregion

}

#endregion Designer generated code