Class: Evepi::OUT_01

Inherits:
Object
  • Object
show all
Defined in:
lib/evepi/out_01.rb

Constant Summary collapse

@@sensor =
Sensor.new 'out_01'
@@CURSOR_SET =
1
@@CURSOR_APPEND =
0
@@CURSOR_CLEAR =
2

Class Method Summary collapse

Class Method Details

._write(input_json, name = 'fuckname') ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/evepi/out_01.rb', line 29

def self._write(input_json, name='fuckname')
      hostname = @@sensor.json_obj[name][0]
    port = @@sensor.json_obj[name][1]
    socket = TCPSocket.open(hostname, port)
    socket.send input_json, 0
    line = socket.recv(1024)
    socket.close
end

.clear(name = 'fuckname') ⇒ Object



82
83
84
# File 'lib/evepi/out_01.rb', line 82

def self.clear(name='fuckname')
    return self.write(@@CURSOR_CLEAR, 0, 0, nil, name)
end

.set_cursor(x, y, name = 'fuckname') ⇒ Object



50
51
52
53
54
55
56
57
58
# File 'lib/evepi/out_01.rb', line 50

def self.set_cursor(x, y, name='fuckname')
    input_dict = {
        :cursor_whether => @@CURSOR_SET,
        :cursor_i => x,
        :cursor_j => y,
    }
    input_json = JSON.dump(input_dict)
    return self._write(input_json, name)
end

.write(type, x, y, content, name = 'fuckname') ⇒ Object



38
39
40
41
42
43
44
45
46
47
# File 'lib/evepi/out_01.rb', line 38

def self.write(type, x, y, content, name='fuckname')
    input_dict = {
        :cursor_whether => type,
        :cursor_i => x,
        :cursor_j => y,
        :input_string => content
    }
    input_json = JSON.dump(input_dict)
    return self._write(input_json, name)
end

.write_after(content, name = 'fuckname') ⇒ Object



72
73
74
75
76
77
78
79
# File 'lib/evepi/out_01.rb', line 72

def self.write_after(content, name='fuckname')
    input_dict = {
        :cursor_whether => @@CURSOR_APPEND,
        :input_string => content
    }
    input_json = JSON.dump(input_dict)
    return self._write(input_json, name)
end

.write_at(x, y, content, name = 'fuckname') ⇒ Object



60
61
62
63
64
65
66
67
68
69
# File 'lib/evepi/out_01.rb', line 60

def self.write_at(x, y, content, name='fuckname')
    input_dict = {
        :cursor_whether => @@CURSOR_SET,
        :cursor_i => x,
        :cursor_j => y,
        :input_string => content
    }
    input_json = JSON.dump(input_dict)
    return self._write(input_json, name)
end