Exemple #1
0
/**************************************************
* Function name	:
* Created by	:
* Date created	:
* Description	:
* Notes		:
***************************************************/
void sensor_cb (void)
{
    if(sensor_union[DIS_number].sensor_data.status == OK)
    {
        if(DIS_command == CONFIGURATION)
        {
            sensor_union[DIS_number].sensor_data.sort_sensor = read_packet.read_pos.data[0];
            sensor_union[DIS_number].sensor_data.sort_gas = read_packet.read_pos.data[1];
            sensor_union[DIS_number].sensor_data.unit = read_packet.read_pos.data[2];
            sensor_union[DIS_number].sensor_data.voltage = read_packet.read_pos.data[3];
        }
        if(DIS_command == DATA)
        {
            for(U8 i=0; i<4; i++)
            {
                sensor_union[DIS_number].sensor_data.data.data_buf[i] = read_packet.read_pos.data[i];
            }
        }
        check_number();


    }
    if(sensor_union[DIS_number].sensor_data.status == ERROR_CONTROL_BYTE)
    {
        for(U8 i = 0x00; i < 6; i++)
        {
            sensor_union[DIS_number].data_buffer[i] = 0x00;
        }
        check_number();
    }
}
Exemple #2
0
int CopyFile::Run(int argc, char *argv[])
{
	if (!check_number(this, argc, 6)) return -1;
	if (!check_folder(argv[2])) return -1;
	if (!check_folder(argv[3])) return -1;

	// todo
	std::string opt = argv[3];
	if (opt != "-l" || opt != "--list") {
		std::cerr << "error opt" << std::endl;
		std::cerr << Usage() << std::endl;
		return -1;
	}

//	Trigger(argv[2]);

	Init(argv[2], argv[3]);
	if (opt == "-s" || opt == "--scale") {
//		CopyByExportNames(argv[4], atof(argv[5]));
	} else {
		std::cout << "unknown option" << std::endl;
		return -1;
	}

	return 0;
}
Exemple #3
0
gint 
day_key_press_cb (GtkWidget *widget, GdkEventKey *event, gpointer data) {

gint a;

    if (event->keyval == GDK_Return) {

        if (check_number(gtk_entry_get_text(GTK_ENTRY(day_entry))) == FALSE) {
            sprintf(tmpbuf, "%d", timer->tm_mday);
            gtk_entry_set_text (GTK_ENTRY(day_entry), tmpbuf);
        }

        a = atoi(gtk_entry_get_text(GTK_ENTRY(day_entry)));

        if (a > 31)
            gtk_entry_set_text (GTK_ENTRY(day_entry), "31");
        if (a < 1)
            gtk_entry_set_text (GTK_ENTRY(day_entry), "1");

        gtk_widget_grab_focus(GTK_WIDGET(month_entry));
        return TRUE;
    }

    return FALSE;
}
Exemple #4
0
/* void Arduino50::checkpoint()
 * @param1: int checkpoint_id 
 * purpose: based on the checkpoint id, obtains the correct solution object
 */
