⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iniaux.cc

📁 Source code for an Numeric Cmputer
💻 CC
字号:
/********************************************************************* Description: iniaux.cc*   INI file initialization for aux controller**   Derived from a work by Fred Proctor & Will Shackleford** Author:* License: GPL Version 2* System: Linux*    * Copyright (c) 2004 All rights reserved.** Last change:* $Revision: 1.8 $* $Author: yabosukz $* $Date: 2005/07/08 14:52:44 $********************************************************************/extern "C" {#include <stdio.h>		// NULL, sscanf}#include "emc.hh"#include "inifile.hh"#include "iniaux.hh"		// these decls#include "emcglb.h"		// ESTOP_SENSE_INDEX, etc// inifile ref'ed by iniAux(), loadAux() static Inifile *auxInifile = 0;/*  loadAux()  Loads ini file params for aux from [EMCIO] section  ESTOP_SENSE_INDEX <int>      dio point for mist aux on/off  ESTOP_WRITE_INDEX <int>     dio point for flood aux on/off  ESTOP_SENSE_POLARITY <0,1>   polarity for mist on  ESTOP_WRITE_POLARITY <0,1>  polarity for flood on  calls:  emcAuxEstopSetSenseIndex(int index);  emcAuxEstopSetWriteIndex(int index);  emcAuxEstopSetSensePolarity(int polarity);  emcAuxEstopSetWritePolarity(int polarity);  */static int loadAux(){    int retval = 0;    const char *inistring;    int i;    if (NULL !=	(inistring = auxInifile->find("ESTOP_SENSE_INDEX", "EMCIO"))) {	if (1 == sscanf(inistring, "%d", &i)) {	    // found, and valid	    if (0 != emcAuxEstopSetSenseIndex(i)) {		printf("bad return value from emcAuxEstopSetSenseIndex\n");		retval = -1;	    }	} else {	    // found, but invalid, so warn	    printf("invalid inifile value for ESTOP_SENSE_INDEX: %s\n",		   inistring);	}    }    // else ignore omission    if (NULL !=	(inistring = auxInifile->find("ESTOP_WRITE_INDEX", "EMCIO"))) {	if (1 == sscanf(inistring, "%d", &i)) {	    // found, and valid	    if (0 != emcAuxEstopSetWriteIndex(i)) {		printf("bad return value from emcAuxEstopSetWriteIndex\n");		retval = -1;	    }	} else {	    // found, but invalid, so warn	    printf("invalid inifile value for ESTOP_WRITE_INDEX: %s\n",		   inistring);	}    }    // else ignore omission    if (NULL !=	(inistring = auxInifile->find("ESTOP_SENSE_POLARITY", "EMCIO"))) {	if (1 == sscanf(inistring, "%d", &i)) {	    // found, and valid	    if (0 != emcAuxEstopSetSensePolarity(i)) {		printf		    ("bad return value from emcAuxEstopSetSensePolarity\n");		retval = -1;	    }	} else {	    // found, but invalid, so warn	    printf("invalid inifile value for ESTOP_SENSE_POLARITY: %s\n",		   inistring);	}    }    // else ignore omission    if (NULL !=	(inistring = auxInifile->find("ESTOP_WRITE_POLARITY", "EMCIO"))) {	if (1 == sscanf(inistring, "%d", &i)) {	    // found, and valid	    if (0 != emcAuxEstopSetWritePolarity(i)) {		printf		    ("bad return value from emcAuxEstopSetWritePolarity\n");		retval = -1;	    }	} else {	    // found, but invalid, so warn	    printf("invalid inifile value for ESTOP_WRITE_POLARITY: %s\n",		   inistring);	}    }    // else ignore omission    return retval;}/*  iniAux(const char *filename)  Loads ini file parameters for aux controller, from [EMCIO] section */int iniAux(const char *filename){    int retval = 0;    auxInifile = new Inifile;    if (auxInifile->open(filename) == false) {	return -1;    }    // load aux values    if (0 != loadAux()) {	retval = -1;    }    // close the inifile    auxInifile->close();    delete auxInifile;    return retval;}// implementations of functions to set ini file global variablesint emcAuxEstopSetSenseIndex(int index){    ESTOP_SENSE_INDEX = index;    return 0;}int emcAuxEstopSetWriteIndex(int index){    ESTOP_WRITE_INDEX = index;    return 0;}int emcAuxEstopSetSensePolarity(int polarity){    ESTOP_SENSE_POLARITY = polarity;    return 0;}int emcAuxEstopSetWritePolarity(int polarity){    ESTOP_WRITE_POLARITY = polarity;    return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -