예제 #1
0
//--------------------------------------------------------------------------------------------------
void NextionComponent::command_txt(const char* value)
{
  send(this->name);
  send(F2C(".txt=\""));
  send(value);
  send(F2C("\""));
  sendDone();  
}
예제 #2
0
파일: import.c 프로젝트: ScilabOrg/scilab
/*never used, never interfaced */
int C2F(getsciblockbylabel)(int*kfun, int label[], int *n)
{
    int k, i, i0, nblk, n1;
    int job = 1;
    char* lab[100];
    if (scicos_imp.x == (double *)NULL)
    {
        return (2); /* undefined import table scicos is not running */
    }
    nblk = scicos_imp.nblk[0];

    F2C(cvstr)(n, lab, *label, &job, *n);

    *kfun = 0;
    for (k = 0; k < nblk; k++)
    {
        n1 = (int)(scicos_imp.izptr[k] - scicos_imp.izptr[k - 1]);
        if (n1 == *n)
        {
            i0 = scicos_imp.izptr[k - 1] - 1;
            i = 0;
            while ((lab[i] == scicos_imp.iz[i0 + i]) & (i < n1))
            {
                i++;
            }
            if (i == n1)
            {
                *kfun = k + 1;
                return 0;
            }
        }
    }
    return 0;
}
예제 #3
0
//--------------------------------------------------------------------------------------------------
void Nextion::sleepDelay(uint8_t seconds)
{
  String num;
  num = seconds;
  send(F2C("thsp="));
  send(num.c_str());
  sendEndOfPacket(); 
}
예제 #4
0
//--------------------------------------------------------------------------------------------------
void Nextion::page(uint8_t pageNum)
{
  send(F2C("page "));
  String num;
  num = pageNum;
  send(num.c_str());
  sendEndOfPacket();
}
예제 #5
0
//--------------------------------------------------------------------------------------------------
void Nextion::fontYSpacing(uint8_t spacing)
{
  send(F2C("spay="));
  String num;
  num = spacing;
  send(num.c_str());
  sendEndOfPacket(); 
  
}
예제 #6
0
//--------------------------------------------------------------------------------------------------
void NextionComponent::command_click(bool isReleaseEvent)
{
  send(F2C("click "));
  send(this->name);
  send(",");
  send(isReleaseEvent ? "0" : "1");
  sendDone();
  
}
예제 #7
0
void C2F(ccharf)(int *n, char **ip, int *op)
{
    int i = 0;
    if (*n > 0)
    {
        F2C(cvstr)(n, op, *ip, &i, *n);
        FREE(*ip);
    }
}
예제 #8
0
//--------------------------------------------------------------------------------------------------
void NextionComponent::command_vis(uint8_t val)
{
  send(F2C("vis "));
  send(this->name);
  send(",");
  String s;
  s = val;
  send(s.c_str());
  sendDone();
    
}
예제 #9
0
//--------------------------------------------------------------------------------------------------
void Nextion::sysVariable(uint8_t sysVarNumber,uint32_t val)
{
  send(F2C("sys"));
  String num;
  num = sysVarNumber;
  send(num.c_str());
  send("=");
  num = val;
  send(num.c_str());
  sendEndOfPacket();
  
}
예제 #10
0
//--------------------------------------------------------------------------------------------------
void Nextion::brightness(uint8_t bright, bool setAsDefault)
{
  send(F2C("dim"));
  if(setAsDefault)
    send("s");

  send("=");
  String num;
  num = bright;
  send(num.c_str());

  sendEndOfPacket();  
}
예제 #11
0
//--------------------------------------------------------------------------------------------------
void NextionComponent::command_pconum(uint8_t val, uint16_t color)
{
  String num;
  num = val;
  
  send(this->name);
  send(F2C(".pco"));
  send(num.c_str());
  send("=");
  num = color;
  send(num.c_str());
  sendDone();    
}
예제 #12
0
//--------------------------------------------------------------------------------------------------
void Nextion::baudRate(uint16_t baud, bool setAsDefault)
{
  send(F2C("baud"));
  if(setAsDefault)
    send("s");

  send("=");
  String num;
  num = baud;
  send(num.c_str());

  sendEndOfPacket();
  
}
예제 #13
0
//--------------------------------------------------------------------------------------------------
void NextionComponent::command_waveformdata(uint8_t id, uint8_t channel, uint8_t val)
{
  String num;
  num = id;
  send(F2C("add "));
  send(num.c_str());
  send(",");
  num = channel;
  send(num.c_str());
  send(",");
  num = val;
  send(num.c_str());
  
}
예제 #14
0
void  Impostor::AddSample( vcg::Point3f  p,   vcg::Point3f   n, vcg::Color4b c){
	if(box.IsIn(p)){
                const int ii = std::min<int>( int((p[0]-box.min[0])/cellsize),Gridsize()-1);
		const int jj = std::min<int>( int((p[1]-box.min[1])/cellsize),Gridsize()-1);
		const int kk = std::min<int>( int((p[2]-box.min[2])/cellsize),Gridsize()-1);

		if(n_samples.IsOn(ii,jj,kk)){
						assert(n_samples.At(ii,jj,kk) != 0);
						centroids.At(ii,jj,kk) = Acc(centroids.At(ii,jj,kk),F2C(p,ii,jj,kk),n_samples.At(ii,jj,kk));
						normals.At(ii,jj,kk)   = Acc(normals.At(ii,jj,kk),F2C_01(n),n_samples.At(ii,jj,kk));
                        colors.At(ii,jj,kk)   = Acc_0_255(colors.At(ii,jj,kk),F2C(c),n_samples.At(ii,jj,kk));
                        ++n_samples.At(ii,jj,kk);
                }
		else{
                        n_samples.At(ii,jj,kk)  = 1;
						centroids.At(ii,jj,kk)  =  F2C(p,ii,jj,kk);
                        normals.At(ii,jj,kk)    =  F2C_01(n);
                        colors.At(ii,jj,kk)     =  F2C(c);

                }

	}
}
예제 #15
0
void C2F(cstringf) (char ***ip, int *sciptr, int *m, int *n, int *max, int *ierr)
{
    int i, j, l, ie;
    int job = 0;
    int *chars;
    *ierr = 0;
    if (5 + *m * *n > *max)
    {
        *ierr = 1;
        return;
    }
    sciptr[0] = sci_strings;
    sciptr[1] = *m;
    sciptr[2] = *n;
    sciptr[3] = 0;
    sciptr[4] = 1;
    chars = &(sciptr[5 + *m * *n]);
    ie = 0;
    for (j = 0; j < *n; j++)
    {
        for (i = 0; i < *m; i++)
        {
            l = (int)strlen((*ip)[ie]);
            sciptr[ie + 5] = sciptr[ie + 4] + l;
            if (5 + *m * *n + sciptr[ie + 5] > *max)
            {
                *ierr = 1;
                return;
            }
            F2C(cvstr)(&l, &(chars[sciptr[ie + 4] - 1]), (*ip)[ie], &job, l);
            FREE((*ip)[ie]);
            ie++;
        }
    }
    FREE((char *)*ip);
}
예제 #16
0
/*--------------------------------------------------------------------------*/
int sci_legendre(char *fname,unsigned long fname_len)
{
    /*
    *   Interface onto the (Slatec) dxleg.f code.
    *   Scilab calling sequence :
    *
    *   p = legendre(n, m, x [, norm_flag] )
    *
    *      x is a vector with mnx elements (it is better to
    *        have a row vector but this is not forced)
    *
    *      n : a non negative int scalar (or a vector of such
    *          int regularly speced with an increment of 1)
    *      m : same constraints than for n
    *
    *      n and m may not be both vectors
    *
    *      norm_flag : optionnal. When it is present and equal to "norm"
    *                  it is a normalised version which is computed
    *    AUTHOR
    *       Bruno Pincon <*****@*****.**>
    */
    int it = 0, lc = 0, mM = 0, nM = 0, lM = 0, m1 = 0, m2 = 0, mN = 0, nN = 0;
    int lN = 0, n1 = 0, n2 = 0, mx = 0, nx = 0, lx = 0, mnx = 0, ms = 0, ns = 0, ls = 0;
    int M_is_scalar = 0, N_is_scalar = 0, normalised = 0, MNp1 = 0, lpqa = 0, lipqa = 0, *ipqa = NULL;
    double *x = NULL, xx = 0., dnu1 = 0., *pqa = NULL;
    int id = 0, ierror = 0, i = 0, j = 0, nudiff = 0;

    CheckLhs(1, 1);
    CheckRhs(3, 4);
    GetRhsVar(1, MATRIX_OF_DOUBLE_DATATYPE, &mN, &nN, &lN);

    if ( ! verify_cstr(stk(lN), mN*nN, &n1, &n2) )
    {
        Scierror(999,_("%s: Wrong type for first input argument.\n"), fname);
        return 0;
    };

    if ( mN == 1 && nN == 1) N_is_scalar = 1;

    GetRhsVar(2,MATRIX_OF_DOUBLE_DATATYPE, &mM, &nM, &lM);
    if ( ! verify_cstr(stk(lM), mM*nM, &m1, &m2) )
    {
        Scierror(999,_("%s: Wrong type for input argument #%d.\n"), fname,2);
        return 0;
    }

    if ( mM == 1 && nM == 1) M_is_scalar = 1;

    if ( ! M_is_scalar  &&  ! N_is_scalar )
    {
        Scierror(999,_("%s: Only one of arg1 and arg2 may be a vector.\n"), fname);
        return 0;
    };

    GetRhsCVar(3,MATRIX_OF_DOUBLE_DATATYPE, &it, &mx, &nx, &lx, &lc);
    if ( it != 0 )
    {
        Scierror(999,_("%s: Wrong type for input argument #%d: Real matrix expected.\n"), fname, 3);
        return 0;
    };

    mnx = mx*nx;
    x = stk(lx);
    for ( i = 0 ; i < mnx ; i++ )
        if ( ! (fabs(x[i]) < 1.0) )
        {
            Scierror(999,_("%s: Wrong value for input argument #%d: Matrix with elements in (%d,%d) expected.\n"), fname,3,-1,1);
            return 0;
        };

    if ( Rhs == 4 )
    {
        GetRhsVar(4,STRING_DATATYPE, &ms, &ns, &ls);
        if ( strcmp(cstk(ls),"norm") == 0)
        {
            normalised = 1;
        }
        else
        {
            normalised = 0;
        }
    }
    else
    {
        normalised = 0;
    }

    MNp1 = Max (n2 - n1, m2 - m1) + 1;

    CreateVar(Rhs+1, MATRIX_OF_DOUBLE_DATATYPE, &MNp1, &mnx, &lpqa);
    pqa = stk(lpqa);
    CreateVar(Rhs+2, MATRIX_OF_INTEGER_DATATYPE, &MNp1, &mnx, &lipqa);
    ipqa = istk(lipqa);

    if ( normalised )
    {
        id = 4;
    }
    else
    {
        id = 3;
    }

    nudiff = n2 - n1;
    dnu1 = (double) n1;

    for ( i = 0 ; i < mnx ; i++ )
    {
        xx = fabs(x[i]); /* dxleg computes only for x in [0,1) */
        F2C(dxlegf) (&dnu1, &nudiff, &m1, &m2, &xx, &id,
                     stk(lpqa+i*MNp1), istk(lipqa+i*MNp1), &ierror);
        if ( ierror != 0 )
        {
            if ( ierror == 207 ) /* @TODO what is 207 ? */
            {
                Scierror(999,_("%s: overflow or underflow of an extended range number\n"), fname);
            }
            else
            {
                Scierror(999,_("%s: error number %d\n"), fname, ierror);
            }
            return 0;
        };
    }

    /*  dxlegf returns the result under a form (pqa,ipqa) (to
    *  compute internaly with an extended exponent range)
    *  When the "exponent" part (ipqa) is 0 then the number is exactly
    *  given by pqa else it leads to an overflow or an underflow.
    */
    for ( i = 0 ; i < mnx*MNp1 ; i++ )
    {
        if ( ipqa[i] < 0 )
        {
            pqa[i] = 0.0;
        }
        if ( ipqa[i] > 0 )
        {
            pqa[i] = pqa[i] * return_an_inf(); /* pqa[i] * Inf  to have the sign */
        }
    }

    /* complete the result by odd/even symmetry for negative x */
    for ( i = 0 ; i < mnx ; i++ )
    {
        if ( x[i] < 0.0 )
        {
            if ( (n1+m1) % 2 == 1 )
            {
                for ( j = 0 ; j < MNp1 ; j+=2 )
                {
                    pqa[i*MNp1 + j] = -pqa[i*MNp1 + j];
                }
            }
            else
            {
                for ( j = 1 ; j < MNp1 ; j+=2 )
                {
                    pqa[i*MNp1 + j] = -pqa[i*MNp1 + j];
                }
            }
        }
    }
    LhsVar(1) = Rhs + 1;
    PutLhsVar();
    return 0;
}
예제 #17
0
파일: test.c 프로젝트: ccdwt/WindTurbine
int main(int argc, char *argv[])
{
    int sockfd, numbytes;  
    char buf[MAXDATASIZE];
    char version[50];
    hilow_parse hilow;
    loop_parse loop;// __attribute__ ((packed));
    struct addrinfo hints, *servinfo, *p;
    int rv;
    char s[INET6_ADDRSTRLEN];

    if (argc != 2) {
        fprintf(stderr,"usage: client hostname\n");
        exit(1);
    }

    memset(&hints, 0, sizeof hints);
    hints.ai_family = AF_UNSPEC;
    hints.ai_socktype = SOCK_STREAM;

    if ((rv = getaddrinfo(argv[1], PORT, &hints, &servinfo)) != 0) {
        fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv));
        return 1;
    }

    // loop through all the results and connect to the first we can
    for(p = servinfo; p != NULL; p = p->ai_next) {
        if ((sockfd = socket(p->ai_family, p->ai_socktype,
                p->ai_protocol)) == -1) {
            perror("client: socket");
            continue;
        }

        if (connect(sockfd, p->ai_addr, p->ai_addrlen) == -1) {
            close(sockfd);
            perror("client: connect");
            continue;
        }

        break;
    }

    if (p == NULL) {
        fprintf(stderr, "client: failed to connect\n");
        return 2;
    }

    inet_ntop(p->ai_family, get_in_addr((struct sockaddr *)p->ai_addr),
            s, sizeof s);
    //printf("client: connecting to %s\n", s);

    freeaddrinfo(servinfo); // all done with this structure


