Class: MsgSendSpeechRecognitionCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/haruzira_sdk/MsgSendSpeechRecognitionCommand.rb

Overview

<summary> 音声認識コマンド送信メッセージ(0x15) </summary>

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMsgSendSpeechRecognitionCommand

Returns a new instance of MsgSendSpeechRecognitionCommand.



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
# File 'lib/haruzira_sdk/MsgSendSpeechRecognitionCommand.rb', line 9

def initialize()
    #region 変数・定数定義
    #メンバーIndex offset定義
    @INDEX_ID = 0              #メッセージID
    @INDEX_ENC_FLG = 1         #暗号化フラグ
    @INDEX_LANG_CODE = 2       #ロケールID(言語コード)
    @INDEX_TIME_STAMP = 4      #タイムスタンプ(00:00:00)
    @INDEX_MODE = 12           #コマンドモード
    @INDEX_PORT = 13           #ポート番号
    @INDEX_RESERVE = 15        #予備
    @INDEX_SIZE = 20           #読み上げデータサイズ


    # <summary>
    # 送信メンバデータ値定義
    # </summary>
    #暗号化フラグ
    @ENC_FLG_OFF = 0x00           #暗号化無
    @ENC_FLG_ON = 0x01            #暗号化有
    #言語コード
    @LANG_CODE = 0x00             #ロケールID(言語コード)


    @id = MSG_SEND_SPEECH_RECOGNITION_COMMAND               #メッセージID
    @enc_flg = 0x00                                         #暗号化フラグ
    @lang_code = 0x00                                       #ロケールID(言語コード)
    @time_stamp = Array.new(8, 0x00)                        #タイムスタンプ(00:00:00)
    @mode = 0x00                                            #コマンドモード
    @port = 46000                                           #ポート番号
    @reserve = Array.new(5, 0x00)                           #予備
    @size = 0x00                                            #コマンドデータサイズ
    @data = nil                                             #コマンドデータ(可変)
    @head_len = (1 * 2) + (2 + 1 * 9) + (2) + (1 * 5) + (4) #ヘッダーサイズ(読み上げデータを除いたサイズ)
    @total_len = 0                                          #送信フィールド合計サイズ
    #endregion
end

Instance Attribute Details

#dataObject

アクセサ定義



54
55
56
# File 'lib/haruzira_sdk/MsgSendSpeechRecognitionCommand.rb', line 54

def data
  @data
end

#enc_flgObject

アクセサ定義



54
55
56
# File 'lib/haruzira_sdk/MsgSendSpeechRecognitionCommand.rb', line 54

def enc_flg
  @enc_flg
end

#ENC_FLG_OFFObject (readonly)

アクセサ定義(送信メンバデータ値)



51
52
53
# File 'lib/haruzira_sdk/MsgSendSpeechRecognitionCommand.rb', line 51

def ENC_FLG_OFF
  @ENC_FLG_OFF
end

#ENC_FLG_ONObject (readonly)

アクセサ定義(送信メンバデータ値)



51
52
53
# File 'lib/haruzira_sdk/MsgSendSpeechRecognitionCommand.rb', line 51

def ENC_FLG_ON
  @ENC_FLG_ON
end

#head_lenObject (readonly)

Returns the value of attribute head_len.



55
56
57
# File 'lib/haruzira_sdk/MsgSendSpeechRecognitionCommand.rb', line 55

def head_len
  @head_len
end

#idObject (readonly)

Returns the value of attribute id.



55
56
57
# File 'lib/haruzira_sdk/MsgSendSpeechRecognitionCommand.rb', line 55

def id
  @id
end

#INDEX_ENC_FLGObject (readonly)

アクセサ定義(メンバーIndex offset)



47
48
49
# File 'lib/haruzira_sdk/MsgSendSpeechRecognitionCommand.rb', line 47

def INDEX_ENC_FLG
  @INDEX_ENC_FLG
end

#INDEX_IDObject (readonly)

アクセサ定義(メンバーIndex offset)



47
48
49
# File 'lib/haruzira_sdk/MsgSendSpeechRecognitionCommand.rb', line 47

def INDEX_ID
  @INDEX_ID
