class Labcom::ArcSamples

Authors

S.imazu

Version

20.0.0

Date

2018-06-01

[クラス名] ArcSamples

[メンバー]

[クラスメソッド]

[インスタンスメソッド]

[説 明]

  1. サンプリングデータクラス

  2. 計測データは、binary stringで保持する。

Attributes

block_bin_str[R]
image_type[R]

Public Class Methods

new( dtype=nil, data=nil, bsize=nil) click to toggle source
dtype(string)

データ型

data(string)

データ配列(binary string)

bsize(int)

有効データバイト数

返値

なし

[説  明]
コンストラクタ
# File labcom/ArcSamples.rb, line 48
def initialize( dtype=nil, data=nil, bsize=nil)
  if nil != dtype then
    @image_type = dtype
    @na_type = Labcom::to_narray_type( dtype)
    @bytes_per_sample = Labcom::to_bytes_per_sample( dtype)
  else
    @image_type = nil
    @na_type = nil
    @bytes_per_sample = 1
  end
  if nil != data then
    if nil == bsize then
      @block_bin_str = data
    else
      @block_bin_str = data[0..bsize-1]
    end
  else
    @block_bin_str = nil
  end
end

Public Instance Methods

num() click to toggle source
引数

なし

返値

データ件数(int)

[説  明]
サンプリングデータのデータ件数を戻す。
バイトサイズではない。
# File labcom/ArcSamples.rb, line 84
def num()
  return nil if( nil ==  @block_bin_str )
  return @block_bin_str.length/@bytes_per_sample
end
set_val( dtype, data, bsize=nil) click to toggle source
data(string)

データ配列(binary string)

dtype(string)

データ型

bsize(int)

有効データバイト数

返値

なし

[説  明]
メンバー変数にサンプリングデータを設定する。
データ型 : 'INT8', 'INT16', 'INT16', 'FLT32', 'FLT32' ('INT64'はNArrayが未サポート)
# File labcom/ArcSamples.rb, line 123
def set_val( dtype, data, bsize=nil)
  @image_type = dtype
  @na_type = Labcom::to_narray_type( dtype)
  @bytes_per_sample = Labcom::to_bytes_per_sample( dtype)
  if nil == bsize then
    @block_bin_str = data
  else
    @block_bin_str = data[0..bsize-1]
  end
end
val() click to toggle source
引数

なし

返値

配列データ(NArray)

[説  明]
バイナリデータをNArrayクラスのオブジェクトに変換し戻す。
# File labcom/ArcSamples.rb, line 100
def val()
  num_sample = num()
  return nil if( nil ==  num_sample )

  ary = NArray.to_na( @block_bin_str , @na_type, num_sample)
  return ary
end