void 
Arduino50::checkpoint(int checkpoint_id)
{	
	// get the specific solution for this checkpoint
	solution s = outputs[checkpoint_id];
	
	// based on the ENUM to Solution.Type pairing, check the current input
	switch(s.type)
	{
		case READ:
			inputs[checkpoint_id] = check_read(s);
		break;
		case PIN:
			inputs[checkpoint_id] = check_pin(s);			
		break;
		case NUMBER:
			inputs[checkpoint_id] = check_number(s);
		break;
		case MODE:
		break;
		default:
		break;
	}

}
Exemple #5
0
int check_networktype(CLISESSION *pSession, char *pszValue)
{
	if (!strcasecmp(pszValue, "star")) return 1;
	if (!strcasecmp(pszValue, "mesh")) return 1;

    return check_number(pSession, pszValue);
}
Exemple #6
0
int check_mtortype(CLISESSION *pSession, char *pszValue)
{
	if (!strcasecmp(pszValue, "high")) return 1;
	if (!strcasecmp(pszValue, "low")) return 1;

    return check_number(pSession, pszValue);
}
Exemple #7
0
int VerifyJson::Run(int argc, char *argv[])
{
	if (!check_number(this, argc, 3)) return -1;
	if (!check_folder(argv[2])) return -1;

	Trigger(argv[2]);

	return 0;
}
Exemple #8
0
int GenAudioID::Run(int argc, char *argv[])
{
	if (!check_number(this, argc, 3)) return -1;
	if (!check_folder(argv[2])) return -1;

	Trigger(argv[2], argv[3]);

	return 0;
}
Exemple #9
0
int check_coretype(CLISESSION *pSession, char *pszValue)
{
	if (!strcasecmp(pszValue, "modem") || !strcasecmp(pszValue, "core"))
    {
		return 1;
    }

    return check_number(pSession, pszValue);
}
Exemple #10
0
int check_schedulertype(CLISESSION *pSession, char *pszValue)
{
	if (!strncasecmp(pszValue, "mask", 4) || !strncasecmp(pszValue, "int", 3))
    {
		return 1;
    }

    return check_number(pSession, pszValue);
}
int FormatJsonFile::Run(int argc, char *argv[])
{
	if (!check_number(this, argc, 3)) return -1;
	if (!check_folder(argv[2])) return -1;

	Trigger(argv[2]);

	return 0;
}
Exemple #12
0
int CalcImageArea::Run(int argc, char *argv[])
{
	if (!check_number(this, argc, 3)) return -1;
	if (!check_folder(argv[2])) return -1;

	Run(argv[2]);

	return 0;
}
int GenNoCompressCfg::Run(int argc, char *argv[])
{
	if (!check_number(this, argc, 5)) return -1;
	if (!check_folder(argv[2])) return -1;

	Trigger(argv[2], argv[3], argv[4]);

	return 0;
}
int TransNewTextFile::Run(int argc, char *argv[])
{
	if (!check_number(this, argc, 3)) return -1;
	if (!check_folder(argv[2])) return -1;

	Run(argv[2]);

	return 0;
}
Exemple #15
0
int FixLRSprLayer::Run(int argc, char *argv[])
{
	// fix-lr-layer D:\projects\ejoy\coco-tools\sg_particle\data\json_and_pngs

	if (!check_number(this, argc, 3)) return -1;
	if (!check_folder(argv[2])) return -1;

	Trigger(argv[2]);

	return 0;
}
Exemple #16
0
int NumberImages::Run(int argc, char *argv[])
{
	// num-imgs E:\debug\character E:\debug\character\num_image.txt

	if (!check_number(this, argc, 4)) return -1;
	if (!check_folder(argv[2])) return -1;

	Trigger(argv[2], argv[3]);

	return 0;
}
int ChangeComplexOrigin::Run(int argc, char *argv[])
{
	// change-origin D:\projects\ejoy\coco-tools\sg_particle\data\json_and_pngs

	if (!check_number(this, argc, 3)) return -1;
	if (!check_folder(argv[2])) return -1;

	Trigger(argv[2]);

	return 0;
}
Exemple #18
0
int check_troption(CLISESSION *pSession, char *pszValue)
{
	if (!strcasecmp(pszValue, "default")) return 1;
	if (!strcasecmp(pszValue, "queue")) return 1;
	if (!strcasecmp(pszValue, "wait")) return 1;
	if (!strcasecmp(pszValue, "run")) return 1;
	if (!strcasecmp(pszValue, "w+q+r")) return 1;
	if (!strcasecmp(pszValue, "terminate")) return 1;
	if (!strcasecmp(pszValue, "all")) return 1;

    return check_number(pSession, pszValue);
}
int LRSeparateComplex::Run(int argc, char *argv[])
{
	if (!check_number(this, argc, 4)) return -1;
	if (!check_file(argv[2])) return -1;

	m_point_dir = argv[3];
	m_output_dir = ee::FileHelper::GetFileDir(argv[4]);
	m_output_name = ee::FileHelper::GetFilenameWithExtension(argv[4]);

	Run(argv[2]);

	return 0;
}
Exemple #20
0
int FixTextAlign::Run(int argc, char *argv[])
{
	// fix-text-align D:\projects\ejoy\coco-tools\sg_particle\data\json_and_pngs

	if (!check_number(this, argc, 3)) return -1;
	if (!check_folder(argv[2])) return -1;

	ee::GTxt::Init();

	Trigger(argv[2]);

	return 0;
}
Exemple #21
0
/*begin main*/
int main()
{
    /*declare variables for holding values to calculate exponents and interest*/
    float x;
    int exp;
    float pow;
    float amtc;
    float amt ;
    float rate;
    int year;
    float interest;

    printf("Enter a number: ");/*prompt user to enter a number*/
    scanf("%f", &x);/*assign the number to a variable*/

    while (check_number(x) == 0)/*check to make sure number is within the correct range*/
    {
        printf("Invalid. Enter a number from -100 to 100: ");
        scanf("%f", &x);
    }

    printf("Enter the exponent: ");/*prompt the user to enter an exponent*/
    scanf("%d", &exp);

    while (check_exponent(exp) == 0)/*check to make sure the user entered a valid exponent*/
    {
        printf("invalid. Enter an exponent between -5 and 5: ");
        scanf("%d", &exp);
    }

    pow = compute_power(x, exp);/*send values to compute_power function to calculate exponent*/

    printf("\nPow(%.2f,%d) is %.2f\n", x, exp, pow);/*display results of the calculation*/

    printf("Enter a dollar amount: ");/*prompt user to enter a dollar amount*/
    scanf("%f", &amt);
    printf("Enter an interest rate: ");/*prompt user to enter an interest rate*/
    scanf("%f", &rate);
    printf("Enter the the number of years: ");/*prompt user to enter the number of years of compound interest*/
    scanf("%d", &year);


    amtc = amt * compute_power(1+rate/100,year);/*calculate the amound after compound interest*/
    interest = amtc - amt;/*calculate the amount of interest earned*/

    /*display the results of the calculations for interest*/
    printf("\n\nInterest earned on $%.2f at a rate of %.3f%% after %d years is $%.2f.\n", amt, rate, year, interest);


    return 0;
}   /*end main*/
Exemple #22
0
SOL_API bool
sol_json_scanner_next(struct sol_json_scanner *scanner, struct sol_json_token *token)
{
    token->start = NULL;
    token->end = NULL;

    for (; scanner->current < scanner->mem_end; scanner->current++) {
        enum sol_json_type type = sol_json_mem_get_type(scanner->current);
        switch (type) {
        case SOL_JSON_TYPE_UNKNOWN:
            if (!isspace((uint8_t)scanner->current[0])) {
                SOL_ERR("%zu: unexpected symbol %#x (%c)",
                    sol_json_scanner_get_mem_offset(scanner, scanner->current),
                    scanner->current[0], scanner->current[0]);
                errno = EINVAL;
                return false;
            }
            break;

        case SOL_JSON_TYPE_OBJECT_START:
        case SOL_JSON_TYPE_OBJECT_END:
        case SOL_JSON_TYPE_ARRAY_START:
        case SOL_JSON_TYPE_ARRAY_END:
        case SOL_JSON_TYPE_ELEMENT_SEP:
        case SOL_JSON_TYPE_PAIR_SEP:
            token->start = scanner->current;
            token->end = scanner->current + 1;
            scanner->current = token->end;
            return true;

        case SOL_JSON_TYPE_TRUE:
            return check_symbol(scanner, token, "true", sizeof("true") - 1);

        case SOL_JSON_TYPE_FALSE:
            return check_symbol(scanner, token, "false", sizeof("false") - 1);

        case SOL_JSON_TYPE_NULL:
            return check_symbol(scanner, token, "null", sizeof("null") - 1);

        case SOL_JSON_TYPE_STRING:
            return check_string(scanner, token);

        case SOL_JSON_TYPE_NUMBER:
            return check_number(scanner, token);
        }
    }

    errno = 0;
    return false;
}
int ExportBodymovin::Run(int argc, char *argv[])
{
	if (!check_number(this, argc, 4)) return -1;
	if (!check_folder(argv[3])) return -1;

	int ret = init_gl();
	if (ret < 0) {
		return ret;
	}

	Trigger(argv[2], argv[3]);

	return 0;
}
Exemple #24
0
int solve_sudoku(int line, int column, int sudoku[9][9]) {
  int index_line, index_column, copy_sudoku[9][9], good=0, number;

  // create a sudoku matrix copy
  for(index_line=0; index_line<9; index_line++) {
    for(index_column=0; index_column<9; index_column++) {
      copy_sudoku[index_line][index_column] = sudoku[index_line][index_column];
    }
  }

  // go to the first 0 element
  while(copy_sudoku[line][column] != 0 && line < 9) {
    if (column == 8) {
      column = 0; line++;
    } else {
      column++;
    }
  }

  // if we are at the last line + 1 => we found a solution
  if (line >= 9) {
    print_solution(copy_sudoku);
    return 1;
  }

  // we are at 0-element in matrix, so we try to change that element with the
  // right non-0 element
  for(number=1; number<=9; number++) {
    // if the number meet thoese 3 condition, go to next position
    if (check_number(number, line, column, copy_sudoku)) {
      good = 1;
      copy_sudoku[line][column] = number;
      // continue solving for next position
      if (column == 8) {
        solve_sudoku(line+1, 0, copy_sudoku);
      } else {
        solve_sudoku(line, column+1, copy_sudoku);
      }
    }
    // if no solution was found, go back and try with another number
  }

  if (!good) return 0;
}
Exemple #25
0
int main()
{
    float x;

    printf("Enter a number: ");
    scanf("%f", &x);

    while (check_number (x) == 0)
    {
        printf("Invalid. Enter a number from -100 to 100: ");
        scanf("%f", &x);
    }

    printf("\nThe number entered is %.2f", x);
    printf("\nSquare of %.2f is %.2f", x, square(x));
    printf("\nCube of %.2f is %.2f", x, cube(x));

    return 0;
}
int ChangeTPJsonFile::Run(int argc, char *argv[])
{
	if (!check_number(this, argc, 6)) return -1;
	if (!check_folder(argv[2])) return -1;

	// todo
	std::string opt = argv[3];
	if (opt != "-m" && opt != "--move") {
		std::cerr << "error opt" << std::endl;
		std::cerr << Usage() << std::endl;
		return -1;
	} 

	Run(argv[2]);
	if (opt == "-m" || opt == "--move") {
		TranslateFrameXY(atof(argv[4]), atof(argv[5]));
	} else {
		std::cout << "unknown option" << std::endl;
		return -1;
	}

	return 0;
}
Exemple #27
0
static int
ParseTime (char *s, time_t * t_start)
{
  struct tm ts;
  int i;
  char *p, *q;


  /* A time string may look like:
   * yyyy/MM/dd.hh:mm:ss
   */

  memset ((void *) &ts, 0, sizeof (ts));
  ts.tm_isdst = -1;

  p = s;

  // parse year
  q = strchr (p, '/');
  if (q)
    {
      *q++ = 0;
    }
  if (!check_number (p, 4))
    return 0;
  i = atoi (p);
  if (i > 2038 || i < 1970)
    {
      LogError ("Year out of range: '%i'\n", i);
      *t_start = 0;
      return 0;
    }
  ts.tm_year = i - 1900;
  if (!q)
    {
      ts.tm_mday = 1;
      *t_start = mktime (&ts);
      return 1;
    }

  // parse month
  p = q;
  q = strchr (p, '/');
  if (q)
    *q++ = 0;
  if (!check_number (p, 2))
    return 0;
  i = atoi (p);
  if (i < 1 || i > 12)
    {
      LogError ("Month out of range: '%i'\n", i);
      *t_start = 0;
      return 0;
    }
  ts.tm_mon = i - 1;
  if (!q)
    {
      ts.tm_mday = 1;
      *t_start = mktime (&ts);
      return 1;
    }

  // Parse day
  p = q;
  q = strchr (p, '.');
  if (q)
    *q++ = 0;
  if (!check_number (p, 2))
    return 0;
  i = atoi (p);
  if (i < 1 || i > 31)
    {
      LogError ("Day out of range: '%i'\n", i);
      *t_start = 0;
      return 0;
    }
  ts.tm_mday = i;
  if (!q)
    {
      *t_start = mktime (&ts);
      return 1;
    }

  // Parse hour
  p = q;
  q = strchr (p, ':');
  if (q)
    *q++ = 0;
  if (!check_number (p, 2))
    return 0;
  i = atoi (p);
  if (i < 0 || i > 23)
    {
      LogError ("Hour out of range: '%i'\n", i);
      *t_start = 0;
      return 0;
    }
  ts.tm_hour = i;
  if (!q)
    {
      *t_start = mktime (&ts);
      return 1;
    }

  // Parse minute
  p = q;
  q = strchr (p, ':');
  if (q)
    *q++ = 0;
  if (!check_number (p, 2))
    return 0;
  i = atoi (p);
  if (i < 0 || i > 59)
    {
      LogError ("Minute out of range: '%i'\n", i);
      *t_start = 0;
      return 0;
    }
  ts.tm_min = i;
  if (!q)
    {
      *t_start = mktime (&ts);
      return 1;
    }

  // Parse second
  p = q;
  if (!check_number (p, 2))
    return 0;
  i = atoi (p);
  if (i < 0 || i > 59)
    {
      LogError ("Seconds out of range: '%i'\n", i);
      *t_start = 0;
      return 0;
    }
  ts.tm_sec = i;
  *t_start = mktime (&ts);
  return 1;

}				// End of ParseTime
static int
check(kdump_ctx *ctx)
{
	kdump_attr_t attr;
	kdump_addr_t symval;
	kdump_status status;
	int rc, tmprc;

	attr.type = kdump_string;
	attr.val.string = vmcore;
	status = kdump_set_attr(ctx, "linux.vmcoreinfo.raw", &attr);
	if (status != kdump_ok) {
		fprintf(stderr, "Cannot set vmcoreinfo: %s\n",
			kdump_err_str(ctx));
		return TEST_ERR;
	}

	rc = TEST_OK;
	attr.type = kdump_string;

	/* Check modifications */
	attr.val.string = ALT_OSRELEASE;
	status = kdump_set_attr(ctx, ATTR_LINES ".OSRELEASE", &attr);
	if (status != kdump_ok) {
		fprintf(stderr, "Cannot modify %s: %s\n",
			ATTR_LINES ".OSRELEASE", kdump_err_str(ctx));
		return TEST_ERR;
	}
	tmprc = check_string(ctx, ATTR_OSRELEASE, ALT_OSRELEASE);
	if (tmprc == TEST_ERR)
		return tmprc;
	if (tmprc != TEST_OK)
		rc = tmprc;

	attr.val.string= str(ALT_PAGESIZE);
	status = kdump_set_attr(ctx, ATTR_LINES ".PAGESIZE", &attr);
	if (status != kdump_ok) {
		fprintf(stderr, "Cannot modify %s: %s\n",
			ATTR_LINES ".PAGESIZE", kdump_err_str(ctx));
		return TEST_ERR;
	}
	tmprc = check_number(ctx, ATTR_PAGESIZE, ALT_PAGESIZE);
	if (tmprc == TEST_ERR)
		return tmprc;
	if (tmprc != TEST_OK)
		rc = tmprc;

	attr.val.string= str(ALT_SYM_VALUE);
	status = kdump_set_attr(ctx, ATTR_LINES ".SYMBOL(" SYM_NAME ")",
				&attr);
	if (status != kdump_ok) {
		fprintf(stderr, "Cannot modify %s: %s\n",
			ATTR_LINES ".SYMBOL(" SYM_NAME ")",
			kdump_err_str(ctx));
		return TEST_ERR;
	}
	status = kdump_vmcoreinfo_symbol(ctx, SYM_NAME, &symval);
	if (status != kdump_ok) {
		fprintf(stderr, "%s: Cannot get value: %s\n",
			SYM_NAME, kdump_err_str(ctx));
		return TEST_ERR;
	}
	if (symval != ALT_SYM_VALUE) {
		fprintf(stderr, "%s: Invalid attribute value: %llx != %llx\n",
			SYM_NAME, (long long) symval,
			(long long) ALT_SYM_VALUE);
		rc = TEST_FAIL;
	} else
		printf("%s = %llx\n", SYM_NAME, (long long) symval);


	attr.val.string= str(ALT_LEN_VALUE);
	status = kdump_set_attr(ctx, ATTR_LINES ".LENGTH(" LEN_NAME ")",
				&attr);
	if (status != kdump_ok) {
		fprintf(stderr, "Cannot modify %s: %s\n",
			ATTR_LINES ".LENGTH(" LEN_NAME ")",
			kdump_err_str(ctx));
		return TEST_ERR;
	}
	tmprc = check_number(ctx, ATTR_LEN, ALT_LEN_VALUE);
	if (tmprc == TEST_ERR)
		return tmprc;
	if (tmprc != TEST_OK)
		rc = tmprc;

	attr.val.string= str(ALT_NUM_VALUE);
	status = kdump_set_attr(ctx, ATTR_LINES ".NUMBER(" NUM_NAME ")",
				&attr);
	if (status != kdump_ok) {
		fprintf(stderr, "Cannot modify %s: %s\n",
			ATTR_LINES ".NUMBER(" NUM_NAME ")",
			kdump_err_str(ctx));
		return TEST_ERR;
	}
	tmprc = check_number(ctx, ATTR_NUM, ALT_NUM_VALUE);
	if (tmprc == TEST_ERR)
		return tmprc;
	if (tmprc != TEST_OK)
		rc = tmprc;

	attr.val.string= str(ALT_OFF_VALUE);
	status = kdump_set_attr(ctx, ATTR_LINES ".OFFSET(" OFF_NAME ")",
				&attr);
	if (status != kdump_ok) {
		fprintf(stderr, "Cannot modify %s: %s\n",
			ATTR_LINES ".OFFSET(" OFF_NAME ")",
			kdump_err_str(ctx));
		return TEST_ERR;
	}
	tmprc = check_number(ctx, ATTR_OFF, ALT_OFF_VALUE);
	if (tmprc == TEST_ERR)
		return tmprc;
	if (tmprc != TEST_OK)
		rc = tmprc;

	attr.val.string= str(ALT_SIZE_VALUE);
	status = kdump_set_attr(ctx, ATTR_LINES ".SIZE(" SIZE_NAME ")",
				&attr);
	if (status != kdump_ok) {
		fprintf(stderr, "Cannot modify %s: %s\n",
			ATTR_LINES ".SIZE(" SIZE_NAME ")",
			kdump_err_str(ctx));
		return TEST_ERR;
	}
	tmprc = check_number(ctx, ATTR_SIZE, ALT_SIZE_VALUE);
	if (tmprc == TEST_ERR)
		return tmprc;
	if (tmprc != TEST_OK)
		rc = tmprc;

	/* Check cleanup */

	return rc;
}
Exemple #29
0
void parse_incoming_sms(){
	uint8_t temp = 0;
	int32_t temp2 = 0;
	int32_t temp3 = 0;
	int i;
	char command_str[70];
	char command[20];
	char command_count = 0;
	char bug_command_count = 0;
	for (i = 0;i<11;i++) tel_number_temp[i] = gsm_message[i+24];
	last_control_ID_number = check_number(tel_number_temp);

	if (last_control_ID_number > MAX_TEL_NUMBERS) return;
	sms_ucs_to_eng(gsm_message, input_sms_message);
#ifdef DEBUG_MODEM
	send_string_to_UART3("INCOMING SMS! NUMBER: ");
	send_string_to_UART3(tel_number_temp);
	send_string_to_UART3(" ID: ");
	send_int_to_UART3(last_control_ID_number);
	send_string_to_UART3(" \n\r");
	send_string_to_UART3(" SMS: ");
	send_string_to_UART3(input_sms_message);
	send_string_to_UART3(" \n\r");
#endif
	while(get_next_command_from_sms(input_sms_message,command_str,command_count)){
		command_count++;
#ifdef DEBUG_MODEM
	send_string_to_UART3("Progessing command: ");
	send_string_to_UART3(command_str);
	send_string_to_UART3("\n\r");
#endif
		switch(command_str[0]){
	//nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
			case 'n':
				switch(command_str[1]){
					case 'n':
						//nnX +79021201364
						sms_command_nn(command_str);

					break;
					case 't':
						//ntX -10,29,00010011
						temp = 0;
						temp2 = parse_int_in_message(command_str,4);
						temp3 = parse_int_in_message(command_str,(4 + get_size_number(temp2) + 1));
						for (i = 0;;i++) {
							char a = command_str[4 + i + get_size_number(temp2) + 1 + get_size_number(temp3) +1];
							if ((a != '0') && (a != '1')) break;
								temp = (temp<<1) | (a - '0');
						}
						set_ds18x20_settings((command_str[2]-'0'),temp2,temp3,temp);
					break;
					case 'v':
						temp = 0;
						if (command_str[2] == 't'){
							if (command_str[3] < '0' || command_str[3] > '9') break;
							//nvt1 dverb zapili
							set_input_text((command_str[3]-'0'),command_str);
						}else{
							if (command_str[2] < '0' || command_str[2] > '9') break;
							//nv1 3,7,000,2
							for (i = 0;;i++) {
							if ((command_str[8 + i] != '0') && (command_str[8 + i] != '1')) break;
								temp = (temp<<1) | (command_str [8 + i] - '0');
							}
							set_input_settings(
										(command_str[2]-'0'),
										(command_str[4]-'0'),
										(command_str[6]-'0'),
										temp,
										parse_int_in_message(command_str,(8+i+1))
									);
						}

					break;
					case 'r':
						//nr lov12
						for (i = 0;i < MAX_OUTPUT;i++){
							set_output_settings(i,(command_str[3 + i]));
						}
					break;
					case 'i':
						//ni lov12
						for (i = 0;i < MAX_LED;i++){
							set_led_settings(i,(command_str[3 + i]));
						}
					break;
					case 'p':
						//np 93
						setting_powered(1);
					break;
					case 'a':
						//np 93
						setting_powered(2);
					break;
					case 's':
						//ns
						temp = 0;
						temp2 = 0;
						temp3 = 0;
						for (i = 0;;i++) {
							if ((command_str[3 + i] != '0') && (command_str[3 + i] != '1')) break;
							temp = (temp<<1) | (command_str[3 + i] - '0');
						}
						temp2 = parse_int_in_message(command_str,(3+i+1));
						temp3 = parse_int_in_message(command_str,(3+i+1+ get_size_number(temp2) +1));
						set_device_setting(temp,temp2,temp3);

					break;
					default:
						bug_command_count++;
					break;

				}
			break;
	//oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
			case 'o':
				//o0 o1 o
					str_add_str(last_control_guard,sizeof(last_control_guard),"+79",0);
					convert_number_to_eng(tel_number_temp);
					str_add_str(last_control_guard,sizeof(last_control_guard),tel_number_temp,10);
					if (command_str[1]) set_new_guard_st((command_str[1] - '0'));
					else set_new_guard_st(!get_guard_st());

			break;
	//rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
			case 'r':
				//r
					sms_command_r();
			break;
	//bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
			case 'b':
				//b *102#

				temp = str_length(command_str);
				for (i = 0; i < (temp - 2);i++){
					command[i] = command_str[i+2];
				}
				command[i+1] = 0;
				send_string_to_GSM("AT+CUSD=1,\"");
				send_string_to_GSM(command);
				send_command_to_GSM("\"","OK",gsm_message,2,5);
	//			send_command_to_GSM("AT+CUSD=1,\"*102#\"","OK",gsm_message,2,5);
			break;
	//aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
			case 'a':
				if ((command_str[1]) == 's') {
					//vs 3
					if (!command_str[3]) FULL_RESET();
					temp = parse_int_in_message(command_str,(3));
					set_time_to_reset(temp);
				}else if ((command_str[1]) == 'r'){
					//vr 48
					setting_time_to_report(parse_int_in_message(command_str,(3)));
				}else{
					bug_command_count++;
				}

			break;
	//UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU
			case 'u':
				if ((command_str[1]) == 'v') {
					//vs 3
					temp2 = parse_int_in_message(command_str,4);
					sms_control_output((command_str[2] - '0'), temp2);
				}else{
					bug_command_count++;
				}

			break;
//SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
			case 's':
				if ((command_str[1]) == 'b')
					if ((command_str[2]) == 'r')
						if ((command_str[3]) == 'o')
							if ((command_str[4]) == 's')
								FULL_ERASE_DEVICE();

			break;
			default:
				bug_command_count++;
			break;
		}

		for (i = 0;i<70;i++){
			if (!command_str[i]) break;
			command_str[i] = 0;
		}

	}

	if (check_device_setting(DEVICE_SETTING_SMS_AT_SMS_COMMAND)){
			if ((command_count - bug_command_count)){
				str_add_str(output_sms_message,sizeof(output_sms_message),"prinqto komand: ",0);
				str_add_num(output_sms_message,(command_count - bug_command_count));
			}
			if (bug_command_count){
					str_add_str(output_sms_message,sizeof(output_sms_message)," \nnevernaq komanda: ",0);
					str_add_num(output_sms_message,bug_command_count);
			}
			send_sms_message_for_all(output_sms_message,SMS_FUNCTION_SERVICE);
		}
	for (i = 0;i<70;i++) input_sms_message[i] = 0;
}
Exemple #30
0
void AskParams(struct options* options, int argc, char** argv, int rank) {
    int ret;

    if (rank == 0) {
        printf(
            "============================================================\n");
        printf(
            "Program for calculation of partial differential equations.  \n");
        printf(
            "============================================================\n");
        printf("(c) Dr. Thomas Ludwig, TU München.\n");
        printf("    Thomas A. Zochler, TU München.\n");
        printf("    Andreas C. Schmidt, TU München.\n");
        printf(
            "============================================================\n");
        printf("\n");
    }

    if (argc < 2) {
        /* ----------------------------------------------- */
        /* Get input: method, interlines, func, precision. */
        /* ----------------------------------------------- */
        do {
            printf("\n");
            printf("Select number of threads:\n");
            printf("Number> ");
            fflush(stdout);
            ret = scanf("%" SCNu64, &(options->number));
            while (getchar() != '\n')
                ;
        } while (ret != 1 || !check_number(options));

        do {
            printf("\n");
            printf("Select calculationmethod:\n");
            printf("  %1d: Gauss-Seidel.\n", METH_GAUSS_SEIDEL);
            printf("  %1d: Jacobi.\n", METH_JACOBI);
            printf("method> ");
            fflush(stdout);
            ret = scanf("%" SCNu64, &(options->method));
            while (getchar() != '\n')
                ;
        } while (ret != 1 || !check_method(options));

        do {
            printf("\n");
            printf("Matrixsize = Interlines*8+9\n");
            printf("Interlines> ");
            fflush(stdout);
            ret = scanf("%" SCNu64, &(options->interlines));
            while (getchar() != '\n')
                ;
        } while (ret != 1 || !check_interlines(options));

        do {
            printf("\n");
            printf("Select interferencefunction:\n");
            printf(" %1d: f(x,y)=0.\n", FUNC_F0);
            printf(" %1d: f(x,y)=2pi^2*sin(pi*x)sin(pi*y).\n", FUNC_FPISIN);
            printf("interferencefunction> ");
            fflush(stdout);
            ret = scanf("%" SCNu64, &(options->inf_func));
            while (getchar() != '\n')
                ;
        } while (ret != 1 || !check_inf_func(options));

        do {
            printf("\n");
            printf("Select termination:\n");
            printf(" %1d: sufficient precision.\n", TERM_PREC);
            printf(" %1d: number of iterationes.\n", TERM_ITER);
            printf("termination> ");
            fflush(stdout);
            ret = scanf("%" SCNu64, &(options->termination));
            while (getchar() != '\n')
                ;
        } while (ret != 1 || !check_termination(options));

        if (options->termination == TERM_PREC) {
            do {
                printf("\n");
                printf("Select precision:\n");
                printf("  Range: 1e-4 .. 1e-20.\n");
                printf("precision> ");
                fflush(stdout);
                ret = scanf("%lf", &(options->term_precision));
                while (getchar() != '\n')
                    ;
            } while (ret != 1 || !check_term_precision(options));

            options->term_iteration = MAX_ITERATION;
        } else if (options->termination == TERM_ITER) {
            do {
                printf("\n");
                printf("Select number of iterations:\n");
                printf("  Range: 1 .. %d.\n", MAX_ITERATION);
                printf("Iterations> ");
                fflush(stdout);
                ret = scanf("%" SCNu64, &(options->term_iteration));
                while (getchar() != '\n')
                    ;
            } while (ret != 1 || !check_term_iteration(options));

            options->term_precision = 0;
        }
    } else {
        if (argc < 7 || strcmp(argv[1], "-h") == 0 ||
            strcmp(argv[1], "-?") == 0) {
            usage(argv[0]);
            exit(0);
        }

        ret = sscanf(argv[1], "%" SCNu64, &(options->number));

        if (ret != 1 || !check_number(options)) {
            usage(argv[0]);
            exit(1);
        }

        ret = sscanf(argv[2], "%" SCNu64, &(options->method));

        if (ret != 1 || !check_method(options)) {
            usage(argv[0]);
            exit(1);
        }

        ret = sscanf(argv[3], "%" SCNu64, &(options->interlines));

        if (ret != 1 || !check_interlines(options)) {
            usage(argv[0]);
            exit(1);
        }

        ret = sscanf(argv[4], "%" SCNu64, &(options->inf_func));

        if (ret != 1 || !check_inf_func(options)) {
            usage(argv[0]);
            exit(1);
        }

        ret = sscanf(argv[5], "%" SCNu64, &(options->termination));

        if (ret != 1 || !check_termination(options)) {
            usage(argv[0]);
            exit(1);
        }

        if (options->termination == TERM_PREC) {
            ret = sscanf(argv[6], "%lf", &(options->term_precision));
            options->term_iteration = MAX_ITERATION;

            if (ret != 1 || !check_term_precision(options)) {
                usage(argv[0]);
                exit(1);
            }
        } else {
            ret = sscanf(argv[6], "%" SCNu64, &(options->term_iteration));
            options->term_precision = 0;

            if (ret != 1 || !check_term_iteration(options)) {
                usage(argv[0]);
                exit(1);
            }
        }
    }
}