end

#INDEX_LANG_CODEObject (readonly)

アクセサ定義(メンバーIndex offset)



47
48
49
# File 'lib/haruzira_sdk/MsgSendSpeechRecognitionCommand.rb', line 47

def INDEX_LANG_CODE
  @INDEX_LANG_CODE
end

#INDEX_MODEObject (readonly)

アクセサ定義(メンバーIndex offset)



47
48
49
# File 'lib/haruzira_sdk/MsgSendSpeechRecognitionCommand.rb', line 47

def INDEX_MODE
  @INDEX_MODE
end

#INDEX_PORTObject (readonly)

アクセサ定義(メンバーIndex offset)



47
48
49
# File 'lib/haruzira_sdk/MsgSendSpeechRecognitionCommand.rb', line 47

def INDEX_PORT
  @INDEX_PORT
end

#INDEX_RESERVEObject (readonly)

アクセサ定義(メンバーIndex offset)



47
48
49
# File 'lib/haruzira_sdk/MsgSendSpeechRecognitionCommand.rb', line 47

def INDEX_RESERVE
  @INDEX_RESERVE
end

#INDEX_SIZEObject (readonly)

アクセサ定義(メンバーIndex offset)



47
48
49
# File 'lib/haruzira_sdk/MsgSendSpeechRecognitionCommand.rb', line 47

def INDEX_SIZE
  @INDEX_SIZE
end

#INDEX_TIME_STAMPObject (readonly)

アクセサ定義(メンバーIndex offset)



47
48
49
# File 'lib/haruzira_sdk/MsgSendSpeechRecognitionCommand.rb', line 47

def INDEX_TIME_STAMP
  @INDEX_TIME_STAMP
end

#lang_codeObject

アクセサ定義



54
55
56
# File 'lib/haruzira_sdk/MsgSendSpeechRecognitionCommand.rb', line 54

def lang_code
  @lang_code
end

#LANG_CODEObject (readonly)

アクセサ定義(送信メンバデータ値)



51
52
53
# File 'lib/haruzira_sdk/MsgSendSpeechRecognitionCommand.rb', line 51

def LANG_CODE
  @LANG_CODE
end

#modeObject

アクセサ定義



54
55
56
# File 'lib/haruzira_sdk/MsgSendSpeechRecognitionCommand.rb', line 54

def mode
  @mode
end

#portObject

アクセサ定義



54
55
56
# File 'lib/haruzira_sdk/MsgSendSpeechRecognitionCommand.rb', line 54

def port
  @port
end

#reserveObject

アクセサ定義



54
55
56
# File 'lib/haruzira_sdk/MsgSendSpeechRecognitionCommand.rb', line 54

def reserve
  @reserve
end

#sizeObject

アクセサ定義



54
55
56
# File 'lib/haruzira_sdk/MsgSendSpeechRecognitionCommand.rb', line 54

def size
  @size
end

#time_stampObject

アクセサ定義



54
55
56
# File 'lib/haruzira_sdk/MsgSendSpeechRecognitionCommand.rb', line 54

def time_stamp
  @time_stamp
end

#total_lenObject (readonly)

Returns the value of attribute total_len.



55
56
57
# File 'lib/haruzira_sdk/MsgSendSpeechRecognitionCommand.rb', line 55

def total_len
  @total_len
end

Instance Method Details

#makeSendDataObject

<summary> 送信データ生成</summary> <param name=“sd”>生成データ</param> <returns>生成データサイズ</returns>



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/haruzira_sdk/MsgSendSpeechRecognitionCommand.rb', line 64

def makeSendData()
    @total_len = @head_len + @size
    mdata = nil

    begin
        #ネットワークバイトオーダー後に、Byte配列に変換
        bLangCode = [@lang_code].pack("n*").unpack("C*")
        bPort = [@port].pack("n*").unpack("C*")
        bSize = [@size].pack("N*").unpack("C*")

        mdata = [@id] + [@enc_flg] + bLangCode + \
                @time_stamp + [@mode] + bPort + @reserve + bSize + @data

    rescue Exception => ex
        p ex
        @total_len = 0
    ensure
        return @total_len, mdata
    end
end