| 2124 | } |
| 2125 | |
| 2126 | double cTaskLib::Task_MatchStr(cTaskContext& ctx) const |
| 2127 | { |
| 2128 | tBuffer<int> temp_buf(ctx.GetOutputBuffer()); |
| 2129 | // if (temp_buf[0] != 357913941) return 0; |
| 2130 | |
| 2131 | // temp_buf.Pop(); // pop the signal value off of the buffer |
| 2132 | |
| 2133 | const cString& string_to_match = ctx.GetTaskEntry()->GetArguments().GetString(0); |
| 2134 | int partial = ctx.GetTaskEntry()->GetArguments().GetInt(0); |
| 2135 | int binary = ctx.GetTaskEntry()->GetArguments().GetInt(1); |
| 2136 | // double mypow = ctx.GetTaskEntry()->GetArguments().GetDouble(0); |
| 2137 | int string_index; |
| 2138 | int num_matched = 0; |
| 2139 | int test_output; |
| 2140 | int max_num_matched = 0; |
| 2141 | int num_real=0; |
| 2142 | |
| 2143 | if (!binary) { |
| 2144 | if (temp_buf.GetNumStored() > 0) { |
| 2145 | test_output = temp_buf[0]; |
| 2146 | |
| 2147 | for (int j = 0; j < string_to_match.GetSize(); j++) { |
| 2148 | string_index = string_to_match.GetSize() - j - 1; // start with last char in string |
| 2149 | int k = 1 << j; |
| 2150 | if ((string_to_match[string_index] == '0' && !(test_output & k)) || |
| 2151 | (string_to_match[string_index] == '1' && (test_output & k))) num_matched++; |
| 2152 | } |
| 2153 | max_num_matched = num_matched; |
| 2154 | } |
| 2155 | } |
| 2156 | else { |
| 2157 | for (int j = 0; j < string_to_match.GetSize(); j++) { |
| 2158 | if (string_to_match[j] != '9') { |
| 2159 | num_real++; |
| 2160 | } |
| 2161 | if ((string_to_match[j] == '0' && temp_buf[j]==0) || |
| 2162 | (string_to_match[j] == '1' && temp_buf[j]==1)) { |
| 2163 | num_matched++; |
| 2164 | } |
| 2165 | } |
| 2166 | max_num_matched = num_matched; |
| 2167 | } |
| 2168 | |
| 2169 | bool used_received = false; |
| 2170 | if (ctx.GetReceivedMessages()) { |
| 2171 | tBuffer<int> received(*(ctx.GetReceivedMessages())); |
| 2172 | for (int i = 0; i < received.GetNumStored(); i++) { |
| 2173 | test_output = received[i]; |
| 2174 | num_matched = 0; |
| 2175 | |
| 2176 | for (int j = 0; j < string_to_match.GetSize(); j++) { |
| 2177 | string_index = string_to_match.GetSize() - j - 1; // start with last char in string |
| 2178 | int k = 1 << j; |
| 2179 | if ((string_to_match[string_index]=='0' && !(test_output & k)) || |
| 2180 | (string_to_match[string_index]=='1' && (test_output & k))) { |
| 2181 | num_matched++; |
| 2182 | } |
| 2183 | } |
nothing calls this directly
no test coverage detected