66 |
if (str.size() >0) |
if (str.size() >0) |
67 |
{ |
{ |
68 |
cout << "Got " << str.size() << " bytes :" << str << endl; |
cout << "Got " << str.size() << " bytes :" << str << endl; |
69 |
if ( str == "100") |
do |
70 |
{ |
{ |
71 |
std::ostringstream tmp; |
if ( str == "100") |
72 |
|
{ |
73 |
|
std::ostringstream tmp; |
74 |
|
|
75 |
if (store->led3) |
if (store->led3) |
76 |
tmp << "111|"; |
tmp << "111|"; |
77 |
else |
else |
78 |
tmp << "110|"; |
tmp << "110|"; |
79 |
|
|
80 |
if (store->led4) |
if (store->led4) |
81 |
tmp << "121|"; |
tmp << "121|"; |
82 |
else |
else |
83 |
tmp << "120|"; |
tmp << "120|"; |
84 |
|
|
85 |
if (store->led5) |
if (store->led5) |
86 |
tmp << "131|"; |
tmp << "131|"; |
87 |
else |
else |
88 |
tmp << "130|"; |
tmp << "130|"; |
89 |
|
|
90 |
if (store->switch2) |
if (store->switch2) |
91 |
tmp << "140|"; |
tmp << "141|"; |
92 |
else |
else |
93 |
tmp << "141|"; |
tmp << "140|"; |
94 |
|
|
95 |
if (store->switch3) |
if (store->switch3) |
96 |
tmp << "150|"; |
tmp << "151|"; |
97 |
else |
else |
98 |
tmp << "151|"; |
tmp << "150|"; |
99 |
|
|
100 |
tmp << ( store->temp + 4000) << "|"; |
tmp << ( store->temp + 4000) << "|"; |
101 |
tmp << ( store->potmeter+2000) << "|"; |
tmp << ( store->potmeter+2000) << "|"; |
102 |
conn << tmp.str(); |
conn << tmp.str(); |
103 |
} else { |
} else { |
104 |
|
|
105 |
boost::mutex::scoped_lock lock(store->writeMutex); |
boost::mutex::scoped_lock lock(store->writeMutex); |
106 |
if (str == "111") |
if (str == "111") |
107 |
store->commands.push( WriteCommand(0,1) ); |
store->commands.push( WriteCommand(0,1) ); |
108 |
|
else if (str == "110") |
109 |
if (str == "110") |
store->commands.push( WriteCommand(0,0) ); |
110 |
store->commands.push( WriteCommand(0,0) ); |
else if (str == "121") |
111 |
|
store->commands.push( WriteCommand(1,1) ); |
112 |
if (str == "121") |
else if (str == "120") |
113 |
store->commands.push( WriteCommand(1,1) ); |
store->commands.push( WriteCommand(1,0) ); |
114 |
|
else if (str == "131") |
115 |
if (str == "120") |
store->commands.push( WriteCommand(2,1) ); |
116 |
store->commands.push( WriteCommand(1,0) ); |
else if (str == "130") |
117 |
|
store->commands.push( WriteCommand(2,0) ); |
118 |
if (str == "131") |
} |
119 |
store->commands.push( WriteCommand(2,1) ); |
} while (str.length |
|
|
|
|
if (str == "130") |
|
|
store->commands.push( WriteCommand(2,0) ); |
|
|
} |
|
120 |
} |
} |
121 |
str = ""; |
str = ""; |
122 |
} |
} |