Exemple #1
0
CMainFrame::~CMainFrame()
{
	KillTimer(mytimer);
	
	DataReset();
	ListReset();
	OnSavesettings();
}
Exemple #2
0
void DelayCamac(USHORT delay)
{
	CMCPforNTApp* pApp = (CMCPforNTApp*)AfxGetApp();
	while (!GPIBReady()||!ListReady());
	ListReset();
	DataReset();

	SendFCamac(41);
	SendFCamac(32);
	
	SendFCamac(64+pApp->PresetSlot);
	EnableLAMTimer(pApp->PresetSlot);
	
	ListDelayCamac(pApp->PresetSlot,delay);
	ListStart();
	while (!ListReady());
}
Exemple #3
0
// -------------------------------------------------------------------------------------------------
static bool ProcessCommand
(
    const char* textPtr,      ///< [IN] Check this text to see if it's a valid command.
    const char* requesterPtr  ///< [IN] If not NULL, then any response text is SMSed to this target.
)
{
    char buffer[10240];

    // Start looking for a match...
    if (strcmp(textPtr, "Crash") == 0)
    {
        // As the name implies, we are going to be crashing the application.  So simply append to
        // the output log and crash the app.  This is done to allow demonstration of the supervisor
        // policies.
        int x = 10;
        int y = 0;

        LE_ERROR("Something wicked this way comes...");
        LE_ERROR("Data result: %d", x / y);
    }
    else if (strcmp(textPtr, "Status") == 0)
    {
        // The status command allows the caller to query the current state of the modem.  A friendly
        // version of this status is constructed and returned to the caller.
        le_onoff_t radioStatus;
        const char * radioStatusPtr;
        le_mrc_NetRegState_t netRegState;
        uint32_t signalQuality;

        if(le_mrc_GetRadioPower(&radioStatus) != LE_OK)
        {
            radioStatusPtr = "in an unknown state";
        }
        else
        {
            radioStatusPtr = (radioStatus == LE_OFF) ? "off" : "on";
        }

        if(le_mrc_GetNetRegState(&netRegState) != LE_OK)
        {
            netRegState = LE_MRC_REG_UNKNOWN;
        }

        if(le_mrc_GetSignalQual(&signalQuality) != LE_OK)
        {
            signalQuality = 0;
        }

        sprintf(buffer, "The radio is %s and is %s. The signal strength is %s.",
                radioStatusPtr,
                GetNetStateString(netRegState),
                GetSignalString(signalQuality));
    }
    else if (strcmp(textPtr, "Sim") == 0)
    {
        // Like the status command, this command queries the underling hardware for information.
        // This information is turned into a string that can then be returned to the caller.
        le_sim_Id_t simId;
        le_sim_States_t simState;

        char iccid[100];
        char imsi[100];
        int pos = 0;

        simId = le_sim_GetSelectedCard();
        simState = le_sim_GetState(simId);

        pos += snprintf(buffer + pos, sizeof(buffer) - pos,
                "SIM %u is %s.",
                simId,
                GetSimStateString(simState));

        if(le_sim_GetICCID(simId, iccid, sizeof(iccid)) == LE_OK)
        {
            pos += snprintf(buffer + pos, sizeof(buffer) - pos,
                    " ICCID=%s", iccid);
        }

        if(le_sim_GetIMSI(simId, imsi, sizeof(imsi)) == LE_OK)
        {
            pos += snprintf(buffer + pos, sizeof(buffer) - pos,
                    " IMSI=%s", imsi);
        }

    }
    else if (strcmp(textPtr, "Online") == 0)
    {
        le_utf8_Copy(buffer, "Requesting data connection.", sizeof(buffer), NULL);
        GoOnline();
    }
    else if (strcmp(textPtr, "Offline") == 0)
    {
        le_utf8_Copy(buffer, "Releasing data connection.", sizeof(buffer), NULL);
        GoOffline(buffer);
    }
    else if (strcmp(textPtr, "TestDataConnectionV4") == 0)
    {
        TestDataConnectionV4(buffer);
    }
    else if (strcmp(textPtr, "TestDataConnectionV6") == 0)
    {
        TestDataConnectionV6(buffer);
    }
    else if (strcmp(textPtr, "Netinfo") == 0)
    {
        Netinfo(buffer);
    }
    else if (strcmp(textPtr, "DataInfo") == 0)
    {
        Datainfo(buffer);
    }
    else if (strcmp(textPtr, "DataReset") == 0)
    {
        DataReset(buffer);
    }
    else if (strcmp(textPtr, "Scan") == 0)
    {
        PerformScan(buffer, sizeof(buffer), requesterPtr);
    }
    else
    {
        return false;
    }

    // Check to see if any processing has occurred.  If so, check to see if the request came from a
    // local or remote requester.
    // If the requester was local, (requesterPtr == NULL) then simply log our response to the SMS log.
    // Otherwise, attempt to SMS the response string to the original caller.
    if (requesterPtr != NULL)
    {
        SendMessage(requesterPtr, buffer);
    }
    else if (OutputFilePtr != NULL)
    {
        fprintf(OutputFilePtr, "## %s ##\n", buffer);
        fflush(OutputFilePtr);
    }

    // Let the calling function know if we did any processing or not.
    return true;
}
Exemple #4
0
CString SendReadGPIB(CString Command,int Address,int CamacSlot)
{
	char TheCommand[255];
	char TheAnswer[255];
	CString Answer = "Not successful";
	USHORT length;
	ULONG i;

	strcpy(TheCommand,Command);

	CMCPforNTApp* pMyApp = (CMCPforNTApp*)AfxGetApp();
	if(!pMyApp->GlobalMeasurementRunning&&pMyApp->CamacOn)
	{
		while (!GPIBReady()||!ListReady());
		ListReset();
		DataReset();

		ListDNAFCamac(SENDNAF,0,CamacSlot,0,26);
		ListDNAFCamac(SENDNAF,0,CamacSlot,1,26);
		ListDNAFCamac(SENDNAF,0,CamacSlot,4,26);

		ListDNAFCamac(SENDDNAF,8,CamacSlot,13,17);	// Write LAM-Mask

		ListDNAFCamac(SENDF,0,0,0,32);				// Disable Inhibit


		ListDNAFCamac(SENDF,0,0,0,64+CamacSlot);	// Enable Interrupt from #CamacSlot

		ListDNAFCamac(SENDF,0,0,0,41);				// Enable Interrupts

		ListDNAFCamac(SENDDNAF,32+Address,CamacSlot,0,16);
		ListDNAFCamac(WAITINT | READENCL,0,0,0,0);

		ListDNAFCamac(SENDDNAF,64+21,CamacSlot,0,16);
		ListDNAFCamac(WAITINT | READENCL,0,0,0,0);

		ListDNAFCamac(SENDNAF,0,CamacSlot,0,24);

		for (i=0;i<strlen(TheCommand);i++)
		{
			ListDNAFCamac(SENDDNAF,TheCommand[i],CamacSlot,0,16);
			ListDNAFCamac(WAITINT | READENCL,0,0,0,0);
		}


		ListDNAFCamac(SENDDNAF,13,CamacSlot,0,16);			// CR
		ListDNAFCamac(WAITINT | READENCL,0,0,0,0);

		ListDNAFCamac(SENDDNAF,10,CamacSlot,0,16);			// LF
		ListDNAFCamac(WAITINT | READENCL,0,0,0,0);


		/*************** Now listen to the device *****************/

		ListDNAFCamac(SENDNAF,0,CamacSlot,0,26);

		ListDNAFCamac(SENDDNAF,64+Address,CamacSlot,0,16);	// Device talks
		ListDNAFCamac(WAITINT | READENCL,0,0,0,0);

		ListDNAFCamac(SENDDNAF,32+21,CamacSlot,0,16);		// 3388 is listening
		ListDNAFCamac(WAITINT | READENCL,0,0,0,0);

		

		// this is new and hopefully works
		ListDNAFCamac(SENDDNAF,128,CamacSlot,13,17);		// Write LAM-Mask
		ListDNAFCamac(SENDNAF,0,CamacSlot,0,24);
		ListDNAFCamac(READGPIB,0,CamacSlot,0,0);		

		ListDNAFCamac(SENDDNAF,8,CamacSlot,13,17);			// Write LAM-Mask
	
		ListDNAFCamac(SENDNAF,0,CamacSlot,0,26);

		ListDNAFCamac(SENDDNAF,32+Address,CamacSlot,0,16);
		ListDNAFCamac(WAITINT | READENCL,0,0,0,0);

		ListDNAFCamac(SENDDNAF,64+21,CamacSlot,0,16);
		ListDNAFCamac(WAITINT | READENCL,0,0,0,0);

		
		ListDNAFCamac(SENDDNAF,UNL,CamacSlot,0,16);			// UNLISTEN
		ListDNAFCamac(WAITINT | READENCL,0,0,0,0);

		ListDNAFCamac(SENDDNAF,UNT,CamacSlot,0,16);			// UNTALK
		ListDNAFCamac(WAITINT | READENCL,0,0,0,0);

		ListDNAFCamac(SENDNAF,0,CamacSlot,0,24);
		ListDNAFCamac(SENDDNAF,0,CamacSlot,13,17);
		ListDNAFCamac(READENCL,0,0,0,0);
		

		ListStart();

		i=0;
		do i++;
		while (!GPIBReady()&&i<100000);
		if(i<100000)
		{
			ListReadS(&TheAnswer[0],&length);
			if(strlen(TheAnswer)>25)
			{
				strcpy(TheCommand,TheAnswer);
				strcpy(TheAnswer+1,TheCommand);
				strncpy(TheAnswer+25,"\n",1);
				strncpy(TheAnswer,TheCommand,25);
			}
			Answer = TheAnswer;
		}
		else 
		{
			Answer = "No answer";
		}

		ListReset();
		DataReset();
		return Answer;
	}
	return "Device busy";
}
Exemple #5
0
BOOL SendGPIB(CString Command,int Address,int CamacSlot)
{
	char TheCommand[255];
	USHORT i;
	CMCPforNTApp* pMyApp = (CMCPforNTApp*)AfxGetApp();
	if(!pMyApp->GlobalMeasurementRunning&&pMyApp->CamacOn)
	{
		strcpy(TheCommand,Command);
		while (!GPIBReady()||!ListReady());
		ListReset();
		DataReset();
		
		ListDNAFCamac(SENDNAF,0,CamacSlot,0,26);
		ListDNAFCamac(SENDNAF,0,CamacSlot,1,26);
		ListDNAFCamac(SENDNAF,0,CamacSlot,4,26);

		ListDNAFCamac(SENDDNAF,8,CamacSlot,13,17);	// Write LAM-Mask

		ListDNAFCamac(SENDF,0,0,0,32);				// Disable Inhibit


		ListDNAFCamac(SENDF,0,0,0,64+CamacSlot);	// Enable Interrupt from #CamacSlot

		ListDNAFCamac(SENDF,0,0,0,41);				// Enable Interrupts

		ListDNAFCamac(SENDDNAF,32+Address,CamacSlot,0,16);
		ListDNAFCamac(WAITINT | READENCL,0,0,0,0);

		ListDNAFCamac(SENDDNAF,64+21,CamacSlot,0,16);
		ListDNAFCamac(WAITINT | READENCL,0,0,0,0);

		ListDNAFCamac(SENDNAF,0,CamacSlot,0,24);

		for (i=0;i<strlen(TheCommand);i++)
		{
			ListDNAFCamac(SENDDNAF,TheCommand[i],CamacSlot,0,16);
			ListDNAFCamac(WAITINT | READENCL,0,0,0,0);
		}


		ListDNAFCamac(SENDDNAF,13,CamacSlot,0,16);			// CR
		ListDNAFCamac(WAITINT | READENCL,0,0,0,0);

		ListDNAFCamac(SENDDNAF,10,CamacSlot,0,16);			// LF
		ListDNAFCamac(WAITINT | READENCL,0,0,0,0);

		ListDNAFCamac(SENDNAF,0,CamacSlot,0,26);

		ListDNAFCamac(SENDDNAF,UNL,CamacSlot,0,16);			// UNLISTEN
		ListDNAFCamac(WAITINT | READENCL,0,0,0,0);

		ListDNAFCamac(SENDDNAF,UNT,CamacSlot,0,16);			// UNTALK
		ListDNAFCamac(WAITINT | READENCL,0,0,0,0);

		ListDNAFCamac(SENDNAF,0,CamacSlot,0,24);

		ListDNAFCamac(SENDDNAF,0,CamacSlot,13,17);			// Write LAM-Mask (disable all)
		ListDNAFCamac(SENDF,0,0,0,40);						// Disable Interrupts

		ListStart();
		while (!GPIBReady()||!ListReady());
		ListReset();
		DataReset();
		return TRUE;
	}
	return FALSE;
}