Skip to content

Commit

Permalink
re #10095 revert the revert and avoid the facility name TEST
Browse files Browse the repository at this point in the history
  • Loading branch information
NickDraper committed Aug 12, 2014
1 parent a68e64a commit 2187b54
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 10 deletions.
21 changes: 13 additions & 8 deletions Code/Mantid/Framework/ISISLiveData/src/FakeISISEventDAE.cpp
Expand Up @@ -74,6 +74,7 @@ class TestServerConnection: public Poco::Net::TCPServerConnection
Kernel::MersenneTwister tof(0,100.0,200.0);
Kernel::MersenneTwister spec(1234,0.0,static_cast<double>(m_nSpectra));
Kernel::MersenneTwister period(0,0.0,static_cast<double>(m_nPeriods));
std::vector<TCPStreamEventNeutron> neutronVector (m_nEvents);
for(;;)
{
Poco::Thread::sleep(m_Rate);
Expand All @@ -89,13 +90,17 @@ class TestServerConnection: public Poco::Net::TCPServerConnection
TCPStreamEventNeutron neutron;
neutron.time_of_flight = static_cast<float>(tof.nextValue());
neutron.spectrum = static_cast<uint32_t>(spec.nextValue());
socket().sendBytes(&neutron,(int)sizeof(neutron));
neutronVector[i] = neutron;
}

int bytesSent = 0;
int targetSize = m_nEvents * sizeof(TCPStreamEventNeutron);
while (bytesSent < targetSize)
{
bytesSent += socket().sendBytes(neutronVector.data() + bytesSent,targetSize-bytesSent);
}

}
TCPStreamEventDataSetup setup;
setup.head_setup.run_number = 1234;
strcpy(setup.head_setup.inst_name,"MUSR");
socket().sendBytes(&setup,(int)sizeof(setup));
}
};

Expand Down Expand Up @@ -155,9 +160,9 @@ void FakeISISEventDAE::init()
{
declareProperty(new PropertyWithValue<int>("NPeriods", 1, Direction::Input),"Number of periods.");
declareProperty(new PropertyWithValue<int>("NSpectra", 100, Direction::Input),"Number of spectra.");
declareProperty(new PropertyWithValue<int>("Rate", 1000, Direction::Input),
"Rate of sending the data: stream of NEvents events is sent every Rate microseconds.");
declareProperty(new PropertyWithValue<int>("NEvents", 100, Direction::Input),"Number of events in each packet.");
declareProperty(new PropertyWithValue<int>("Rate", 20, Direction::Input),
"Rate of sending the data: stream of NEvents events is sent every Rate milliseconds.");
declareProperty(new PropertyWithValue<int>("NEvents", 1000, Direction::Input),"Number of events in each packet.");
}

/**
Expand Down
Expand Up @@ -18,7 +18,7 @@
// Time we'll wait on a receive call (in seconds)
const long RECV_TIMEOUT = 30;
// Sleep time in case we need to wait for the data to become available (in milliseconds)
const long RECV_WAIT = 100;
const long RECV_WAIT = 1;

//----------------------------------------------------------------------
// Forward declarations
Expand Down
Expand Up @@ -263,7 +263,7 @@ void ISISLiveEventDataListener::run()
}
else
{
Poco::Thread::sleep(100);
Poco::Thread::sleep(RECV_WAIT);
}
}
if (!events.isValid())
Expand Down
3 changes: 3 additions & 0 deletions Code/Mantid/docs/source/algorithms/FakeISISEventDAE-v1.rst
Expand Up @@ -13,4 +13,7 @@ Simulates ISIS event DAE. It runs continuously until canceled and
listens to port 10000 for connection. When connected starts sending
event packets.

Note: For a connection to succeed uyou need to be running the :ref:`FakeISISHistoDAE` as well,
otherwise you will recieve cannot connect to port 10000 error messages.

.. categories::
24 changes: 24 additions & 0 deletions Code/Mantid/instrument/Facilities.xml
Expand Up @@ -602,4 +602,28 @@
</instrument>
</facility>

<!-- Test Facility to allow example usage of Live listeners against "Fake" instrument sources -->
<facility name="TEST_LIVE" FileExtensions=".nxs,.raw">
<instrument name="ISIS_HISTOGRAM">
<technique>Test Listener</technique>
<livedata address="localhost:6789" listener="ISISHistoDataListener"/>
</instrument>

<instrument name="ISIS_EVENT">
<technique>Test Listener</technique>
<livedata address="localhost:10000" listener="ISISLiveEventDataListener" />
</instrument>

<instrument name="ADARA_TestData">
<technique>Test Listener</technique>
<livedata listener="TestDataListener" address="127.0.0.1:0" />
</instrument>

<instrument name="ADARA_FakeEvent">
<technique>Test Listener</technique>
<livedata listener="FakeEventDataListener" address="127.0.0.1:0" />
</instrument>

</facility>

</facilities>

0 comments on commit 2187b54

Please sign in to comment.