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

TiePie engineering

 

03 Oct 2013 (Updated )

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

LibTiePie.List
% LibTiePie.List is the device list object in LibTiePie.
%
% For more information, see api.tiepie.com and www.tiepie.com/LibTiePie .
%
% (c) 2012-2013 TiePie engineering.

classdef List < handle
  properties ( Access = protected )
    sLibrary;
    oLibTiePie;
  end
  properties ( SetAccess = private )
    Count;
  end
  properties ( Access = private , Constant )
    IDM_ALL = hex2dec( 'FFFFFFFF' );
  end

  methods
    function obj = List( oLibTiePie )
      if ( nargin < 1 )
        error( 'Do not create LibTiePie.List directly, but use LibTiePie.List to get it.' )
        return
      end
      obj.sLibrary = oLibTiePie.sLibrary;
      obj.oLibTiePie = oLibTiePie;
    end

    function Update( self , dwDeviceIdMask )
      if ( nargin < 2 )
        dwDeviceIdMask = self.IDM_ALL;
      end
      calllib( self.sLibrary , 'LstUpdate' , dwDeviceIdMask );
    end

    function bDeviceCanOpen = DeviceCanOpen( self , dwIdKind , dwId , dwDeviceType )
      bDeviceCanOpen = calllib( self.sLibrary , 'LstGetDeviceCanOpen' , uint32( dwIdKind ) , uint32( dwId ) , uint32( dwDeviceType ) );
      self.oLibTiePie.CheckStatus;
    end

    function oOscilloscope = OpenOscilloscope( self , dwIdKind , dwId )
      hDevice = calllib( self.sLibrary , 'LstOpenOscilloscope' , uint32( dwIdKind ) , uint32( dwId ) );
      if self.oLibTiePie.CheckStatus
        oOscilloscope = LibTiePie.Oscilloscope( self.oLibTiePie , hDevice );
      end
    end

    function oGenerator = OpenGenerator( self , dwIdKind , dwId )
      hDevice = calllib( self.sLibrary , 'LstOpenGenerator' , uint32( dwIdKind ) , uint32( dwId ) );
      if self.oLibTiePie.CheckStatus
        oGenerator = LibTiePie.Generator( self.oLibTiePie , hDevice );
      end
    end

    function oI2CHost = OpenI2CHost( self , dwIdKind , dwId )
      hDevice = calllib( self.sLibrary , 'LstOpenI2CHost' , uint32( dwIdKind ) , uint32( dwId ) );
      if self.oLibTiePie.CheckStatus
        oI2CHost = LibTiePie.I2CHost( self.oLibTiePie , hDevice );
      end
    end

    function oDevice = OpenDevice( self , dwIdKind , dwId , dwDeviceType )
      hDevice = calllib( self.sLibrary , 'LstOpenDevice' , uint32( dwIdKind ) , uint32( dwId ) , uint32( dwDeviceType ) );
      if self.oLibTiePie.CheckStatus
        switch dwDeviceType
          case LibTiePie.Enum.DEVICETYPE.OSCILLOSCOPE
            oDevice = LibTiePie.Oscilloscope( self.oLibTiePie , hDevice );
          case LibTiePie.Enum.DEVICETYPE.GENERATOR
            oDevice = LibTiePie.Generator( self.oLibTiePie , hDevice );
          case LibTiePie.Enum.DEVICETYPE.I2CHOST
            oDevice = LibTiePie.I2CHost( self.oLibTiePie , hDevice );
          otherwise
            error( 'Unsupported device type.' );
        end
      end
    end


    function dwSerialNumber = SerialNumber( self , dwIdKind , dwId )
      dwSerialNumber = calllib( self.sLibrary , 'LstGetDeviceSerialNumber' , uint32( dwIdKind ) , uint32( dwId ) );
      self.oLibTiePie.CheckStatus;
    end

    function sDeviceName = DeviceName( self , dwIdKind , dwId )
      dwLength = calllib( self.sLibrary , 'LstGetDeviceName' , uint32( dwIdKind ) , uint32( dwId ) , [] , 0 );
      [ dwLength , sDeviceName ] = calllib( self.sLibrary , 'LstGetDeviceName' , uint32( dwIdKind ) , uint32( dwId ) , blanks( dwLength ) , dwLength );
      self.oLibTiePie.CheckStatus;
    end

    function sDeviceNameShort = DeviceNameShort( self , dwIdKind , dwId )
      dwLength = calllib( self.sLibrary , 'LstGetDeviceNameShort' , uint32( dwIdKind ) , uint32( dwId ) , [] , 0 );
      [ dwLength , sDeviceNameShort ] = calllib( self.sLibrary , 'LstGetDeviceNameShort' , uint32( dwIdKind ) , uint32( dwId ) , blanks( dwLength ) , dwLength );
      self.oLibTiePie.CheckStatus;
    end

    function dwDeviceProductId = DeviceProductId( self , dwIdKind , dwId )
      dwDeviceProductId = calllib( self.sLibrary , 'LstGetDeviceProductId' , uint32( dwIdKind ) , uint32( dwId ) );
      self.oLibTiePie.CheckStatus;
    end

    function arDeviceTypes = DeviceTypes( self , dwIdKind , dwId )
      arDeviceTypes = LibTiePie.Enum.DEVICETYPE( LibTiePie.BitMask2Array( calllib( self.sLibrary , 'LstGetDeviceTypes' , uint32( dwIdKind ) , uint32( dwId ) ) ) );
      self.oLibTiePie.CheckStatus;
    end

    function dwDeviceVendorId = DeviceVendorId( self , dwIdKind , dwId )
      dwDeviceVendorId = calllib( self.sLibrary , 'LstGetDeviceVendorId' , uint32( dwIdKind ) , uint32( dwId ) );
      self.oLibTiePie.CheckStatus;
    end

    function nDeviceDriverVersion = DeviceDriverVersion( self , dwIdKind , dwId )
      nDeviceDriverVersion = calllib( self.sLibrary , 'LstDevGetDriverVersion' , uint32( dwIdKind ) , uint32( dwId ) );
    end

    function sDeviceDriverVersion = DeviceDriverVersionString( self , dwIdKind , dwId )
      sDeviceDriverVersion = LibTiePie.VersionNumber2String( self.DeviceDriverVersion( dwIdKind , dwId ) );
    end

    function nDeviceRecommendedDriverVersion = DeviceRecommendedDriverVersion( self , dwIdKind , dwId )
      nDeviceRecommendedDriverVersion = calllib( self.sLibrary , 'LstDevGetRecommendedDriverVersion' , uint32( dwIdKind ) , uint32( dwId ) );
    end

    function sDeviceRecommendedDriverVersion = DeviceRecommendedDriverVersionString( self , dwIdKind , dwId )
      sDeviceRecommendedDriverVersion = LibTiePie.VersionNumber2String( self.DeviceRecommendedDriverVersion( dwIdKind , dwId ) );
    end

    function nDeviceFirmwareVersion = DeviceFirmwareVersion( self , dwIdKind , dwId )
      nDeviceFirmwareVersion = calllib( self.sLibrary , 'LstDevGetFirmwareVersion' , uint32( dwIdKind ) , uint32( dwId ) );
    end

    function sDeviceFirmwareVersion = DeviceFirmwareVersionString( self , dwIdKind , dwId )
      sDeviceFirmwareVersion = LibTiePie.VersionNumber2String( self.DeviceFirmwareVersion( dwIdKind , dwId ) );
    end

    function CalibrationDate = DeviceCalibrationDate( self , dwIdKind , dwId )
      dwCalibrationDate = calllib( self.sLibrary , 'LstDevGetCalibrationDate' , uint32( dwIdKind ) , uint32( dwId ) );
      wYear = bitand( bitshift( dwCalibrationDate , -16 ) , 65535 );
      byMonth = bitand( bitshift( dwCalibrationDate , -8 ) , 255 );
      byDay = bitand( dwCalibrationDate , 255 );
      CalibrationDate = datenum( wYear , byMonth , byDay );
    end

    function sCalibrationDate = DeviceCalibrationDateString( self , dwIdKind , dwId )
      sCalibrationDate = datestr( self.DeviceCalibrationDate( dwIdKind , dwId ) );
    end

    function dwarSerialNumbers = DeviceContainedSerialNumbers( self , dwIdKind , dwId )
      dwLength = calllib( self.sLibrary , 'LstDevGetContainedSerialNumbers' , uint32( dwIdKind ) , uint32( dwId ) , [ 0 ] , 0 );
      [ dwLength , dwarSerialNumbers ] = calllib( self.sLibrary , 'LstDevGetContainedSerialNumbers' , uint32( dwIdKind ) , uint32( dwId ) , zeros( dwLength , 1 ) , dwLength );
    end;
  end
  methods
    function nCount = get.Count( self )
      nCount = calllib( self.sLibrary , 'LstGetCount' );
    end
  end
end

Contact us