예제 #1
0
int Controller::OnTrigger(MM::PropertyBase* pProp, MM::ActionType eAct)
{

   if (eAct == MM::BeforeGet)
   {
      pProp->Set(trigger_.c_str());
   }
   else if (eAct == MM::AfterSet)
   {
      char cmd=0;
      pProp->Get(trigger_);
      for (int i=0;i<5;i++)
      {
         if (trigger_.compare(TriggerLabels[i])==0)
         {
            cmd = TriggerCmd[i];
            triggerMode_ = (TriggerType) i;
         }
      }
      
      SetTrigger();

   }
   return HandleErrors();
}
예제 #2
0
// ON for deltaT milliseconds
// other implementations of Shutter don't implement this
// is this perhaps because this blocking call is not appropriate
int Sapphire::Fire(double deltaT)
{
	SetOpen(true);
	CDeviceUtils::SleepMs((long)(deltaT+.5));
	SetOpen(false);
   return HandleErrors();
}
예제 #3
0
status_t
NFS4Object::ConfirmOpen(const FileHandle& fh, OpenState* state,
	uint32* sequence)
{
	ASSERT(state != NULL);
	ASSERT(sequence != NULL);

	do {
		RPC::Server* serv = fFileSystem->Server();
		Request request(serv, fFileSystem);

		RequestBuilder& req = request.Builder();

		req.PutFH(fh);
		req.OpenConfirm(*sequence, state->fStateID, state->fStateSeq);

		status_t result = request.Send();
		if (result != B_OK)
			return result;

		ReplyInterpreter& reply = request.Reply();

		*sequence += IncrementSequence(reply.NFS4Error());

		if (HandleErrors(reply.NFS4Error(), serv, NULL, state))
			continue;

		reply.PutFH();
		result = reply.OpenConfirm(&state->fStateSeq);
		if (result != B_OK)
			return result;

		return B_OK;
	} while (true);
}
예제 #4
0
int Controller::OnChannelWave(MM::PropertyBase* pProp, MM::ActionType eAct, long channel)
{
	string wavelength;

	if (eAct == MM::BeforeGet && waveUpdated_[channel]) {
		pProp->Set(channelWave_[channel].c_str());
		waveUpdated_[channel] = false;
	}
	else if (eAct == MM::AfterSet)
	{
		pProp->Get(wavelength);
		//LOAD:<wavelength> loads that particular wavelength in the channel
		stringstream msg;
		msg << "LOAD:" << wavelength;

		MMThreadGuard myLock(lock_);
		Purge();
		Send(msg.str());
		do {
			ReceiveOneLine();
		} while (buf_string_.size() == 0);
	}

	return HandleErrors();
}
예제 #5
0
//=--------------------------------------------------------------------------=
// CImp_DrawDlg::SendMouseMovement
//=--------------------------------------------------------------------------=
// Purpose: This function sends my mouse movement information to the m_qFriend queue.
//  
//
// Parameters:
//    LINE		-	a custom type defined in Drawarea.h
//
// Output:
//    none
//
// Notes:
//    This function encodes line data into a string and passes that string
//    as the body of an MSMQ message. This function is called by the 
//	  CDrawArea class, which was ported from the MSMQ C_Draw sample.
// 
void CImp_DrawDlg::SendMouseMovement(LINE line)
{
	try
	{
		if (m_qFriend != NULL && m_qFriend->IsOpen)
		{
			m_msgOut->Priority = 3;

			/* Pack the data into one line (twice). */
			WCHAR wcsBody[MAX_MSG_BODY_LEN+1];
			swprintf_s(wcsBody, sizeof(wcsBody)/sizeof(wcsBody[0]), L"%07ld%07ld%07ld%07ld", 
					 line.ptStart.x, line.ptStart.y, line.ptEnd.x, line.ptEnd.y);

			WCHAR wcsLabel[MQ_MAX_MSG_LABEL_LEN+1];
			swprintf_s(wcsLabel, sizeof(wcsLabel)/sizeof(wcsLabel[0]), L"%07ld,%07ld To %07ld,%07ld", 
					 line.ptStart.x, line.ptStart.y, line.ptEnd.x, line.ptEnd.y);

			/* Initialize a variant with the wcsbody data. */
			_variant_t	vtBody(wcsBody);
			
			// Setup the message properties.
			m_msgOut->Body = vtBody;
			m_msgOut->Label = wcsLabel;
			m_msgOut->Delivery = m_iRadio;

			// Send the message.
			m_msgOut->Send(m_qFriend);
		};
	}
	catch(_com_error &comerr)
	{
		HandleErrors(comerr);
	};
};
예제 #6
0
int Controller::Initialize()
{

   // set property list
   // -----------------
   /*
   MM::Device* serialDevice = GetCoreCallback()->GetDevice(this, port_.c_str());
   if (serialDevice == NULL) {
      LogMessage("Serial port not found");
      return DEVICE_SERIAL_COMMAND_FAILED;
   }
*/
   this->LogMessage("Controller::Initialize()");

   currentChannel_ = 0;

   ReadGreeting();
   int result = ReadChannelLabels();
   if (result != DEVICE_OK)
	   return result;

   GenerateChannelChooser();
   GeneratePropertyIntensity();
   GeneratePropertyState();
   GeneratePropertyTrigger();
   GeneratePropertyTriggerSequence();
   
   initialized_ = true;
   return HandleErrors();

}
예제 #7
0
bool
RootInode::ProbeMigration()
{
	do {
		RPC::Server* server = fFileSystem->Server();
		Request request(server, fFileSystem);
		RequestBuilder& req = request.Builder();

		req.PutFH(fInfo.fHandle);
		req.Access();

		status_t result = request.Send();
		if (result != B_OK)
			continue;

		ReplyInterpreter& reply = request.Reply();

		if (reply.NFS4Error() == NFS4ERR_MOVED)
			return true;

		if (HandleErrors(reply.NFS4Error(), server))
			continue;

		return false;
	} while (true);
}
예제 #8
0
status_t
Delegation::ReturnDelegation()
{
	do {
		RPC::Server* serv = fFileSystem->Server();
		Request request(serv, fFileSystem);
		RequestBuilder& req = request.Builder();

		req.PutFH(fInfo.fHandle);
		req.DelegReturn(fData.fStateID, fData.fStateSeq);

		status_t result = request.Send();
		if (result != B_OK)
			return result;

		ReplyInterpreter& reply = request.Reply();

		if (HandleErrors(reply.NFS4Error(), serv, NULL, fInode->GetOpenState()))
			continue;

		reply.PutFH();

		return reply.DelegReturn();
	} while (true);
}
예제 #9
0
//=--------------------------------------------------------------------------=
// CImp_DrawDlg::SendKeystroke
//=--------------------------------------------------------------------------=
// Purpose: This function sends my mouse movement information to the m_qFriend 
//			queue.
//  
//
// Parameters:
//    uChar		-	Character value of the keystroke to send.
//
// Output:
//    none
//
// Notes:
//    This function provides a straightforward way to send an MSMQ message.
//    This function is called by the CDrawArea class, which was ported from 
//	  the MSMQ C_Draw sample.
//
// 
void CImp_DrawDlg::SendKeystroke(UINT uChar)
{
	try
	{
		// First, the friend queue must be defined and opened.
		if (m_qFriend != NULL && m_qFriend->IsOpen)
		{
			// Next, push the character into a variant.
			_variant_t vtChar((char*)&uChar);

			// Now set up the message properties.
			m_msgOut->Priority = 4;
			m_msgOut->Body = &vtChar;
			m_msgOut->Label = "Key: " + uChar;
			m_msgOut->Delivery = m_iRadio;

			// Lastly, send the message.
			m_msgOut->Send(m_qFriend);
		};
	}
	catch(_com_error &comerr)
	{
		HandleErrors(comerr);
	};
};
예제 #10
0
int Sapphire::Shutdown()
{
   if (initialized_)
   {
      initialized_ = false;
   }
   return HandleErrors();
}
예제 #11
0
int Controller::Shutdown()
{
   if (initialized_)
   {
      initialized_ = false;
   }
   return HandleErrors();
}
예제 #12
0
BOOL CImp_DrawDlg::IsDsEnabledLocaly()
{
    BOOL fDSConnection = FALSE;
     IMSMQApplicationPtr qapp;
    //
    // This should work on Windows NT 4.0 and on Windows 2000 and later.
    //
    try
    { 
     qapp.CreateInstance("MSMQ.MSMQApplication");
    }
    catch(_com_error &comerr)
	{
        HandleErrors(comerr);
	};

     
    //
    // This part handles the diffrence between Windows NT 4.0 and Windows 2000 and later.
    // It should work only on Windows 2000 and later.
    //
    try
    {    
        IMSMQApplication2Ptr qapp2 = qapp;
        fDSConnection = qapp2->GetIsDsEnabled();
    }
	catch(_com_error &comerr)
	{
        HRESULT hr = comerr.Error();
		if (hr == E_NOINTERFACE || hr == E_POINTER)
        {
			//
            // No such interface is implemented, we must be using MSMQ 1.0.
            // We can continue as if the local computer is DS-enabled. 
            //
            return TRUE;
        }
        else
        {
            HandleErrors(comerr);
        }
	};
    return fDSConnection;
}
예제 #13
0
파일: Net.cpp 프로젝트: Lexdysic/Ferrite
//=============================================================================
bool Socket::Send (const byte data[], unsigned len)
{ 
    ASSERT(IsValid());
    const int ret = ::send(m_socket, (const char *)data, len, 0);
    if (ret > 0)
        return true;

    HandleErrors();
    return false;
}
예제 #14
0
파일: Net.cpp 프로젝트: Lexdysic/Ferrite
//=============================================================================
unsigned Socket::Recv (byte data[], unsigned len)
{
    ASSERT(IsValid());
    const int ret = ::recv(m_socket, (char *)data, len, 0);
    if (ret > 0)
        return ret;

    HandleErrors();
    return 0;
}
예제 #15
0
int Sapphire::OnWaveLength(MM::PropertyBase* pProp, MM::ActionType eAct /* , long */)
{
   if (eAct == MM::BeforeGet)
   {
		pProp->Set(wave_);
   }
   else if (eAct == MM::AfterSet)
   {
	        pProp->Get(wave_);
   }
   return HandleErrors();
}
예제 #16
0
int Sapphire::OnHeadID(MM::PropertyBase* pProp, MM::ActionType eAct)
{
   if (eAct == MM::BeforeGet)
   {
		pProp->Set((this->queryLaser(headSerialNoToken_)).c_str());
   }
   else if (eAct == MM::AfterSet)
   {
			// never do anything!!
   }
   return HandleErrors();
}
예제 #17
0
status_t
Inode::ReadDirUp(struct dirent* de, uint32 pos, uint32 size)
{
	ASSERT(de != NULL);

	uint32 attempt = 0;
	do {
		RPC::Server* serv = fFileSystem->Server();
		Request request(serv, fFileSystem);
		RequestBuilder& req = request.Builder();

		req.PutFH(fInfo.fHandle);
		req.LookUpUp();
		req.GetFH();

		if (fFileSystem->IsAttrSupported(FATTR4_FILEID)) {
			Attribute attr[] = { FATTR4_FILEID };
			req.GetAttr(attr, sizeof(attr) / sizeof(Attribute));
		}

		status_t result = request.Send();
		if (result != B_OK)
			return result;

		ReplyInterpreter& reply = request.Reply();

		if (HandleErrors(attempt, reply.NFS4Error(), serv))
			continue;

		reply.PutFH();
		result = reply.LookUpUp();
		if (result != B_OK)
			return result;

		FileHandle fh;
		reply.GetFH(&fh);

		uint64 fileId;
		if (fFileSystem->IsAttrSupported(FATTR4_FILEID)) {
			AttrValue* values;
			uint32 count;
			result = reply.GetAttr(&values, &count);
			if (result != B_OK)
				return result;

			fileId = values[0].fData.fValue64;
			delete[] values;
		} else
			fileId = fFileSystem->AllocFileId();

		return FillDirEntry(de, FileIdToInoT(fileId), "..", pos, size);
	} while (true);
}
예제 #18
0
int Sapphire::GetOpen(bool& open)
{
   long state;
   GetState(state);
   if (state==1)
      open = true;
   else if (state==0)
      open = false;
   else
      error_ = DEVICE_UNKNOWN_POSITION;

   return HandleErrors();
}
예제 #19
0
int Controller::OnTriggerSequence(MM::PropertyBase* pProp, MM::ActionType eAct)
{
   if (eAct == MM::BeforeGet)
   {
      pProp->Set(triggerSequence_.c_str());
   }
   else if (eAct == MM::AfterSet)
   { 
      pProp->Get(triggerSequence_);
      SetTrigger();
   }
   return HandleErrors();
}
예제 #20
0
int Sapphire::OnMaximumLaserPower(MM::PropertyBase* pProp, MM::ActionType eAct)
{
   if (eAct == MM::BeforeGet)
   {
		pProp->Set(maxlp_);
   }
   else if (eAct == MM::AfterSet)
   {
	        pProp->Get(maxlp_);

			SetPropertyLimits(g_Keyword_PowerSetpoint, minlp_, maxlp_);
   }
   return HandleErrors();
}
예제 #21
0
int Controller::GetOpen(bool& open)
{
	long state;
	GetProperty(g_Keyword_Global_State, state);

	if (state == 1)
		open = true;
	else if (state == 0)
		open = false;
	else
		error_ = DEVICE_UNKNOWN_POSITION;

	return HandleErrors();
}
예제 #22
0
int Sapphire::OnHeadUsageHours(MM::PropertyBase* pProp, MM::ActionType eAct)
{
   if (eAct == MM::BeforeGet)
   {
		std::string svalue = this->queryLaser(headUsageHoursToken_);
		double dvalue = atof(svalue.c_str());
		pProp->Set(dvalue);
   }
   else if (eAct == MM::AfterSet)
   {
			// never do anything!!
   }
   return HandleErrors();
}
예제 #23
0
int Controller::OnIntensity(MM::PropertyBase* pProp, MM::ActionType eAct, long index)
{
	long intensity;
	if (eAct == MM::BeforeGet && intensityUpdated_[index]) {
		pProp->Set(channelIntensities_[index]);
		intensityUpdated_[index] = false;
	}
	else if (eAct == MM::AfterSet) {
		pProp->Get(intensity);
		SetIntensity(intensity, index);
	}

	return HandleErrors();
}
예제 #24
0
//=--------------------------------------------------------------------------=
// CImp_DrawDlg::Arrived
//=--------------------------------------------------------------------------=
// Purpose: This function handles events received from the opened queue.
//  
//
// Parameters:
//    IDispatch*		-	The queue sending the event
//	  lErrorCode		-	S_OK if no error, otherwise the error code sent
//							along with the queue event
//	  lCursor			-	Cursor value sent with the event. Unused in
//							this function.
//
// Output:
//    none
//
// Notes:
//    The queue is opened in the OnInitDialog() function. An error event will
//	  popup a dialog box and return from the function. For a normal event, retrieve
//	  the message body, and interpret it either as a keystroke or as line data.
//	  After you are finished handling an event, you must signal your queue that you
//	  are ready to receive another event.
//
void CImp_DrawDlg::Arrived(IDispatch* pdispQueue, long lErrorCode, long lCursor)
{
	if (lErrorCode != S_OK)
	{
		// This code is what will run if the _DMSMQEventEvents->ArrivedError() Event is called.
		char szErr[30]  = "";
		_itoa_s(lErrorCode, szErr, sizeof(szErr), 16);
		CString tempString = "Method returned HRESULT: ";
		tempString += szErr;
		MessageBox(tempString, NULL, MB_ICONSTOP | MB_OK);
		return;
	};

	IMSMQMessagePtr msgIn;
	LINE			line;
	char*			strTextIn = "";
	_variant_t		vtTimeout((short) 100);
	_bstr_t			btBody;


	try
	{
		IMSMQQueuePtr	q(pdispQueue);		// Creates an MSMQQueue smart pointer pointing to pdispQueue
		msgIn = q->Receive(&vtMissing, &vtMissing, &vtMissing, &vtTimeout);	// Any messages?
		btBody = msgIn->Body;				// Copy the message body to my own bstr.
		
		strTextIn = (char*) btBody;			// Convert to char*.
		if (msgIn->BodyLength == 2)		
			m_drawScribble.AddKeystroke(strTextIn);
		else
		{
			int iRes = sscanf_s(strTextIn, "%07ld%07ld%07ld%07ld", 
				&line.ptStart.x, &line.ptStart.y, 
				&line.ptEnd.x, &line.ptEnd.y);

			if (iRes != 0 && iRes != EOF)
			{
				m_drawScribble.AddLine(line);
			}
		};
	}
	catch(_com_error &comerr)
	{
		HandleErrors(comerr);
	};

	m_queue->EnableNotification(m_qevent);		// IMPORTANT: After you receive an event, you must re-enable 
												// event notification.
};
예제 #25
0
int Sapphire::OnPowerReadback(MM::PropertyBase* pProp, MM::ActionType eAct, long /*index*/)
{

   double powerReadback;
   if (eAct == MM::BeforeGet)
   {
      GetPowerReadback(powerReadback);
      pProp->Set(powerReadback);
   }
   else if (eAct == MM::AfterSet)
   {
			// never do anything!!
   }
   return HandleErrors();
}
예제 #26
0
int Controller::OnState(MM::PropertyBase* pProp, MM::ActionType eAct)
{
   if (eAct == MM::BeforeGet)
   {
      GetState(state_);
      pProp->Set(state_);
   }
   else if (eAct == MM::AfterSet)
   {
      pProp->Get(state_);
      SetState(state_);
   }
   
   return HandleErrors();
}
예제 #27
0
int Controller::OnLockPod(MM::PropertyBase* pProp, MM::ActionType eAct)
{
	if (eAct == MM::AfterSet)
	{
		long lockPod;

		pProp->Get(lockPod);

		MMThreadGuard myLock(lock_);
		Purge();
		Send(lockPod == 1 ? "PORT:P=OFF" : "PORT:P=ON");
		ReceiveOneLine();
	}

	return HandleErrors();
}
예제 #28
0
int GenericSLM::OnGraphicsPort(MM::PropertyBase* pProp, MM::ActionType eAct)
{
   if (eAct == MM::BeforeGet)
   {
      pProp->Set((const char *) graphicsPortDescription_.c_str());
   }
   else if (eAct == MM::AfterSet)
   { 
      long graphicsPortNum;
      pProp->Get(graphicsPortDescription_);
      GetCurrentPropertyData(g_Graphics_Port,graphicsPortNum);
      chosenDisplayIndex_ = graphicsPortNum;
      DetachDisplayDevice(&displays_[chosenDisplayIndex_]);
   }
   return HandleErrors();
}
예제 #29
0
int Controller::Initialize()
{
	string strError;

	ReadGreeting();

	Purge();
	Send("XMODEL");
	ReceiveOneLine();//Mainboard version returned

	int rlt = (int)buf_string_.find("pE-4000");
	if (rlt < 0) {
		strError = "\r\n\r\nIncompatible device driver!\r\n";
		strError += "The driver loaded: CoolLED-pE4000\r\n";
		strError += "The device found: ";
		strError += buf_string_.substr(7);
		strError += "\r\n\r\n";
		strError += "Internal Error Reference: ";
		SetErrorText(DEVICE_NOT_SUPPORTED, strError.c_str());
		return DEVICE_NOT_SUPPORTED;
	}

	for (int i = 0; i < 4; i++) {
		channelIntensities_[i] = 0;
		channelSelection_[i] = 0;
		channelWave_[i] = "";
		intensityUpdated_[i] = false;
		selectionUpdated_[i] = false;
		waveUpdated_[i] = false;
	}

	GenerateDescription();
	GenerateChannelState();
	GenerateChannelSelector();
	GeneratePropertyIntensity();
	GeneratePropertyState();
	GeneratePropertyLockPod();

	GetUpdate();

	mThread_ = new PollingThread(*this);
	mThread_->Start();

	initialized_ = true;
	return HandleErrors();

}
예제 #30
0
//function to execute SELECT * query
wyInt32
TableView::ExecuteTableData()
{
	wyString        query;
    wyInt32         ret;
    MySQLDataEx*    pdata;

    query.Sprintf("select * from `%s`.`%s`", m_mydata->m_db.GetString(), m_mydata->m_table.GetString());

    //get filter info
    GetFilterInfo(query);

    //get sort info
    GetSortInfo(query);

    //get limits
    GetLimits(query);

    //execut query
    m_mydata->m_datares = ExecuteQuery(query);

    //is thread stopped
	if(ThreadStopStatus())
	{	
        return TE_STOPPED;
	}

    //any error? show error dialog
	if(!m_mydata->m_datares)
	{
        return HandleErrors(query);
	}

    //allocate row array, if the thread is stopped, delete them
    if((ret = AllocateRowsExArray()) != TE_SUCCESS || 
        (ret = GetTableDetails()) != TE_SUCCESS)
    {
        pdata = ResetData(m_data);
        delete pdata;
        return ret;
    }

    //add new row in the end
    AddNewRow();

    return TE_SUCCESS;
}