Class: MsgReqStartComm

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

Overview

<summary> 通信開始要求メッセージ(0x00) </summary>

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMsgReqStartComm

Returns a new instance of MsgReqStartComm.



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
45
46
47
48
49
50
# File 'lib/haruzira_sdk/MsgReqStartComm.rb', line 11

def initialize()
    #region 変数・定数定義
    # <summary>
    # メンバーIndex offset定義
    # </summary>
    @INDEX_ID = 0              #メッセージID
    @INDEX_ENC_FLG = 1         #暗号化フラグ
    @INDEX_CER_FLG = 2         #認証フラグ
    @INDEX_PADDING = 3         #アライメント
    @INDEX_PORT = 4            #ポート番号
    @INDEX_NAME_LEN = 6        #接続元名称サイズ
    @INDEX_PASSWD_LEN = 8      #パスワードサイズ
    @INDEX_PADDING2 = 10       #アライメント
    @INDEX_NAME = 12           #接続元名称
    #endregion

    # <summary>
    # 送信メンバデータ値定義
    # </summary>
    #暗号化フラグ
    @ENC_FLG_OFF = 0x00      #暗号化無
    @ENC_FLG_ON = 0x01       #暗号化有
    #認証フラグ
    @CER_FLG_OFF = 0x00      #認証無
    @CER_FLG_ON = 0x01       #認証有

    @id = MSG_REQ_START_COMM                #メッセージID
    @enc_flg = 0x00           #暗号化フラグ
    @cer_flg = 0x00             #認証フラグ
    @padding = 0x00           #アライメント
    @port = 46000            #ポート番号
    @name_len = 0x00        #接続元名称サイズ
    @passwd_len = 0x00      #パスワードサイズ
    @padding2 = Array.new(2, 0x00)        #アライメント
    @name = nil            #接続元名称
    @passwd = nil          #パスワード
    #@byte[] reserve { get; set; }        #予備
    @head_len = (1 * 4) + (2 * 3) + @padding2.size                        #ヘッダーサイズ(読み上げデータを除いたサイズ)
    @total_len = 0                       #送信フィールド合計サイズ
end

Instance Attribute Details

#cer_flgObject

アクセサ定義



59
60
61
# File 'lib/haruzira_sdk/MsgReqStartComm.rb', line 59

def cer_flg
  @cer_flg
end

#CER_FLG_OFFObject (readonly)

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



56
57
58
# File 'lib/haruzira_sdk/MsgReqStartComm.rb', line 56

def CER_FLG_OFF
  @CER_FLG_OFF
end

#CER_FLG_ONObject (readonly)

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



56
57
58
# File 'lib/haruzira_sdk/MsgReqStartComm.rb', line 56

def CER_FLG_ON
  @CER_FLG_ON
end

#enc_flgObject

アクセサ定義



59
60
61
# File 'lib/haruzira_sdk/MsgReqStartComm.rb', line 59

def enc_flg
  @enc_flg
end

#ENC_FLG_OFFObject (readonly)

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



56
57
58
# File 'lib/haruzira_sdk/MsgReqStartComm.rb', line 56

def ENC_FLG_OFF
  @ENC_FLG_OFF
end

#ENC_FLG_ONObject (readonly)

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



56
57
58
# File 'lib/haruzira_sdk/MsgReqStartComm.rb', line 56

def ENC_FLG_ON
  @ENC_FLG_ON
end

#head_lenObject (readonly)

Returns the value of attribute head_len.



60
61
62
# File 'lib/haruzira_sdk/MsgReqStartComm.rb', line 60

def head_len
  @head_len
end

#idObject (readonly)

Returns the value of attribute id.



60
61
62
# File 'lib/haruzira_sdk/MsgReqStartComm.rb', line 60

def id
  @id
end

#INDEX_CER_FLGObject (readonly)

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



53
54
55
# File 'lib/haruzira_sdk/MsgReqStartComm.rb', line 53

def INDEX_CER_FLG
  @INDEX_CER_FLG
