Code covered by the BSD License  

Highlights from
Matlab LibTiePie 0.4.3 instrument driver for Handyscope HS5

Matlab LibTiePie 0.4.3 instrument driver for Handyscope HS5

by

 

03 Oct 2013 (Updated )

MatlabLibTiePie : TiePie engineering's instrument library for Matlab 7.6 = 2008a and higher.

LibTiePie.Device
% LibTiePie.Device is a common ancestor for test and measurement devices in LibTiePie.
%
% For more information, see api.tiepie.com and www.tiepie.com/LibTiePie .
%
% (c) 2012-2013 TiePie engineering.

classdef Device < handle
  properties ( Access = protected )
    sLibrary;
  end
  properties ( SetAccess = private , Hidden = true )
    oLibTiePie;
    hDevice;
  end
  properties ( SetAccess = private )
    SerialNumber;
    Name;
    NameShort;
    ProductId;
    VendorId;
    DriverVersionString;
    FirmwareVersionString;
    CalibrationDateString;
    Type;
  end
  properties ( SetAccess = private )
    TriggerInputCount;
    TriggerInputs = LibTiePie.TriggerInput.empty;
    TriggerOutputCount;
    TriggerOutputs = LibTiePie.TriggerOutput.empty;
  end

  methods
    function obj = Device( oLibTiePie , hDevice )
      if ( nargin < 2 )
        error( 'Do not create LibTiePie.Device directly, but use LibTiePie.List.' )
        return
      end
      obj.sLibrary = oLibTiePie.sLibrary;
      obj.oLibTiePie = oLibTiePie;
      obj.hDevice = hDevice;
      for k = 1:obj.TriggerInputCount
        obj.TriggerInputs( k ) = LibTiePie.TriggerInput( obj , k );
      end
      for k = 1:obj.TriggerOutputCount
        obj.TriggerOutputs( k ) = LibTiePie.TriggerOutput( obj , k );
      end
    end

    function delete( self )
      calllib( self.sLibrary , 'DevClose' , self.hDevice );
      self.oLibTiePie = 0; % Release reference.
    end;

    function bIsRemoved = IsRemoved( self )
      bIsRemoved = calllib( self.sLibrary , 'DevIsRemoved' , self.hDevice );
    end

    function dwSerialNumber = get.SerialNumber( self )
      dwSerialNumber = calllib( self.sLibrary , 'DevGetSerialNumber' , self.hDevice );
    end

    function sName = get.Name( self )
      dwLength = calllib( self.sLibrary , 'DevGetName' , self.hDevice , [] , 0 );
      [ dwLength , sName ] = calllib( self.sLibrary , 'DevGetName' , self.hDevice , blanks( dwLength ) , dwLength );
      sName = native2unicode( uint8( sName ) , 'UTF-8' );
    end;

    function sNameShort = get.NameShort( self )
      dwLength = calllib( self.sLibrary , 'DevGetNameShort' , self.hDevice , [] , 0 );
      [ dwLength , sNameShort ] = calllib( self.sLibrary , 'DevGetNameShort' , self.hDevice , blanks( dwLength ) , dwLength );
      sNameShort = native2unicode( uint8( sNameShort ) , 'UTF-8' );
    end;

    function dwProductId = get.ProductId( self )
      dwProductId = calllib( self.sLibrary , 'DevGetProductId' , self.hDevice );
    end;

    function dwVendorId = get.VendorId( self )
      dwVendorId = calllib( self.sLibrary , 'DevGetVendorId' , self.hDevice );
    end;

    function qwDriverVersion = DriverVersion( self )
      qwDriverVersion = calllib( self.sLibrary , 'DevGetDriverVersion' , self.hDevice );
    end

    function sDriverVersion = get.DriverVersionString( self )
      sDriverVersion = LibTiePie.VersionNumber2String( self.DriverVersion );
    end

    function qwFirmwareVersion = FirmwareVersion( self )
      qwFirmwareVersion = calllib( self.sLibrary , 'DevGetFirmwareVersion' , self.hDevice );
    end

    function sFirmwareVersion = get.FirmwareVersionString( self )
      sFirmwareVersion = LibTiePie.VersionNumber2String( self.FirmwareVersion );
    end

    function CalibrationDate = CalibrationDate( self )
      dwCalibrationDate = calllib( self.sLibrary , 'DevGetCalibrationDate' , self.hDevice );
      wYear = bitand( bitshift( dwCalibrationDate , -16 ) , 65535 );
      byMonth = bitand( bitshift( dwCalibrationDate , -8 ) , 255 );
      byDay = bitand( dwCalibrationDate , 255 );
      CalibrationDate = datenum( wYear , byMonth , byDay );
    end

    function sCalibrationDate = get.CalibrationDateString( self )
      sCalibrationDate = datestr( self.CalibrationDate );
    end

    function dwType = get.Type( self )
      dwType = LibTiePie.Enum.DEVICETYPE( calllib( self.sLibrary , 'DevGetType' , self.hDevice ) );
    end
  end
  methods
    function wTriggerInputCount = get.TriggerInputCount( self )
      wTriggerInputCount = calllib( self.sLibrary , 'DevTrGetInputCount' , self.hDevice );
    end
    function wTriggerOutputCount = get.TriggerOutputCount( self )
      wTriggerOutputCount = calllib( self.sLibrary , 'DevTrGetOutputCount' , self.hDevice );
    end
  end
end

Contact us