Class: Ucp::Pdu::Ucp51Operation
- Inherits:
-
UCP5x
- Object
- UCPMessage
- UCP5x
- Ucp::Pdu::Ucp51Operation
- Defined in:
- lib/ucp/pdu/ucp51_operation.rb
Direct Known Subclasses
Ucp52Operation, Ucp53Operation, Ucp54Operation, Ucp55Operation, Ucp56Operation, Ucp57Operation, Ucp58Operation
Constant Summary
Constants inherited from UCPMessage
Ucp::Pdu::UCPMessage::DELIMITER, Ucp::Pdu::UCPMessage::ETX, Ucp::Pdu::UCPMessage::STX
Instance Attribute Summary
Attributes inherited from UCPMessage
#dcs, #message_ref, #operation, #operation_type, #part_nr, #total_parts, #trn
Instance Method Summary collapse
- #add_xser(xser_id, xser_data) ⇒ Object
- #add_xser_raw(xser) ⇒ Object
- #basic_submit(originator, recipient, message = nil, ucpfields = {}) ⇒ Object
-
#initialize(fields = nil) ⇒ Ucp51Operation
constructor
A new instance of Ucp51Operation.
- #parse_xser ⇒ Object
- #to_s ⇒ Object
Methods inherited from UCP5x
#initialize_message, #set_fields
Methods inherited from UCPMessage
#checksum, #get_field, #is_ack?, #is_nack?, #is_operation?, #is_result?, #length, #set_field, #set_fields
Constructor Details
#initialize(fields = nil) ⇒ Ucp51Operation
Returns a new instance of Ucp51Operation.
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/ucp/pdu/ucp51_operation.rb', line 23 def initialize(fields=nil) super() @operation="51" @operation_type="O" #@fields=[:adc,:oadc,:ac,:nrq,:nadc,:nt,:npid,:lrq,:lrad,:lpid,:dd,:ddt,:vp,:rpid,:scts,:dst,:rsn,:dscts,:mt,:nb,:msg,:mms,:pr,:dcs,:mcls,:rpi,:cpg,:rply,:otoa,:hplmn,:xser,:res4,:res5] if fields.nil? return end @trn=fields[0] @operation_type=fields[2] @operation=fields[3] # *00/00352/O/51/961234567/1234/////////////////4/1072/31D98C56B3DD7039584C36A3D56C375C0E1693CD6835DB0D9783C564335ACD76C3E56031D98C56B3DD7039584C36A3D56C375C0E1693CD6835DB0D9783C564335ACD76C3E56031D98C56B3DD7039584C36A3D56C375C0E1693CD6835DB0D9783C564335ACD76C3E56031D98C56B3DD7039584C36A3D56C375C0E1693CD6835DB0D9783C56433//////////0106050003450201///44# for i in 4..(fields.length-1) field=@fields[i-4] if field.eql?(:xser) add_xser_raw(fields[i]) else @h[field]=fields[i] end end parse_xser end |
Instance Method Details
#add_xser(xser_id, xser_data) ⇒ Object
113 114 115 116 117 118 119 120 |
# File 'lib/ucp/pdu/ucp51_operation.rb', line 113 def add_xser(xser_id,xser_data) xser=xser_id+UCP.int2hex(xser_data.length/2)+xser_data @xservices << xser if xser_id.eql?("02") @dcs=xser_data end end |
#add_xser_raw(xser) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/ucp/pdu/ucp51_operation.rb', line 94 def add_xser_raw(xser) # nao faz parsing/decode do xser #@xservices << xser # partir os xservices, por form a fazer parsing dos mesmos e adiciona-los um a um idx=0 while idx<xser.length xser_id=xser[idx,2] xser_len=xser[idx+2,2].to_i(16) xser_data=xser[idx+4,xser_len*2] #puts "xxx_serid: #{xser_id} ; #{xser_data}" add_xser(xser_id,xser_data) idx+=(xser_len+2)*2 end end |
#basic_submit(originator, recipient, message = nil, ucpfields = {}) ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/ucp/pdu/ucp51_operation.rb', line 122 def basic_submit(originator,recipient,=nil,ucpfields={}) # super() # @operation="51" # @operation_type="O" # @fields=[:adc,:oadc,:ac,:nrq,:nadc,:nt,:npid,:lrq,:lrad,:lpid,:dd,:ddt,:vp,:rpid,:scts,:dst,:rsn,:dscts,:mt,:nb,:msg,:mms,:pr,:dcs,:mcls,:rpi,:cpg,:rply,:otoa,:hplmn,:xser,:res4,:res5] # UCP51 supports IRA encoded SMS and 16 bits UCS2 # for now assume IRA if !.nil? msg=UCP.ascii2ira() end mt=3 otoa="" # UCP51 supports alphanumeric oadc if originator.to_s !~ /^[0-9]+$/ oadc=UCP.packoadc(originator.to_s) otoa="5039" else oadc=originator end @h={:otoa=>otoa,:oadc=>oadc, :adc=>recipient, :msg=>msg,:mt=>mt} @h=@h.merge ucpfields end |
#parse_xser ⇒ Object
58 59 60 61 62 63 64 65 66 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 |
# File 'lib/ucp/pdu/ucp51_operation.rb', line 58 def parse_xser @xservices.each { |xser| puts "xser_id: #{xser[0,2]}" if xser[0,2].eql?("01") header=xser[4,xser[2,2].to_i(16)*2] header_len=xser[4,2].to_i(16) #puts "header: #{header}; hlen: #{header_len}" i=2 while i<header.length ie=header[i, header[i+2,2].to_i(16)*2+4] iei=header[i,2] iel=header[i+2,2].to_i(16) #puts "ie: #{ie}" if iei.eql?("00") @message_ref=ie[4,2].to_i(16) @total_parts=ie[6,2].to_i(16) @part_nr=ie[8,2].to_i(16) #puts "part_info: MR=#{@message_ref}; PN=#{@part_nr} PT=#{@total_parts}" break end i+=iel*2 end elsif xser[0,2].eql?("02") @dcs=xser[4,2] end } # no parts info return nil end |
#to_s ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/ucp/pdu/ucp51_operation.rb', line 153 def to_s xserstr="" if !@xservices.empty? @xservices.each { |xser| xserstr+=xser } @h[:xser]=xserstr end super() end |