Ejemplo n.º 1
0
CSensor_btprox::~CSensor_btprox()
{
  Cancel();

  BtClose();
  SESSION_CLOSE_IF_OPEN(iSocketServ);
  SESSION_CLOSE_IF_OPEN(iTimer);

  FreeResult(iResult);
  FreeResult(iOldResult);
}
Ejemplo n.º 2
0
GLBSYM GetIdentityElement_EM
    (LPPL_YYSTYPE lpYYFcnStrLft,    // Ptr to left operand function strand
     LPTOKEN      lptkLftArg,       // Ptr to left arg token
     LPPL_YYSTYPE lpYYFcnStrRht,    // Ptr to right operand function strand (may be NULL if Scan)
     LPTOKEN      lptkRhtArg)       // Ptr to right arg token

{
    LPPL_YYSTYPE lpYYRes = NULL,    // Ptr to intermediate result
                 lpYYRes2 = NULL,   // Ptr to secondary result
                 lpYYResL = NULL,   // Ptr to left result
                 lpYYResL2 = NULL,  // Ptr to secondary left result
                 lpYYResR = NULL,   // Ptr to right result
                 lpYYResR2 = NULL;  // Ptr to secondary right result
    GLBSYM       hGlbSym = {NULL};  // Result
    LPPRIMFLAGS  lpPrimFlagsLft;    // Ptr to Left operand primitive flags
    LPTOKEN      lptkAxisLft,       // Ptr to left operand axis token
                 lptkAxisRht;       // ...    right ...
    TOKEN        tkFcn = {0};       // Function token

    Assert (lpYYFcnStrLft NE NULL);
    Assert (lptkRhtArg    NE NULL);

    // If the right operand is defined (thus, it's Inner Product), ...
    if (lpYYFcnStrRht NE NULL)
    {
        LPPRIMFNS lpPrimProtoRht;               // Ptr to right operand prototype function
        TOKEN     tkLft = tkZero;               // Boolean zero token

        // Setup a token with the Boolean scalar zero
////////tkLft.tkFlags.TknType   = TKT_VARIMMED;     // Already set from tkZero
////////tkLft.tkFlags.ImmType   = IMMTYPE_BOOL;     // Already set from tkZero
////////tkLft.tkFlags.NoDisplay = FALSE;            // Already set from tkZero
////////tkLft.tkData.tkBoolean  = 0;                // Already set from tkZero
        tkLft.tkCharIndex       = lpYYFcnStrRht->tkToken.tkCharIndex;

        // Setup a token with the {rho} function
        tkFcn.tkFlags.TknType   = TKT_FCNIMMED;
        tkFcn.tkFlags.ImmType   = IMMTYPE_PRIMFCN;
////////tkFcn.tkFlags.NoDisplay = FALSE;            // Already zero from tkZero
        tkFcn.tkData.tkChar     = UTF16_RHO;
        tkFcn.tkCharIndex       = lpYYFcnStrRht->tkToken.tkCharIndex;

        // Check for right operand axis operator
        lptkAxisRht = CheckAxisOper (lpYYFcnStrRht);

        // Execute the right operand between the left and right args
        //   as a prototype function if it's a UDFO

        // Get the appropriate prototype function ptr
        lpPrimProtoRht = GetPrototypeFcnPtr (&lpYYFcnStrRht->tkToken);

        // Check for error
        if (lpPrimProtoRht EQ NULL)
            goto RIGHT_NONCE_EXIT;

        // Reshape the left arg item to an empty vector
        lpYYResL =
          PrimFnDydRho_EM_YY (&tkLft,           // Ptr to left arg token
                              &tkFcn,           // Ptr to function token
                               lptkLftArg,      // Ptr to right arg token
                               NULL);           // Ptr to axis token (may be NULL)
        // Check for error
        if (lpYYResL EQ NULL)
            goto ERROR_EXIT;

        // Reshape the right arg item to an empty vector
        lpYYResR =
          PrimFnDydRho_EM_YY (&tkLft,           // Ptr to left arg token
                              &tkFcn,           // Ptr to function token
                               lptkRhtArg,      // Ptr to right arg token
                               NULL);           // Ptr to axis token (may be NULL)
        // Check for error
        if (lpYYResR EQ NULL)
            goto ERROR_EXIT;

        // Setup a token with the {take} function
////////tkFcn.tkFlags.TknType   = TKT_FCNIMMED;         // Already set above
////////tkFcn.tkFlags.ImmType   = IMMTYPE_PRIMFCN;      // Already set above
////////tkFcn.tkFlags.NoDisplay = FALSE;                // Already zero from = {0}
        tkFcn.tkData.tkChar     = UTF16_UPARROW;
////////tkFcn.tkCharIndex       = lpYYFcnStrLft->tkToken.tkCharIndex;

        // Execute monadic UpArrow on the last two results to extract the first item
        lpYYResL2 =
          PrimFnMonUpArrow_EM_YY (&tkFcn,               // Ptr to function token
                                  &lpYYResL->tkToken,   // Ptr to right arg token
                                   NULL);               // Ptr to axis token (may be NULL)
        // Check for error
        if (lpYYResL2 EQ NULL)
            goto ERROR_EXIT;

        // Execute monadic UpArrow on the last two results to extract the first item
        lpYYResR2 =
          PrimFnMonUpArrow_EM_YY (&tkFcn,               // Ptr to function token
                                  &lpYYResR->tkToken,   // Ptr to right arg token
                                   NULL);               // Ptr to axis token (may be NULL)
        // Check for error
        if (lpYYResR2 EQ NULL)
            goto ERROR_EXIT;

        // Execute the right operand between the left and right args

        // Note that we cast the function strand to LPTOKEN
        //   to bridge the two types of calls -- one to a primitive
        //   function which takes a function token, and one to a
        //   primitive operator which takes a function strand
        lpYYRes2 =
          (*lpPrimProtoRht) (&lpYYResL2->tkToken,   // Ptr to left arg token (may be NULL)
                    (LPTOKEN) lpYYFcnStrRht,        // Ptr to left operand function strand
                             &lpYYResR2->tkToken,   // Ptr to right arg token
                              lptkAxisRht);         // Ptr to axis token (may be NULL)
    } else
    {
        // Setup a token with the {take} function
        tkFcn.tkFlags.TknType   = TKT_FCNIMMED;         // Already set above
        tkFcn.tkFlags.ImmType   = IMMTYPE_PRIMFCN;      // Already set above
////////tkFcn.tkFlags.NoDisplay = FALSE;                // Already zero from = {0}
        tkFcn.tkData.tkChar     = UTF16_UPARROW;
        tkFcn.tkCharIndex       = lpYYFcnStrLft->tkToken.tkCharIndex;

        // Execute monadic UpArrow on the right arg to extract the first item
        lpYYRes2 =
          PrimFnMonUpArrow_EM_YY (&tkFcn,               // Ptr to function token
                                   lptkRhtArg,          // Ptr to right arg token
                                   NULL);               // Ptr to axis token (may be NULL)
    } // End IF/ELSE

    // Check for error
    if (lpYYRes2 EQ NULL)
        goto ERROR_EXIT;

    // Copy the result as the new right arg token
    lptkRhtArg = &lpYYRes2->tkToken;

    // Execute the left operand identity function on the right arg

    // Check for left operand axis operator
    lptkAxisLft = CheckAxisOper (lpYYFcnStrLft);

    // Get the appropriate identity function ptr
    lpPrimFlagsLft = GetPrimFlagsPtr (&lpYYFcnStrLft->tkToken);

    // Check for error
    if (lpPrimFlagsLft EQ NULL || lpPrimFlagsLft->lpPrimOps EQ NULL)
        goto LEFT_NONCE_EXIT;

    lpYYRes =
      (*lpPrimFlagsLft->lpPrimOps)
                        (lptkRhtArg,            // Ptr to original right arg token
                         lpYYFcnStrLft,         // Ptr to operator or function strand
                         lptkRhtArg,            // Ptr to right arg token
                         lptkAxisLft);          // Ptr to axis token (may be NULL)
    // Check for error
    if (lpYYRes EQ NULL)
        goto ERROR_EXIT;

    // Is the token immediate?
    if (IsTknImmed (&lpYYRes->tkToken))
    {
        // Copy the LPSYMENTRY as the result
        hGlbSym.lpSym =
          MakeSymEntry_EM (lpYYRes->tkToken.tkFlags.ImmType,    // ImmType to use (see IMM_TYPES)
                          &lpYYRes->tkToken.tkData.tkLongest,   // Ptr to value to use
                          &lpYYFcnStrLft->tkToken);             // Ptr to token to use in case of error
        // Check for error
        if (hGlbSym.lpSym EQ NULL)
            goto ERROR_EXIT;
    } else
        // Copy the HGLOBAL as the result
        hGlbSym.hGlb = CopySymGlbDir_PTB (lpYYRes->tkToken.tkData.tkGlbData);

    goto NORMAL_EXIT;

LEFT_NONCE_EXIT:
    ErrorMessageIndirectToken (ERRMSG_NONCE_ERROR APPEND_NAME,
                              &lpYYFcnStrLft->tkToken);
    goto ERROR_EXIT;

RIGHT_NONCE_EXIT:
    ErrorMessageIndirectToken (ERRMSG_NONCE_ERROR APPEND_NAME,
                              &lpYYFcnStrRht->tkToken);
    goto ERROR_EXIT;

ERROR_EXIT:
NORMAL_EXIT:
    if (lpYYRes)
    {
        FreeResult (lpYYRes);  YYFree (lpYYRes);  lpYYRes  = NULL;
    } // End IF

    if (lpYYRes2)
    {
        FreeResult (lpYYRes2); YYFree (lpYYRes2); lpYYRes2 = NULL;
    } // End IF

    if (lpYYResL)
    {
        FreeResult (lpYYResL); YYFree (lpYYResL); lpYYResL = NULL;
    } // End IF

    if (lpYYResL2)
    {
        FreeResult (lpYYResL2); YYFree (lpYYResL2); lpYYResL2 = NULL;
    } // End IF

    if (lpYYResR)
    {
        FreeResult (lpYYResR); YYFree (lpYYResR); lpYYResR = NULL;
    } // End IF

    if (lpYYResR2)
    {
        FreeResult (lpYYResR2); YYFree (lpYYResR2); lpYYResR2 = NULL;
    } // End IF

    return hGlbSym;
} // End GetIdentityElement_EM
Ejemplo n.º 3
0
LPPL_YYSTYPE PrimOpDieresisJotCommon_EM_YY
    (LPTOKEN      lptkLftArg,           // Ptr to left arg token (may be NULL if monadic derived function)
     LPPL_YYSTYPE lpYYFcnStrLft,        // Ptr to left operand function strand
     LPPL_YYSTYPE lpYYFcnStrOpr,        // Ptr to operator function strand
     LPPL_YYSTYPE lpYYFcnStrRht,        // Ptr to right operand function strand
     LPTOKEN      lptkRhtArg,           // Ptr to right arg token (may be NULL if niladic)
     UBOOL        bPrototyping)         // TRUE iff protoyping