end

#INDEX_ENC_FLGObject (readonly)

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



53
54
55
# File 'lib/haruzira_sdk/MsgReqStartComm.rb', line 53

def INDEX_ENC_FLG
  @INDEX_ENC_FLG
end

#INDEX_IDObject (readonly)

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



53
54
55
# File 'lib/haruzira_sdk/MsgReqStartComm.rb', line 53

def INDEX_ID
  @INDEX_ID
end

#INDEX_NAMEObject (readonly)

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



53
54
55
# File 'lib/haruzira_sdk/MsgReqStartComm.rb', line 53

def INDEX_NAME
  @INDEX_NAME
end

#INDEX_NAME_LENObject (readonly)

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



53
54
55
# File 'lib/haruzira_sdk/MsgReqStartComm.rb', line 53

def INDEX_NAME_LEN
  @INDEX_NAME_LEN
end

#INDEX_PADDINGObject (readonly)

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



53
54
55
# File 'lib/haruzira_sdk/MsgReqStartComm.rb', line 53

def INDEX_PADDING
  @INDEX_PADDING
end

#INDEX_PADDING2Object (readonly)

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



53
54
55
# File 'lib/haruzira_sdk/MsgReqStartComm.rb', line 53

def INDEX_PADDING2
  @INDEX_PADDING2
end

#INDEX_PASSWD_LENObject (readonly)

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



53
54
55
# File 'lib/haruzira_sdk/MsgReqStartComm.rb', line 53

def INDEX_PASSWD_LEN
  @INDEX_PASSWD_LEN
end

#INDEX_PORTObject (readonly)

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



53
54
55
# File 'lib/haruzira_sdk/MsgReqStartComm.rb', line 53

def INDEX_PORT
  @INDEX_PORT
end

#nameObject

アクセサ定義



59
60
61
# File 'lib/haruzira_sdk/MsgReqStartComm.rb', line 59

def name
  @name
end

#name_lenObject

アクセサ定義



59
60
61
# File 'lib/haruzira_sdk/MsgReqStartComm.rb', line 59

def name_len
  @name_len
end

#passwdObject

アクセサ定義



59
60
61
# File 'lib/haruzira_sdk/MsgReqStartComm.rb', line 59

def passwd
  @passwd
end

#passwd_lenObject

アクセサ定義



59
60
61
# File 'lib/haruzira_sdk/MsgReqStartComm.rb', line 59

def passwd_len
  @passwd_len
end

#portObject

アクセサ定義



59
60
61
# File 'lib/haruzira_sdk/MsgReqStartComm.rb', line 59

def port
  @port
end

#total_lenObject (readonly)

Returns the value of attribute total_len.



60
61
62
# File 'lib/haruzira_sdk/MsgReqStartComm.rb', line 60

def total_len
  @total_len
end

Instance Method Details

#makeSendDataObject

<summary> 送信データ生成</summary> <returns>生成データサイズ, 生成データ</returns>



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/haruzira_sdk/MsgReqStartComm.rb', line 67

def makeSendData()
    @total_len = @head_len + (@name_len + @passwd_len);
    data = nil

    begin
        #パスワードとアカウント名のチェック
        if(@name_len > 0 && @name == nil)
            return 0, nil
        end

        if(@passwd_len > 0 && @passwd == nil)
            return 0, nil
        end

        #ネットワークバイトオーダー(little -> big)変換後に、Byte配列に変換
        bPort = [port].pack("n*").unpack("C*")
        bUserLen = [name_len].pack("n*").unpack("C*")
        bPasswdLen = [passwd_len].pack("n*").unpack("C*")

        if(@name != nil && @passwd != nil)
            data = [@id] + [@enc_flg] + [@cer_flg] + [@padding] + bPort + bUserLen + bPasswdLen + @padding2 + @name + @passwd
        else
            data = [@id] + [@enc_flg] + [@cer_flg] + [@padding] + bPort + bUserLen + bPasswdLen + @padding2
        end

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