/***	HILOWS	***/
    buffer data = get_weather("HILOWS",sockfd);
    find_start(&data);
    memcpy(&hilow,data.data,data.len);
    printf("daily high wind speed = %umph\n", hilow.wind.day);
    printf("daily high temperature = %.2f F\n",((float)hilow.outTemp.dayHigh/10));
    printf("daily low DP = %d F\n",hilow.dewPoint.dayLow);
    printf("mothly high Humididty = %u%%\n", hilow.extraHums.monthHigh[0]);
    printf("daily Low Humidity = %u%%\n", hilow.extraHums.dayLow[0]);
    data = get_weather("LOOP 1",sockfd);
    find_start(&data);
    memcpy(&loop,data.data,data.len);
    //printInHex(data.data,data.len);printf("\n");

//    printf("id\t\t\t= %c%c%c\n",loop.id[0], loop.id[1], loop.id[2]);
//    printf("barTrend\t\t= %u\n", loop.barTrend);
//    printf("Packet type\t\t= %u\n",(loop.packetType));
//    printf("NextRecord\t\t= %u\n",loop.nextRecord);
    printf("barometric pressure\t= %.3f in. Hg\n",(float)loop.barometer/1000);
//    printf("Inside Temperature\t= %.2f F %.2f C\n",((float)loop.insideTemperature/10), F2C((float)loop.insideTemperature/10));
//    printf("Inside Humidity\t\t= %d%%\n",loop.insideHumidity);
    printf("Outside Temperature\t= %.2f F %.2f C\n", ((float)loop.outsideTemperature/10),F2C((float)loop.outsideTemperature/10));
    printf("Wind Speed\t\t= %u mph\n", loop.windSpeed);
    printf("10 Min Avg Wind Speed\t= %d mph\n",loop.tenMinAvgWS);
    printf("Wind Direction\t\t= %u degrees\n", loop.windDirection);
    printf("outside Humidity \t= %d%%\n",loop.outsideHumidity);
    printf("Rain Rate\t\t= %.2f in. per hour\n",((float)loop.rainRate/100));
    printf("Solar Radiation\t\t= %u watts/m^2\n",loop.solarRadiation);
    printf("Day Rain \t\t= %.2f in.\n",((float)loop.dayRain/100)); 
    printf("Month Rain \t\t= %.2f in.\n",((float)loop.monthRain/100)); 
    printf("Year Rain \t\t= %.2f in.\n",((float)loop.yearRain/100)); 
    printf("Day ET \t\t\t= %.2f in.\n",((float)loop.dayET/100)); 
    printf("Month ET \t\t= %.2f in.\n",((float)loop.monthET/100)); 
    printf("Year ET \t\t= %.2f in.\n",((float)loop.yearET/100)); 
    printf("sunrise was at \t\t  %d:%.2d\n", loop.timeOfSunrise/100, loop.timeOfSunrise %100);
    printf("sunset was at \t\t  %d:%.2d\n",loop.timeOfSunset/100,loop.timeOfSunset %100);
    close(sockfd);

    return 0;
}
예제 #18
0
/* ==================================================================== */
int sci_fsum(char *fname, void* pvApiCtx)
{
    SciErr sciErr;

    int m1 = 0, n1 = 0;
    int *piAddressVarOne = NULL;
    double *pdVarOne = NULL;
    int iType1 = 0;

    int m2 = 0, n2 = 0;
    int *piAddressVarTwo = NULL;
    double *pdVarTwo = NULL;
    int iType2 = 0;

    int m_out = 0, n_out = 0;
    double dOut = 0.0;

    /* --> result = csum(3,8)
    /* check that we have only 2 parameters input */
    /* check that we have only 1 parameters output */
    CheckInputArgument(pvApiCtx, 2, 2) ;
    CheckOutputArgument(pvApiCtx, 1, 1) ;

    /* get Address of inputs */
    sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddressVarOne);
    if (sciErr.iErr)
    {
        printError(&sciErr, 0);
        return 0;
    }

    sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddressVarTwo);
    if (sciErr.iErr)
    {
        printError(&sciErr, 0);
        return 0;
    }

    /* check input type */
    sciErr = getVarType(pvApiCtx, piAddressVarOne, &iType1);
    if (sciErr.iErr)
    {
        printError(&sciErr, 0);
        return 0;
    }

    if ( iType1 != sci_matrix )
    {
        Scierror(999, _("%s: Wrong type for input argument #%d: A scalar expected.\n"), fname, 1);
        return 0;
    }

    sciErr = getVarType(pvApiCtx, piAddressVarTwo, &iType2);
    if (sciErr.iErr)
    {
        printError(&sciErr, 0);
        return 0;
    }

    if ( iType2 != sci_matrix )
    {
        Scierror(999, _("%s: Wrong type for input argument #%d: A scalar expected.\n"), fname, 2);
        return 0;
    }

    /* get matrix */
    sciErr = getMatrixOfDouble(pvApiCtx, piAddressVarOne, &m1, &n1, &pdVarOne);
    if (sciErr.iErr)
    {
        printError(&sciErr, 0);
        return 0;
    }

    sciErr = getMatrixOfDouble(pvApiCtx, piAddressVarTwo, &m2, &n2, &pdVarTwo);
    if (sciErr.iErr)
    {
        printError(&sciErr, 0);
        return 0;
    }

    /* check size */
    if ( (m1 != n1) && (n1 != 1) )
    {
        Scierror(999, _("%s: Wrong size for input argument #%d: A scalar expected.\n"), fname, 1);
        return 0;
    }
    if ( (m2 != n2) && (n2 != 1) )
    {
        Scierror(999, _("%s: Wrong size for input argument #%d: A scalar expected.\n"), fname, 2);
        return 0;
    }

    /* call fortran subroutine fsum */
    F2C(fsum)(&pdVarOne[0], &pdVarTwo[0], &dOut);

    /* create result on stack */
    m_out = 1;
    n_out = 1;
    sciErr = createMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, m_out, n_out, &dOut);
    if (sciErr.iErr)
    {
        printError(&sciErr, 0);
        return 0;
    }
    AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;

    return 0;
}
예제 #19
0
//--------------------------------------------------------------------------------------------------
void NextionComponent::command_dir(NextionScrollingDirection direction)
{
  send(F2C("dir"), int32_t(direction));
}
예제 #20
0
void C2F(cchar)(int *n, char **ip, int *op)
{
    int i = 0;
    F2C(cvstr)(n, op, *ip, &i, *n);
}
예제 #21
0
//--------------------------------------------------------------------------------------------------
void NextionComponent::command_gdw(uint16_t val)
{
  send(F2C("gdw"), val);
}
예제 #22
0
//--------------------------------------------------------------------------------------------------
void Nextion::wakeOnTouch(bool awake)
{
  send(F2C("thup="));
  send(awake ? "1" : "0");
  sendEndOfPacket();
}
예제 #23
0
//--------------------------------------------------------------------------------------------------
void NextionComponent::command_dis(uint8_t distance)
{
  send(F2C("dis"), distance);
}
예제 #24
0
//--------------------------------------------------------------------------------------------------
void NextionComponent::command_format(NextionNumberFormat format)
{
  send(F2C("format"), int32_t(format));    
}
예제 #25
0
//--------------------------------------------------------------------------------------------------
void NextionComponent::command_en(uint8_t en)
{
  send(F2C("en"), en);
}
예제 #26
0
//--------------------------------------------------------------------------------------------------
void NextionComponent::command_val(int32_t val)
{
  send(F2C("val"), val);
}
예제 #27
0
//--------------------------------------------------------------------------------------------------
void NextionComponent::command_pw(NextionInputType type)
{
  send(F2C("pw"), int32_t(type));  
}
예제 #28
0
//--------------------------------------------------------------------------------------------------
void Nextion::startRefresh()
{
  send(F2C("ref_star"));
  sendEndOfPacket();
}
예제 #29
0
//--------------------------------------------------------------------------------------------------
void Nextion::receiveTouchEvents(bool receive)
{
  send(F2C("sendxy="));
  send(receive ? "1" : "0");
  sendEndOfPacket();
}
예제 #30
0
//--------------------------------------------------------------------------------------------------
void Nextion::sleep(bool enterSleep)
{
  send(F2C("sleep="));
  send(enterSleep ? "1" : "0");
  sendEndOfPacket();
}