{
    HGLOBAL       hGlbMFO1,             // Magic function/operator #1 global memory handle
                  hGlbMFO2,             // Magic function/operator #2 global memory handle
                  hGlbOprRht;           // Right operand global memory handle
    LPPERTABDATA  lpMemPTD;             // Ptr to PerTabData global memory
    LPPL_YYSTYPE  lpYYRes = NULL;       // Ptr to result
    LPTOKEN       lptkAxisOpr;          // Ptr to axis token
    LPPLLOCALVARS lpplLocalVars;        // Ptr to re-entrant vars
    LPUBOOL       lpbCtrlBreak;         // Ptr to Ctrl-Break flag

    // Get the thread's ptr to local vars
    lpplLocalVars = TlsGetValue (dwTlsPlLocalVars);

    // Get the ptr to the Ctrl-Break flag
    lpbCtrlBreak = &lpplLocalVars->bCtrlBreak;

    // Check for axis operator
    lptkAxisOpr = CheckAxisOper (lpYYFcnStrOpr);

    // Ensure the left operand is a function
    if (!IsTknFcnOpr (&lpYYFcnStrLft->tkToken)
     || IsTknFillJot (&lpYYFcnStrLft->tkToken))
        goto LEFT_OPERAND_SYNTAX_EXIT;

    // Ensure the right operand is a variable
    if (IsTknFcnOpr (&lpYYFcnStrRht->tkToken)
     || IsTknFillJot (&lpYYFcnStrRht->tkToken))
        goto RIGHT_OPERAND_SYNTAX_EXIT;

    // Get ptr to PerTabData global memory
    lpMemPTD = GetMemPTD ();

    // Get the magic function/operator global memory handles
    hGlbMFO1 = (lptkLftArg EQ NULL) ? lpMemPTD->hGlbMFO[MFOE_MonRank]
                                    : lpMemPTD->hGlbMFO[MFOE_DydRank];
    hGlbMFO2 = lpMemPTD->hGlbMFO[MFOE_Conform];

    // Get right operand global ptrs
    hGlbOprRht = GetGlbHandle (&lpYYFcnStrRht->tkToken);

    // If the right operand is not immediate, ...
    if (hGlbOprRht NE NULL)
    {
        APLSTYPE aplTypeOprRht;             // Right operand storage type
        APLNELM  aplNELMOprRht;             // Right operand NELM
        APLRANK  aplRankOprRht;             // Right operand rank

        // Get the attributes (Type, NELM, and Rank)
        //   of the right arg token
        AttrsOfGlb (hGlbOprRht, &aplTypeOprRht, &aplNELMOprRht, &aplRankOprRht, NULL);

        // Check for RIGHT OPERAND RANK ERROR
        if (1 < aplRankOprRht)
            goto RIGHT_OPERAND_RANK_EXIT;

        // Check for RIGHT OPERAND LENGTH ERROR
        if (1 > aplNELMOprRht
         ||     aplNELMOprRht > 3)
            goto RIGHT_OPERAND_LENGTH_EXIT;

        // Check for RIGHT OPERAND DOMAIN ERROR
        if (!IsNumeric (aplTypeOprRht))
            goto RIGHT_OPERAND_DOMAIN_EXIT;
    } else
    // Check for RIGHT OPERAND DOMAIN ERROR
    if (!IsImmNum (lpYYFcnStrRht->tkToken.tkFlags.ImmType))
        goto RIGHT_OPERAND_DOMAIN_EXIT;

    lpYYRes =
      ExecuteMagicOperator_EM_YY (lptkLftArg,               // Ptr to left arg token (may be NULL if monadic/niladic)
                                 &lpYYFcnStrOpr->tkToken,   // Ptr to function token
                                  lpYYFcnStrLft,            // Ptr to left operand function strand
                                  lpYYFcnStrOpr,            // Ptr to function strand
                                  lpYYFcnStrRht,            // Ptr to right operand function strand (may be NULL)
                                  lptkRhtArg,               // Ptr to right arg token (may be NULL if niladic)
                                  NULL,                     // Ptr to axis token
                                  hGlbMFO1,                 // Magic function/operator global memory handle
                                  NULL,                     // Ptr to HSHTAB struc (may be NULL)
                                  bPrototyping
                                ? LINENUM_PRO
                                : LINENUM_ONE);             // Starting line # type (see LINE_NUMS)
    // If the result is valid, finish the process with Conforming Disclose
    if (lpYYRes NE NULL && !IsTknImmed (&lpYYRes->tkToken))
    {
        HGLOBAL     hGlbRes;                // Result global memory handle
        LPAPLNESTED lpMemRes;               // Ptr to result global memory
        APLSTYPE    aplTypeRes;             // Result storage type
        APLNELM     aplNELMRes;             // Result NELM
        APLRANK     aplRankRes;             // Result rank

        // Get result global ptrs
        hGlbRes = GetGlbHandle (&lpYYRes->tkToken);

        // Get the attributes (Type, NELM, and Rank)
        //   of the result global
        AttrsOfGlb (hGlbRes, &aplTypeRes, &aplNELMRes, &aplRankRes, NULL);

        // If the result is nested, ...
        if (IsNested (aplTypeRes))
        {
            APLRANK      uMinRank,          // Minimum rank across all items
                         uMaxRank;          // maximum ...
            APLUINT      uRes;              // Loop counter
            APLRANK      aplRankItm;        // Result item rank
            LPPL_YYSTYPE lpYYRes2;          // Secondary result

            // Lock the memory to get a ptr to it
            lpMemRes = MyGlobalLockVar (hGlbRes);

            // Skip over the header to the data
            lpMemRes = VarArrayDataFmBase (lpMemRes);

            // Initialize minimum & maximum ranks
            uMinRank = NEG1A;
            uMaxRank = 0;

            // In case it's empty, we need to process the prototype
            aplNELMRes = max (aplNELMRes, 1);

            // Loop through the result looking for the minimum/maximum rank items
            for (uRes = 0; uRes < aplNELMRes; uRes++)
            {
                // Check for Ctrl-Break
                if (CheckCtrlBreak (*lpbCtrlBreak))
                    goto ERROR_EXIT;

                // Split cases based the item ptr type
                switch (GetPtrTypeDir (lpMemRes[uRes]))
                {
                    case PTRTYPE_STCONST:
                        // Get the minimum rank
                        uMinRank = min (uMinRank, 0);

                        break;

                    case PTRTYPE_HGLOBAL:
                        // Get the attributes (Type, NELM, and Rank)
                        //   of the result global item
                        AttrsOfGlb (lpMemRes[uRes], NULL, NULL, &aplRankItm, NULL);

                        // Get the minimum rank
                        uMinRank = min (uMinRank, aplRankItm);

                        // Get the maximum rank
                        uMaxRank = max (uMaxRank, aplRankItm);

                        break;

                    defstop
                        break;
                } // End SWITCH
            } // End FOR

            // We no longer need this ptr
            MyGlobalUnlock (hGlbRes); lpMemRes = NULL;

            // If the two ranks are unequal, ...
            if (uMinRank NE uMaxRank)
            {
                TOKEN tkLftArg = {0};   // Left arg token

                // Fill in the left arg token
                tkLftArg.tkFlags.TknType   = TKT_VARIMMED;
                tkLftArg.tkFlags.ImmType   = IMMTYPE_INT;
////////////////tkLftArg.tkFlags.NoDisplay = FALSE; // Already zero from = {0}
                tkLftArg.tkData.tkInteger  = uMaxRank;
////////////////tkLftArg.tkCharIndex       = 0;     // Already zero from = {0}
#ifdef DEBUG
                // Decrement the SI level of lpYYRes so YYResIsEmpty won't complain
                lpYYRes->SILevel--;
#endif
                // Finish it off with another magic function/operator
                lpYYRes2 =
                  ExecuteMagicFunction_EM_YY (&tkLftArg,                // Ptr to left arg token
                                              &lpYYFcnStrOpr->tkToken,  // Ptr to function token
                                               NULL,                    // Ptr to function strand
                                              &lpYYRes->tkToken,        // Ptr to right arg token
                                               NULL,                    // Ptr to axis token
                                               hGlbMFO2,                // Magic function/operator global memory handle
                                               NULL,                    // Ptr to HSHTAB struc (may be NULL)
                                               LINENUM_ONE);            // Starting line # type (see LINE_NUMS)
#ifdef DEBUG
                // Restore the SI level of lpYYRes
                lpYYRes->SILevel++;
#endif
                // Free the first YYRes
                FreeResult (lpYYRes); YYFree (lpYYRes); lpYYRes = NULL;

                // Copy secondary result as primary result
                lpYYRes = lpYYRes2; lpYYRes2 = NULL;
            } // End IF

            // Just disclose the argument
            lpYYRes2 =
              PrimFnMonRightShoe_EM_YY (&lpYYFcnStrOpr->tkToken,    // Ptr to function token
                                        &lpYYRes->tkToken,          // Ptr to right arg token
                                         lptkAxisOpr);              // Ptr to axis token
            // Free the first YYRes
            FreeResult (lpYYRes); YYFree (lpYYRes); lpYYRes = NULL;

            // Copy secondary result as primary result
            lpYYRes = lpYYRes2;
        } // End IF
    } // End IF
Ejemplo n.º 4
0
LPPL_YYSTYPE PrimFnMonCircleSlope_EM_YY
    (LPTOKEN lptkFunc,              // Ptr to function token
     LPTOKEN lptkRhtArg,            // Ptr to right arg token
     LPTOKEN lptkAxis)              // Ptr to axis token (may be NULL)

{
    APLSTYPE     aplTypeRht;    // Right arg storage type
    APLNELM      aplNELMRht;    // ...       NELM
    APLRANK      aplRankRht;    // ...       rank
    HGLOBAL      hGlbLft;       // Left arg global memory handle
    LPVOID       lpMemLft;      // Ptr to left arg global memory
    LPPL_YYSTYPE lpYYRes,       // Ptr to the result
                 lpYYRes2;      // Ptr to secondary result
    APLUINT      ByteRes;       // # bytes in the result
    APLBOOL      bQuadIO;       // []IO

    // Get the current value of []IO
    bQuadIO = GetQuadIO ();

    //***************************************************************
    // This function is not sensitive to the axis operator,
    //   so signal a syntax error if present
    //***************************************************************

    if (lptkAxis NE NULL)
        goto AXIS_SYNTAX_EXIT;

    // Get the attributes (Type, NELM, and Rank) of the right arg
    AttrsOfToken (lptkRhtArg, &aplTypeRht, &aplNELMRht, &aplRankRht, NULL);

    // Calculate space needed for the left arg
    ByteRes = CalcArraySize (ARRAY_APA, aplRankRht, 1);

    // Check for overflow
    if (ByteRes NE (APLU3264) ByteRes)
        goto WSFULL_EXIT;

    // Allocate storage for the left argument
    hGlbLft = DbgGlobalAlloc (GHND, (APLU3264) ByteRes);
    if (hGlbLft EQ NULL)
        goto WSFULL_EXIT;

    // Lock the memory to get a ptr to it
    lpMemLft = MyGlobalLock000 (hGlbLft);

#define lpHeader    ((LPVARARRAY_HEADER) lpMemLft)
    // Fill in the header values
    lpHeader->Sig.nature = VARARRAY_HEADER_SIGNATURE;
    lpHeader->ArrType    = ARRAY_APA;
////lpHeader->PermNdx    = PERMNDX_NONE;// Already zero from GHND
////lpHeader->SysVar     = FALSE;       // Already zero from GHND
    lpHeader->RefCnt     = 1;
    lpHeader->NELM       = aplRankRht;
    lpHeader->Rank       = 1;
#undef  lpHeader

    // Fill in the dimension
    *VarArrayBaseToDim (lpMemLft) = aplRankRht;

    // Skip over the header and dimensions to the data
    lpMemLft = VarArrayDataFmBase (lpMemLft);

    // Fill in the APA parameters
#define lpAPA       ((LPAPLAPA) lpMemLft)
    lpAPA->Off = (aplRankRht - 1) + bQuadIO;
    lpAPA->Mul = -1;
#undef  lpAPA
    // We no longer need this ptr
    MyGlobalUnlock (hGlbLft); lpMemLft = NULL;

    // Allocate a new YYRes
    lpYYRes = YYAlloc ();

    // Fill in the left arg token
    lpYYRes->tkToken.tkFlags.TknType   = TKT_VARARRAY;
////lpYYRes->tkToken.tkFlags.ImmType   = IMMTYPE_ERROR; // Already zero from YYAlloc
////lpYYRes->tkToken.tkFlags.NoDisplay = FALSE;         // Already zero from YYAlloc
    lpYYRes->tkToken.tkData.tkGlbData  = MakePtrTypeGlb (hGlbLft);
    lpYYRes->tkToken.tkCharIndex       = lptkFunc->tkCharIndex;

    // Call the dyadic function
    lpYYRes2 = PrimFnDydCircleSlope_EM_YY (&lpYYRes->tkToken,   // Ptr to left arg token
                                            lptkFunc,           // Ptr to function token
                                            lptkRhtArg,         // Ptr to right arg token
                                            lptkAxis);          // Ptr to axis token (may be NULL)
    // We no longer need this storage
    FreeResult (lpYYRes); YYFree (lpYYRes); lpYYRes = NULL;

    return lpYYRes2;

AXIS_SYNTAX_EXIT:
    ErrorMessageIndirectToken (ERRMSG_SYNTAX_ERROR APPEND_NAME,
                               lptkAxis);
    return NULL;

WSFULL_EXIT:
    ErrorMessageIndirectToken (ERRMSG_WS_FULL APPEND_NAME,
                               lptkFunc);
    return NULL;
} // End PrimFnMonCircleSlope_EM_YY