Exemple #1
0
      public bool ReadDeviceType(ref UInt32 deviceType)
      {
         bool result = true;

         SDOUpload upload = new SDOUpload(0x1000, 0);
         result &= this.ExchangeCommAction(upload);

         if ((false != result) &&
             (null != upload.Data) &&
             (4 >= upload.Data.Length))
         {
            deviceType = BitConverter.ToUInt32(upload.Data, 0);
         }

         return (result);
      }
Exemple #2
0
      public bool ReadDeviceVersion(ref string deviceVersion)
      {
         bool result = true;

         SDOUpload upload = new SDOUpload(0x100A, 0);
         result &= this.ExchangeCommAction(upload);

         if ((false != result) &&
             (null != upload.Data))
         {
            deviceVersion = Encoding.UTF8.GetString(upload.Data);
         }

         return (result);
      }
Exemple #3
0
      public virtual byte[] SDOUpLoad(UInt16 index, byte subIndex)
      {
         byte[] result = null;
         SDOUpload upload = new SDOUpload(index, subIndex);

         this.pendingAction = upload;
         this.ScheduleAction(this.pendingAction);

         this.commEvent.Reset();
         bool actionResult = this.commEvent.WaitOne(500);

         if (false != actionResult)
         {
            result = upload.Data;
         }

         return (result);
      }
Exemple #4
0
      public bool Read(UInt16 index, byte subIndex, ref UInt16 value)
      {
         bool result = true;

         SDOUpload upload = new SDOUpload(index, subIndex);
         result &= this.ExchangeCommAction(upload);

         if ((false != result) &&
             (null != upload.Data) &&
             (2 >= upload.Data.Length))
         {
            value = BitConverter.ToUInt16(upload.Data, 0);
         }

         return (result);
      }
Exemple #5
0
      protected bool ReadSDO(UInt16 index, byte subIndex, ref UInt32 value)
      {
         bool result = false;

         if (null == this.FaultReason)
         {
            SDOUpload upload = new SDOUpload(index, subIndex);
            result = this.ExchangeCommAction(upload);

            if ((false != result) &&
                (null != upload.Data) &&
                (4 >= upload.Data.Length))
            {
               value = BitConverter.ToUInt32(upload.Data, 0);
               result = true;
            }
            else
            {
               result = false;
            }
         }

         return (result);
      }
      public bool GetDeviceType(ref UInt32 deviceType)
      {
         SDOUpload upload = new SDOUpload(0x1000, 0);
         this.pendingAction = upload;
         bool actionResult = this.ExchangeCommAction(this.pendingAction);

         if (false != actionResult)
         {
            if ((null != upload.Data) && (upload.Data.Length >= 4))
            {
               deviceType = BitConverter.ToUInt32(upload.Data, 0);
            }
            else
            {
               actionResult = false;
            }
         }

         return (actionResult);
      }
      public byte GetDeviceNodeId()
      {
         byte result = 0;
         SDOUpload upload = new SDOUpload(0x2101, 0);

         this.pendingAction = upload;
         this.ScheduleAction(this.pendingAction);

         bool actionResult = this.commEvent.WaitOne(500);

         if (false != actionResult)
         {
            if (null != upload.Data)
            {
               result = upload.Data[0];
            }
         }

         return (result);
      }
      public int GetDeviceBaudRate()
      {
         int result = 0;
         SDOUpload upload = new SDOUpload(0x2100, 0);

         this.pendingAction = upload;
         this.ScheduleAction(this.pendingAction);

         bool actionResult = this.commEvent.WaitOne(500);

         if (false != actionResult)
         {
            if (null != upload.Data)
            {
               byte baudCode = upload.Data[0];

               if (0 == baudCode)
               {
                  result = 10000;
               }
               else if (1 == baudCode)
               {
                  result = 20000;
               }
               else if (2 == baudCode)
               {
                  result = 50000;
               }
               else if (3 == baudCode)
               {
                  result = 100000;
               }
               else if (4 == baudCode)
               {
                  result = 125000;
               }
               else if (5 == baudCode)
               {
                  result = 250000;
               }
               else if (6 == baudCode)
               {
                  result = 500000;
               }
               else if (7 == baudCode)
               {
                  result = 1000000;
               }
            }
         }

         return (result);
      }
      public bool GetDeviceNodeOffset(ref byte nodeOffset)
      {
         SDOUpload upload = new SDOUpload(0x2102, 0);
         this.pendingAction = upload;
         bool actionResult = this.ExchangeCommAction(this.pendingAction);

         if (false != actionResult)
         {
            if (null != upload.Data)
            {
               nodeOffset = upload.Data[0];
            }
         }

         return (actionResult);
      }