| | |
| | | /*- |
| | | * Copyright (c) 2012-2013 Jan Breuer, |
| | | * BSD 2-Clause License |
| | | * |
| | | * All Rights Reserved |
| | | * Copyright (c) 2012-2018, Jan Breuer |
| | | * All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are |
| | | * met: |
| | | * 1. Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * 2. Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR |
| | | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| | | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| | | * DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE |
| | | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| | | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| | | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| | | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| | | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| | | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| | | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| | | * * Redistributions of source code must retain the above copyright notice, this |
| | | * list of conditions and the following disclaimer. |
| | | * |
| | | * * Redistributions in binary form must reproduce the above copyright notice, |
| | | * this list of conditions and the following disclaimer in the documentation |
| | | * and/or other materials provided with the distribution. |
| | | * |
| | | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| | | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| | | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| | | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| | | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| | | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| | | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| | | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| | | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| | | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| | | */ |
| | | |
| | | /** |
| | |
| | | int32_t values_to[MAXDIM]; |
| | | size_t dimensions; |
| | | |
| | | bool for_stop_row = false; /* true if iteration for rows has to stop */ |
| | | bool for_stop_col = false; /* true if iteration for columns has to stop */ |
| | | bool for_stop_row = FALSE; /* true if iteration for rows has to stop */ |
| | | bool for_stop_col = FALSE; /* true if iteration for columns has to stop */ |
| | | int32_t dir_row = 1; /* direction of counter for rows, +/-1 */ |
| | | int32_t dir_col = 1; /* direction of counter for columns, +/-1 */ |
| | | |
| | |
| | | arr_idx = 0; /* set arr_idx to 0 */ |
| | | do { /* if valid, iterate over channel_list_param index while res == valid (do-while cause we have to do it once) */ |
| | | res = SCPI_ExprChannelListEntry(context, &channel_list_param, chanlst_idx, &is_range, values_from, values_to, 4, &dimensions); |
| | | if (is_range == false) { /* still can have multiple dimensions */ |
| | | if (is_range == FALSE) { /* still can have multiple dimensions */ |
| | | if (dimensions == 1) { |
| | | /* here we have our values |
| | | * row == values_from[0] |
| | |
| | | if (arr_idx >= MAXROW * MAXCOL) { |
| | | return SCPI_RES_ERR; |
| | | } |
| | | } else if (is_range == true) { |
| | | } else if (is_range == TRUE) { |
| | | if (values_from[0] > values_to[0]) { |
| | | dir_row = -1; /* we have to decrement from values_from */ |
| | | } else { /* if (values_from[0] < values_to[0]) */ |
| | |
| | | |
| | | /* iterating over rows, do it once -> set for_stop_row = false |
| | | * needed if there is channel list index isn't at end yet */ |
| | | for_stop_row = false; |
| | | for (n = values_from[0]; for_stop_row == false; n += dir_row) { |
| | | for_stop_row = FALSE; |
| | | for (n = values_from[0]; for_stop_row == FALSE; n += dir_row) { |
| | | /* usual case for ranges, 2 dimensions */ |
| | | if (dimensions == 2) { |
| | | if (values_from[1] > values_to[1]) { |
| | |
| | | } |
| | | /* iterating over columns, do it at least once -> set for_stop_col = false |
| | | * needed if there is channel list index isn't at end yet */ |
| | | for_stop_col = false; |
| | | for (m = values_from[1]; for_stop_col == false; m += dir_col) { |
| | | for_stop_col = FALSE; |
| | | for (m = values_from[1]; for_stop_col == FALSE; m += dir_col) { |
| | | /* here we have our values |
| | | * row == n |
| | | * col == m |
| | |
| | | } |
| | | if (m == (size_t)values_to[1]) { |
| | | /* endpoint reached, stop column for-loop */ |
| | | for_stop_col = true; |
| | | for_stop_col = TRUE; |
| | | } |
| | | } |
| | | /* special case for range, example: (@2!1) */ |
| | |
| | | } |
| | | if (n == (size_t)values_to[0]) { |
| | | /* endpoint reached, stop row for-loop */ |
| | | for_stop_row = true; |
| | | for_stop_row = TRUE; |
| | | } |
| | | } |
| | | |
| | |
| | | {.pattern = "TEST:TEXT", .callback = TEST_Text,}, |
| | | {.pattern = "TEST:ARBitrary?", .callback = TEST_ArbQ,}, |
| | | {.pattern = "TEST:CHANnellist", .callback = TEST_Chanlst,}, |
| | | |
| | | SCPI_CMD_LIST_END |
| | | }; |
| | | |