Merged master 8748
This commit is contained in:
@@ -0,0 +1,903 @@
|
||||
#ifndef BOOST_THREAD_WIN32_SHARED_MUTEX_HPP
|
||||
#define BOOST_THREAD_WIN32_SHARED_MUTEX_HPP
|
||||
|
||||
// (C) Copyright 2006-8 Anthony Williams
|
||||
// (C) Copyright 2011-2012 Vicente J. Botet Escriba
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/detail/interlocked.hpp>
|
||||
#include <boost/thread/win32/thread_primitives.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <limits.h>
|
||||
#include <boost/thread/thread_time.hpp>
|
||||
#ifdef BOOST_THREAD_USES_CHRONO
|
||||
#include <boost/chrono/system_clocks.hpp>
|
||||
#include <boost/chrono/ceil.hpp>
|
||||
#endif
|
||||
#include <boost/thread/detail/delete.hpp>
|
||||
|
||||
#include <boost/config/abi_prefix.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
class shared_mutex
|
||||
{
|
||||
private:
|
||||
struct state_data
|
||||
{
|
||||
unsigned shared_count:11,
|
||||
shared_waiting:11,
|
||||
exclusive:1,
|
||||
upgrade:1,
|
||||
exclusive_waiting:7,
|
||||
exclusive_waiting_blocked:1;
|
||||
|
||||
friend bool operator==(state_data const& lhs,state_data const& rhs)
|
||||
{
|
||||
return *reinterpret_cast<unsigned const*>(&lhs)==*reinterpret_cast<unsigned const*>(&rhs);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename T>
|
||||
T interlocked_compare_exchange(T* target,T new_value,T comparand)
|
||||
{
|
||||
BOOST_STATIC_ASSERT(sizeof(T)==sizeof(long));
|
||||
long const res=BOOST_INTERLOCKED_COMPARE_EXCHANGE(reinterpret_cast<long*>(target),
|
||||
*reinterpret_cast<long*>(&new_value),
|
||||
*reinterpret_cast<long*>(&comparand));
|
||||
return *reinterpret_cast<T const*>(&res);
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
unlock_sem = 0,
|
||||
exclusive_sem = 1
|
||||
};
|
||||
|
||||
state_data state;
|
||||
detail::win32::handle semaphores[2];
|
||||
detail::win32::handle upgrade_sem;
|
||||
|
||||
void release_waiters(state_data old_state)
|
||||
{
|
||||
if(old_state.exclusive_waiting)
|
||||
{
|
||||
BOOST_VERIFY(detail::win32::ReleaseSemaphore(semaphores[exclusive_sem],1,0)!=0);
|
||||
}
|
||||
|
||||
if(old_state.shared_waiting || old_state.exclusive_waiting)
|
||||
{
|
||||
BOOST_VERIFY(detail::win32::ReleaseSemaphore(semaphores[unlock_sem],old_state.shared_waiting + (old_state.exclusive_waiting?1:0),0)!=0);
|
||||
}
|
||||
}
|
||||
void release_shared_waiters(state_data old_state)
|
||||
{
|
||||
if(old_state.shared_waiting || old_state.exclusive_waiting)
|
||||
{
|
||||
BOOST_VERIFY(detail::win32::ReleaseSemaphore(semaphores[unlock_sem],old_state.shared_waiting + (old_state.exclusive_waiting?1:0),0)!=0);
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
BOOST_THREAD_NO_COPYABLE(shared_mutex)
|
||||
shared_mutex()
|
||||
{
|
||||
semaphores[unlock_sem]=detail::win32::create_anonymous_semaphore(0,LONG_MAX);
|
||||
semaphores[exclusive_sem]=detail::win32::create_anonymous_semaphore_nothrow(0,LONG_MAX);
|
||||
if (!semaphores[exclusive_sem])
|
||||
{
|
||||
detail::win32::release_semaphore(semaphores[unlock_sem],LONG_MAX);
|
||||
boost::throw_exception(thread_resource_error());
|
||||
}
|
||||
upgrade_sem=detail::win32::create_anonymous_semaphore_nothrow(0,LONG_MAX);
|
||||
if (!upgrade_sem)
|
||||
{
|
||||
detail::win32::release_semaphore(semaphores[unlock_sem],LONG_MAX);
|
||||
detail::win32::release_semaphore(semaphores[exclusive_sem],LONG_MAX);
|
||||
boost::throw_exception(thread_resource_error());
|
||||
}
|
||||
state_data state_={0,0,0,0,0,0};
|
||||
state=state_;
|
||||
}
|
||||
|
||||
~shared_mutex()
|
||||
{
|
||||
detail::win32::CloseHandle(upgrade_sem);
|
||||
detail::win32::CloseHandle(semaphores[unlock_sem]);
|
||||
detail::win32::CloseHandle(semaphores[exclusive_sem]);
|
||||
}
|
||||
|
||||
bool try_lock_shared()
|
||||
{
|
||||
state_data old_state=state;
|
||||
for(;;)
|
||||
{
|
||||
state_data new_state=old_state;
|
||||
if(!new_state.exclusive && !new_state.exclusive_waiting_blocked)
|
||||
{
|
||||
++new_state.shared_count;
|
||||
if(!new_state.shared_count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state);
|
||||
if(current_state==old_state)
|
||||
{
|
||||
break;
|
||||
}
|
||||
old_state=current_state;
|
||||
}
|
||||
return !(old_state.exclusive| old_state.exclusive_waiting_blocked);
|
||||
}
|
||||
|
||||
void lock_shared()
|
||||
{
|
||||
|
||||
#if defined BOOST_THREAD_USES_DATETIME
|
||||
BOOST_VERIFY(timed_lock_shared(::boost::detail::get_system_time_sentinel()));
|
||||
#else
|
||||
BOOST_VERIFY(try_lock_shared_until(chrono::steady_clock::now()));
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined BOOST_THREAD_USES_DATETIME
|
||||
template<typename TimeDuration>
|
||||
bool timed_lock_shared(TimeDuration const & relative_time)
|
||||
{
|
||||
return timed_lock_shared(get_system_time()+relative_time);
|
||||
}
|
||||
bool timed_lock_shared(boost::system_time const& wait_until)
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
state_data old_state=state;
|
||||
for(;;)
|
||||
{
|
||||
state_data new_state=old_state;
|
||||
if(new_state.exclusive || new_state.exclusive_waiting_blocked)
|
||||
{
|
||||
++new_state.shared_waiting;
|
||||
if(!new_state.shared_waiting)
|
||||
{
|
||||
boost::throw_exception(boost::lock_error());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
++new_state.shared_count;
|
||||
if(!new_state.shared_count)
|
||||
{
|
||||
boost::throw_exception(boost::lock_error());
|
||||
}
|
||||
}
|
||||
|
||||
state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state);
|
||||
if(current_state==old_state)
|
||||
{
|
||||
break;
|
||||
}
|
||||
old_state=current_state;
|
||||
}
|
||||
|
||||
if(!(old_state.exclusive| old_state.exclusive_waiting_blocked))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned long const res=detail::win32::WaitForSingleObjectEx(semaphores[unlock_sem],::boost::detail::get_milliseconds_until(wait_until), 0);
|
||||
if(res==detail::win32::timeout)
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
state_data new_state=old_state;
|
||||
if(new_state.exclusive || new_state.exclusive_waiting_blocked)
|
||||
{
|
||||
if(new_state.shared_waiting)
|
||||
{
|
||||
--new_state.shared_waiting;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
++new_state.shared_count;
|
||||
if(!new_state.shared_count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state);
|
||||
if(current_state==old_state)
|
||||
{
|
||||
break;
|
||||
}
|
||||
old_state=current_state;
|
||||
}
|
||||
|
||||
if(!(old_state.exclusive| old_state.exclusive_waiting_blocked))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
BOOST_ASSERT(res==0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_THREAD_USES_CHRONO
|
||||
template <class Rep, class Period>
|
||||
bool try_lock_shared_for(const chrono::duration<Rep, Period>& rel_time)
|
||||
{
|
||||
return try_lock_shared_until(chrono::steady_clock::now() + rel_time);
|
||||
}
|
||||
template <class Clock, class Duration>
|
||||
bool try_lock_shared_until(const chrono::time_point<Clock, Duration>& t)
|
||||
{
|
||||
using namespace chrono;
|
||||
system_clock::time_point s_now = system_clock::now();
|
||||
typename Clock::time_point c_now = Clock::now();
|
||||
return try_lock_shared_until(s_now + ceil<system_clock::duration>(t - c_now));
|
||||
}
|
||||
template <class Duration>
|
||||
bool try_lock_shared_until(const chrono::time_point<chrono::system_clock, Duration>& t)
|
||||
{
|
||||
using namespace chrono;
|
||||
typedef time_point<chrono::system_clock, chrono::system_clock::duration> sys_tmpt;
|
||||
return try_lock_shared_until(sys_tmpt(chrono::ceil<chrono::system_clock::duration>(t.time_since_epoch())));
|
||||
}
|
||||
bool try_lock_shared_until(const chrono::time_point<chrono::system_clock, chrono::system_clock::duration>& tp)
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
state_data old_state=state;
|
||||
for(;;)
|
||||
{
|
||||
state_data new_state=old_state;
|
||||
if(new_state.exclusive || new_state.exclusive_waiting_blocked)
|
||||
{
|
||||
++new_state.shared_waiting;
|
||||
if(!new_state.shared_waiting)
|
||||
{
|
||||
boost::throw_exception(boost::lock_error());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
++new_state.shared_count;
|
||||
if(!new_state.shared_count)
|
||||
{
|
||||
boost::throw_exception(boost::lock_error());
|
||||
}
|
||||
}
|
||||
|
||||
state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state);
|
||||
if(current_state==old_state)
|
||||
{
|
||||
break;
|
||||
}
|
||||
old_state=current_state;
|
||||
}
|
||||
|
||||
if(!(old_state.exclusive| old_state.exclusive_waiting_blocked))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
chrono::system_clock::time_point n = chrono::system_clock::now();
|
||||
unsigned long res;
|
||||
if (tp>n) {
|
||||
chrono::milliseconds rel_time= chrono::ceil<chrono::milliseconds>(tp-n);
|
||||
res=detail::win32::WaitForSingleObjectEx(semaphores[unlock_sem],
|
||||
static_cast<unsigned long>(rel_time.count()), 0);
|
||||
} else {
|
||||
res=detail::win32::timeout;
|
||||
}
|
||||
if(res==detail::win32::timeout)
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
state_data new_state=old_state;
|
||||
if(new_state.exclusive || new_state.exclusive_waiting_blocked)
|
||||
{
|
||||
if(new_state.shared_waiting)
|
||||
{
|
||||
--new_state.shared_waiting;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
++new_state.shared_count;
|
||||
if(!new_state.shared_count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state);
|
||||
if(current_state==old_state)
|
||||
{
|
||||
break;
|
||||
}
|
||||
old_state=current_state;
|
||||
}
|
||||
|
||||
if(!(old_state.exclusive| old_state.exclusive_waiting_blocked))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
BOOST_ASSERT(res==0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void unlock_shared()
|
||||
{
|
||||
state_data old_state=state;
|
||||
for(;;)
|
||||
{
|
||||
state_data new_state=old_state;
|
||||
bool const last_reader=!--new_state.shared_count;
|
||||
|
||||
if(last_reader)
|
||||
{
|
||||
if(new_state.upgrade)
|
||||
{
|
||||
new_state.upgrade=false;
|
||||
new_state.exclusive=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(new_state.exclusive_waiting)
|
||||
{
|
||||
--new_state.exclusive_waiting;
|
||||
new_state.exclusive_waiting_blocked=false;
|
||||
}
|
||||
new_state.shared_waiting=0;
|
||||
}
|
||||
}
|
||||
|
||||
state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state);
|
||||
if(current_state==old_state)
|
||||
{
|
||||
if(last_reader)
|
||||
{
|
||||
if(old_state.upgrade)
|
||||
{
|
||||
BOOST_VERIFY(detail::win32::ReleaseSemaphore(upgrade_sem,1,0)!=0);
|
||||
}
|
||||
else
|
||||
{
|
||||
release_waiters(old_state);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
old_state=current_state;
|
||||
}
|
||||
}
|
||||
|
||||
void lock()
|
||||
{
|
||||
|
||||
#if defined BOOST_THREAD_USES_DATETIME
|
||||
BOOST_VERIFY(timed_lock(::boost::detail::get_system_time_sentinel()));
|
||||
#else
|
||||
BOOST_VERIFY(try_lock_until(chrono::steady_clock::now()));
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined BOOST_THREAD_USES_DATETIME
|
||||
template<typename TimeDuration>
|
||||
bool timed_lock(TimeDuration const & relative_time)
|
||||
{
|
||||
return timed_lock(get_system_time()+relative_time);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool try_lock()
|
||||
{
|
||||
state_data old_state=state;
|
||||
for(;;)
|
||||
{
|
||||
state_data new_state=old_state;
|
||||
if(new_state.shared_count || new_state.exclusive)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_state.exclusive=true;
|
||||
}
|
||||
|
||||
state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state);
|
||||
if(current_state==old_state)
|
||||
{
|
||||
break;
|
||||
}
|
||||
old_state=current_state;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#if defined BOOST_THREAD_USES_DATETIME
|
||||
bool timed_lock(boost::system_time const& wait_until)
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
state_data old_state=state;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
state_data new_state=old_state;
|
||||
if(new_state.shared_count || new_state.exclusive)
|
||||
{
|
||||
++new_state.exclusive_waiting;
|
||||
if(!new_state.exclusive_waiting)
|
||||
{
|
||||
boost::throw_exception(boost::lock_error());
|
||||
}
|
||||
|
||||
new_state.exclusive_waiting_blocked=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_state.exclusive=true;
|
||||
}
|
||||
|
||||
state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state);
|
||||
if(current_state==old_state)
|
||||
{
|
||||
break;
|
||||
}
|
||||
old_state=current_state;
|
||||
}
|
||||
|
||||
if(!old_state.shared_count && !old_state.exclusive)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
#ifndef UNDER_CE
|
||||
const bool wait_all = true;
|
||||
#else
|
||||
const bool wait_all = false;
|
||||
#endif
|
||||
unsigned long const wait_res=detail::win32::WaitForMultipleObjectsEx(2,semaphores,wait_all,::boost::detail::get_milliseconds_until(wait_until), 0);
|
||||
if(wait_res==detail::win32::timeout)
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
bool must_notify = false;
|
||||
state_data new_state=old_state;
|
||||
if(new_state.shared_count || new_state.exclusive)
|
||||
{
|
||||
if(new_state.exclusive_waiting)
|
||||
{
|
||||
if(!--new_state.exclusive_waiting)
|
||||
{
|
||||
new_state.exclusive_waiting_blocked=false;
|
||||
must_notify = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
new_state.exclusive=true;
|
||||
}
|
||||
|
||||
state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state);
|
||||
if (must_notify)
|
||||
{
|
||||
BOOST_VERIFY(detail::win32::ReleaseSemaphore(semaphores[unlock_sem],1,0)!=0);
|
||||
}
|
||||
|
||||
if(current_state==old_state)
|
||||
{
|
||||
break;
|
||||
}
|
||||
old_state=current_state;
|
||||
}
|
||||
if(!old_state.shared_count && !old_state.exclusive)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
BOOST_ASSERT(wait_res<2);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef BOOST_THREAD_USES_CHRONO
|
||||
template <class Rep, class Period>
|
||||
bool try_lock_for(const chrono::duration<Rep, Period>& rel_time)
|
||||
{
|
||||
return try_lock_until(chrono::steady_clock::now() + rel_time);
|
||||
}
|
||||
template <class Clock, class Duration>
|
||||
bool try_lock_until(const chrono::time_point<Clock, Duration>& t)
|
||||
{
|
||||
using namespace chrono;
|
||||
system_clock::time_point s_now = system_clock::now();
|
||||
typename Clock::time_point c_now = Clock::now();
|
||||
return try_lock_until(s_now + ceil<system_clock::duration>(t - c_now));
|
||||
}
|
||||
template <class Duration>
|
||||
bool try_lock_until(const chrono::time_point<chrono::system_clock, Duration>& t)
|
||||
{
|
||||
using namespace chrono;
|
||||
typedef time_point<chrono::system_clock, chrono::system_clock::duration> sys_tmpt;
|
||||
return try_lock_until(sys_tmpt(chrono::ceil<chrono::system_clock::duration>(t.time_since_epoch())));
|
||||
}
|
||||
bool try_lock_until(const chrono::time_point<chrono::system_clock, chrono::system_clock::duration>& tp)
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
state_data old_state=state;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
state_data new_state=old_state;
|
||||
if(new_state.shared_count || new_state.exclusive)
|
||||
{
|
||||
++new_state.exclusive_waiting;
|
||||
if(!new_state.exclusive_waiting)
|
||||
{
|
||||
boost::throw_exception(boost::lock_error());
|
||||
}
|
||||
|
||||
new_state.exclusive_waiting_blocked=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_state.exclusive=true;
|
||||
}
|
||||
|
||||
state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state);
|
||||
if(current_state==old_state)
|
||||
{
|
||||
break;
|
||||
}
|
||||
old_state=current_state;
|
||||
}
|
||||
|
||||
if(!old_state.shared_count && !old_state.exclusive)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
#ifndef UNDER_CE
|
||||
const bool wait_all = true;
|
||||
#else
|
||||
const bool wait_all = false;
|
||||
#endif
|
||||
|
||||
chrono::system_clock::time_point n = chrono::system_clock::now();
|
||||
unsigned long wait_res;
|
||||
if (tp>n) {
|
||||
chrono::milliseconds rel_time= chrono::ceil<chrono::milliseconds>(tp-chrono::system_clock::now());
|
||||
wait_res=detail::win32::WaitForMultipleObjectsEx(2,semaphores,wait_all,
|
||||
static_cast<unsigned long>(rel_time.count()), 0);
|
||||
} else {
|
||||
wait_res=detail::win32::timeout;
|
||||
}
|
||||
if(wait_res==detail::win32::timeout)
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
bool must_notify = false;
|
||||
state_data new_state=old_state;
|
||||
if(new_state.shared_count || new_state.exclusive)
|
||||
{
|
||||
if(new_state.exclusive_waiting)
|
||||
{
|
||||
if(!--new_state.exclusive_waiting)
|
||||
{
|
||||
new_state.exclusive_waiting_blocked=false;
|
||||
must_notify = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
new_state.exclusive=true;
|
||||
}
|
||||
|
||||
state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state);
|
||||
if (must_notify)
|
||||
{
|
||||
BOOST_VERIFY(detail::win32::ReleaseSemaphore(semaphores[unlock_sem],1,0)!=0);
|
||||
}
|
||||
if(current_state==old_state)
|
||||
{
|
||||
break;
|
||||
}
|
||||
old_state=current_state;
|
||||
}
|
||||
if(!old_state.shared_count && !old_state.exclusive)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
BOOST_ASSERT(wait_res<2);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void unlock()
|
||||
{
|
||||
state_data old_state=state;
|
||||
for(;;)
|
||||
{
|
||||
state_data new_state=old_state;
|
||||
new_state.exclusive=false;
|
||||
if(new_state.exclusive_waiting)
|
||||
{
|
||||
--new_state.exclusive_waiting;
|
||||
new_state.exclusive_waiting_blocked=false;
|
||||
}
|
||||
new_state.shared_waiting=0;
|
||||
|
||||
state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state);
|
||||
if(current_state==old_state)
|
||||
{
|
||||
break;
|
||||
}
|
||||
old_state=current_state;
|
||||
}
|
||||
release_waiters(old_state);
|
||||
}
|
||||
|
||||
void lock_upgrade()
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
state_data old_state=state;
|
||||
for(;;)
|
||||
{
|
||||
state_data new_state=old_state;
|
||||
if(new_state.exclusive || new_state.exclusive_waiting_blocked || new_state.upgrade)
|
||||
{
|
||||
++new_state.shared_waiting;
|
||||
if(!new_state.shared_waiting)
|
||||
{
|
||||
boost::throw_exception(boost::lock_error());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
++new_state.shared_count;
|
||||
if(!new_state.shared_count)
|
||||
{
|
||||
boost::throw_exception(boost::lock_error());
|
||||
}
|
||||
new_state.upgrade=true;
|
||||
}
|
||||
|
||||
state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state);
|
||||
if(current_state==old_state)
|
||||
{
|
||||
break;
|
||||
}
|
||||
old_state=current_state;
|
||||
}
|
||||
|
||||
if(!(old_state.exclusive|| old_state.exclusive_waiting_blocked|| old_state.upgrade))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
BOOST_VERIFY(!detail::win32::WaitForSingleObjectEx(semaphores[unlock_sem],detail::win32::infinite, 0));
|
||||
}
|
||||
}
|
||||
|
||||
bool try_lock_upgrade()
|
||||
{
|
||||
state_data old_state=state;
|
||||
for(;;)
|
||||
{
|
||||
state_data new_state=old_state;
|
||||
if(new_state.exclusive || new_state.exclusive_waiting_blocked || new_state.upgrade)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
++new_state.shared_count;
|
||||
if(!new_state.shared_count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
new_state.upgrade=true;
|
||||
}
|
||||
|
||||
state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state);
|
||||
if(current_state==old_state)
|
||||
{
|
||||
break;
|
||||
}
|
||||
old_state=current_state;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void unlock_upgrade()
|
||||
{
|
||||
state_data old_state=state;
|
||||
for(;;)
|
||||
{
|
||||
state_data new_state=old_state;
|
||||
new_state.upgrade=false;
|
||||
bool const last_reader=!--new_state.shared_count;
|
||||
|
||||
new_state.shared_waiting=0;
|
||||
if(last_reader)
|
||||
{
|
||||
if(new_state.exclusive_waiting)
|
||||
{
|
||||
--new_state.exclusive_waiting;
|
||||
new_state.exclusive_waiting_blocked=false;
|
||||
}
|
||||
}
|
||||
|
||||
state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state);
|
||||
if(current_state==old_state)
|
||||
{
|
||||
if(last_reader)
|
||||
{
|
||||
release_waiters(old_state);
|
||||
}
|
||||
else {
|
||||
release_shared_waiters(old_state);
|
||||
}
|
||||
// #7720
|
||||
//else {
|
||||
// release_waiters(old_state);
|
||||
//}
|
||||
break;
|
||||
}
|
||||
old_state=current_state;
|
||||
}
|
||||
}
|
||||
|
||||
void unlock_upgrade_and_lock()
|
||||
{
|
||||
state_data old_state=state;
|
||||
for(;;)
|
||||
{
|
||||
state_data new_state=old_state;
|
||||
bool const last_reader=!--new_state.shared_count;
|
||||
|
||||
if(last_reader)
|
||||
{
|
||||
new_state.upgrade=false;
|
||||
new_state.exclusive=true;
|
||||
}
|
||||
|
||||
state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state);
|
||||
if(current_state==old_state)
|
||||
{
|
||||
if(!last_reader)
|
||||
{
|
||||
BOOST_VERIFY(!detail::win32::WaitForSingleObjectEx(upgrade_sem,detail::win32::infinite, 0));
|
||||
}
|
||||
break;
|
||||
}
|
||||
old_state=current_state;
|
||||
}
|
||||
}
|
||||
|
||||
void unlock_and_lock_upgrade()
|
||||
{
|
||||
state_data old_state=state;
|
||||
for(;;)
|
||||
{
|
||||
state_data new_state=old_state;
|
||||
new_state.exclusive=false;
|
||||
new_state.upgrade=true;
|
||||
++new_state.shared_count;
|
||||
if(new_state.exclusive_waiting)
|
||||
{
|
||||
--new_state.exclusive_waiting;
|
||||
new_state.exclusive_waiting_blocked=false;
|
||||
}
|
||||
new_state.shared_waiting=0;
|
||||
|
||||
state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state);
|
||||
if(current_state==old_state)
|
||||
{
|
||||
break;
|
||||
}
|
||||
old_state=current_state;
|
||||
}
|
||||
release_waiters(old_state);
|
||||
}
|
||||
// bool try_unlock_upgrade_and_lock()
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
//#ifdef BOOST_THREAD_USES_CHRONO
|
||||
// template <class Rep, class Period>
|
||||
// bool
|
||||
// try_unlock_upgrade_and_lock_for(
|
||||
// const chrono::duration<Rep, Period>& rel_time)
|
||||
// {
|
||||
// return try_unlock_upgrade_and_lock_until(
|
||||
// chrono::steady_clock::now() + rel_time);
|
||||
// }
|
||||
// template <class Clock, class Duration>
|
||||
// bool
|
||||
// try_unlock_upgrade_and_lock_until(
|
||||
// const chrono::time_point<Clock, Duration>& abs_time)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
//#endif
|
||||
|
||||
void unlock_and_lock_shared()
|
||||
{
|
||||
state_data old_state=state;
|
||||
for(;;)
|
||||
{
|
||||
state_data new_state=old_state;
|
||||
new_state.exclusive=false;
|
||||
++new_state.shared_count;
|
||||
if(new_state.exclusive_waiting)
|
||||
{
|
||||
--new_state.exclusive_waiting;
|
||||
new_state.exclusive_waiting_blocked=false;
|
||||
}
|
||||
new_state.shared_waiting=0;
|
||||
|
||||
state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state);
|
||||
if(current_state==old_state)
|
||||
{
|
||||
break;
|
||||
}
|
||||
old_state=current_state;
|
||||
}
|
||||
release_waiters(old_state);
|
||||
}
|
||||
void unlock_upgrade_and_lock_shared()
|
||||
{
|
||||
state_data old_state=state;
|
||||
for(;;)
|
||||
{
|
||||
state_data new_state=old_state;
|
||||
new_state.upgrade=false;
|
||||
if(new_state.exclusive_waiting)
|
||||
{
|
||||
--new_state.exclusive_waiting;
|
||||
new_state.exclusive_waiting_blocked=false;
|
||||
}
|
||||
new_state.shared_waiting=0;
|
||||
|
||||
state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state);
|
||||
if(current_state==old_state)
|
||||
{
|
||||
break;
|
||||
}
|
||||
old_state=current_state;
|
||||
}
|
||||
release_waiters(old_state);
|
||||
}
|
||||
|
||||
};
|
||||
typedef shared_mutex upgrade_mutex;
|
||||
|
||||
}
|
||||
|
||||
#include <boost/config/abi_suffix.hpp>
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,67 @@
|
||||
subroutine decode9w(nfqso,ntol,nsubmode,ss,id2,sync,nsnr,xdt1,f0,decoded)
|
||||
|
||||
! Decode a weak signal in a wide/slow JT9 submode.
|
||||
|
||||
parameter (NSMAX=6827,NZMAX=60*12000)
|
||||
real ss(184,NSMAX) !Symbol spectra at 1/2-symbol steps
|
||||
real ccfred(NSMAX) !Best sync vs frequency
|
||||
real ccfblue(-9:18) !Sync vs time at best frequency
|
||||
real a(5) !Fitted Lorentzian params
|
||||
integer*2 id2(NZMAX) !Raw 16-bit data
|
||||
integer*1 i1SoftSymbols(207) !Binary soft symbols
|
||||
character*22 decoded !Decoded message
|
||||
|
||||
df=12000.0/16384.0 !Bin spacing in ss()
|
||||
nsps=6912 !Samples per 9-FSK symbol
|
||||
tstep=nsps*0.5/12000.0 !Half-symbol duration
|
||||
npts=52*12000
|
||||
limit=10000 !Fano timeout parameter
|
||||
|
||||
ia=max(1,nint((nfqso-ntol)/df)) !Start frequency bin
|
||||
ib=min(NSMAX,nint((nfqso+ntol)/df)) !End frequency bin
|
||||
lag1=-int(2.5/tstep + 0.9999) !Start lag
|
||||
lag2=int(5.0/tstep + 0.9999) !End lag
|
||||
nhsym=184 !Number of half-symbols
|
||||
|
||||
! First sync pass finds approximate Doppler spread; second pass does a
|
||||
! good Lorentzian fit to determine frequency f0.
|
||||
do iter=1,2
|
||||
nadd=3
|
||||
if(iter.eq.2) nadd=2*nint(0.375*a(4)) + 1
|
||||
call sync9w(ss,nhsym,lag1,lag2,ia,ib,ccfred,ccfblue,ipk,lagpk,nadd)
|
||||
s=0.
|
||||
sq=0.
|
||||
ns=0
|
||||
do i=-9,18
|
||||
if(abs(i-lagpk).gt.3) then
|
||||
s=s+ccfblue(i)
|
||||
sq=sq+ccfblue(i)**2
|
||||
ns=ns+1
|
||||
endif
|
||||
enddo
|
||||
base=s/ns
|
||||
rms=sqrt(sq/ns - base**2)
|
||||
sync=(ccfblue(lagpk)-base)/rms
|
||||
xdt0=lagpk*tstep
|
||||
call lorentzian(ccfred(ia),ib-ia+1,a)
|
||||
f0=(ia+a(3))*df
|
||||
enddo
|
||||
ccfblue=(ccfblue-base)/rms
|
||||
|
||||
call softsym9w(id2,npts,xdt0,f0,a(4)*df,nsubmode,xdt1-1.05,snrdb,i1softsymbols)
|
||||
nsnr=nint(snrdb)
|
||||
call jt9fano(i1softsymbols,limit,nlim,decoded)
|
||||
|
||||
!###
|
||||
! do i=-9,18
|
||||
! write(81,3081) i,ccfblue(i)
|
||||
!3081 format(i3,f10.3)
|
||||
! enddo
|
||||
! do i=1,NSMAX
|
||||
! write(82,3082) i*df,ccfred(i)
|
||||
!3082 format(f10.1,e12.3)
|
||||
! enddo
|
||||
!###
|
||||
|
||||
return
|
||||
end subroutine decode9w
|
||||
@@ -1,36 +0,0 @@
|
||||
set (SAMPLE_FILES
|
||||
ISCAT/ISCAT-A/VK7MO_110401_235515.wav
|
||||
ISCAT/ISCAT-B/K0AWU_100714_115000.wav
|
||||
JT4/JT4A/DF2ZC_070926_040700.WAV
|
||||
JT4/JT4F/OK1KIR_141105_175700.WAV
|
||||
JT65/JT65B/DL7UAE_040308_002400.wav
|
||||
JT9+JT65/130610_2343.wav
|
||||
JT9/130418_1742.wav
|
||||
MSK144/160915_113100.wav
|
||||
MSK144/160915_113230.wav
|
||||
QRA64/QRA64C/161113_0111.wav
|
||||
WSPR/150426_0918.wav
|
||||
)
|
||||
|
||||
set (contents_file_name contents_${WSJTX_VERSION_MAJOR}.${WSJTX_VERSION_MINOR}.json)
|
||||
set (contents_file ${CMAKE_CURRENT_BINARY_DIR}/${contents_file_name})
|
||||
set (web_tree ${CMAKE_CURRENT_BINARY_DIR}/web)
|
||||
set_source_files_properties (${contents_file} PROPERTIES GENERATED ON)
|
||||
|
||||
add_custom_command (
|
||||
OUTPUT ${contents_file}
|
||||
COMMAND ${CMAKE_COMMAND} ARGS -Dcontents_file=${contents_file} -DFILES="${SAMPLE_FILES}" -DDEST=${CMAKE_CURRENT_BINARY_DIR} -P make_contents.cmake
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
DEPENDS ${SAMPLE_FILES} make_contents.cmake
|
||||
)
|
||||
|
||||
find_program (RSYNC_EXECUTABLE rsync)
|
||||
add_custom_command (
|
||||
OUTPUT upload.timestamp
|
||||
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${contents_file} ${web_tree}/samples/${contents_file_name}
|
||||
COMMAND ${RSYNC_EXECUTABLE} ARGS -avz --progress ${CMAKE_CURRENT_BINARY_DIR}/web/samples ${PROJECT_SAMPLES_UPLOAD_DEST}
|
||||
COMMAND ${CMAKE_COMMAND} ARGS -E touch upload.timestamp
|
||||
DEPENDS ${contents_file}
|
||||
COMMENT "Uploading WSJT-X samples to web server"
|
||||
)
|
||||
add_custom_target (upload-samples DEPENDS upload.timestamp)
|
||||
@@ -1,329 +0,0 @@
|
||||
_WSJT-X_ v1.7 introduces a number of new features designed for use
|
||||
on the VHF and higher bands. These features now include:
|
||||
|
||||
- *JT4*, a mode particularly useful for EME on the microwave bands
|
||||
|
||||
- *JT9* fast modes, useful for scatter propagation on VHF bands
|
||||
|
||||
- *QRA64*, a mode for EME using a "`Q-ary Repeat Accumulate`" code,
|
||||
a low-density parity-check (LDPC) code using a 64-character symbol
|
||||
alphabet
|
||||
|
||||
- *MSK144*, a mode for meteor scatter using a binary LDPC code and
|
||||
Offset Quadrature Phase-Shift Keying (OQPSK). The resulting waveform
|
||||
is sometimes called Minimum Shift Keying (MSK).
|
||||
|
||||
- *ISCAT*, intended for aircraft scatter and other types of scatter
|
||||
propagation
|
||||
|
||||
- *Echo* mode, for detecting and measuring your own lunar echoes
|
||||
|
||||
- *Doppler tracking*, which becomes increasingly important for EME
|
||||
on bands above 1.2 GHz.
|
||||
|
||||
- *Auto-sequencing* of transmitted messages for the fast modes with
|
||||
forward error control
|
||||
|
||||
[[VHF_SETUP]]
|
||||
=== VHF Setup
|
||||
|
||||
To activate the VHF-and-up features:
|
||||
|
||||
- On the *Settings | General* tab check *Enable VHF/UHF/Microwave
|
||||
features* and *Single decode*.
|
||||
|
||||
- For EME, check *Decode at t = 52 s* to allow for extra path delay on
|
||||
received signals.
|
||||
|
||||
- If you will use automatic Doppler tracking and your radio accepts
|
||||
frequency-setting commands while transmitting, check *Allow Tx
|
||||
frequency changes while transmitting*. Transceivers known to permit
|
||||
such changes include the IC-735, IC-756 Pro II, IC-910-H, FT-847,
|
||||
TS-590S, TS-590SG, TS-2000 (with Rev 9 or later firmware upgrade),
|
||||
Flex 1500 and 5000, HPSDR, Anan-10, Anan-100, and KX3. To gain full
|
||||
benefit of Doppler tracking your radio should allow frequency changes
|
||||
under CAT control in 1 Hz steps.
|
||||
|
||||
NOTE: If your radio does not accept commands to change frequency
|
||||
while transmitting, Doppler tracking will be approximated with a
|
||||
single Tx frequency adjustment before a transmission starts, using a
|
||||
value computed for the middle of the Tx period.
|
||||
|
||||
- On the *Radio* tab select *Split Operation* (use either *Rig* or
|
||||
*Fake It*; you may need to experiment with both options to find one
|
||||
that works best with your radio).
|
||||
|
||||
- On the right side of the main window select *Tab 1* to present the
|
||||
traditional format for entering and choosing Tx messages.
|
||||
|
||||
The main window will reconfigure itself as necessary to display
|
||||
controls supporting the features of each mode.
|
||||
|
||||
- If you are using transverters, set appropriate frequency offsets on
|
||||
the *Settings | Frequencies* tab. Offset is defined as (transceiver
|
||||
dial reading) minus (on-the-air frequency). For example, when using a
|
||||
144 MHz radio at 10368 MHz, *Offset (MHz)* = (144 - 10368) =
|
||||
-10224.000. If the band is already in the table, you can edit the
|
||||
offset by double clicking on the offset field itself. Otherwise a new
|
||||
band can be added by right clicking in the table and selecting
|
||||
*Insert*.
|
||||
|
||||
image::Add_station_info.png[align="center",alt="Station information"]
|
||||
|
||||
- On the *View* menu, select *Astronomical data* to display a window
|
||||
with important information for tracking the Moon and performing
|
||||
automatic Doppler control. The right-hand portion of the window
|
||||
becomes visible when you check *Doppler tracking*.
|
||||
|
||||
image::Astronomical_data.png[align="center",alt="Astronomical data"]
|
||||
|
||||
Three different types of Doppler tracking are provided:
|
||||
|
||||
- Select *Full Doppler to DX Grid* if you know your QSO partner's locator
|
||||
and he/she will not be using any Doppler control.
|
||||
|
||||
- Select *Receive only* to enable EME Doppler tracking of your receive
|
||||
frequency to a specific locator. Your Tx frequency will remain fixed.
|
||||
|
||||
- Select *Constant frequency on Moon* to correct for your own one-way
|
||||
Doppler shift to or from the Moon. If your QSO partner does the same
|
||||
thing, both stations will have the required Doppler compensation.
|
||||
Moreover, anyone else using this option will hear both of you
|
||||
without the need for manual frequency changes.
|
||||
|
||||
- See <<ASTRODATA,Astronomical Data>> for details on the quantities
|
||||
displayed in this window.
|
||||
|
||||
=== JT4
|
||||
|
||||
JT4 is designed especially for EME on the microwave bands, 2.3 GHz and
|
||||
above.
|
||||
|
||||
- Select *JT4* from the *Mode* menu. The central part of the main
|
||||
window will look something like this:
|
||||
|
||||
image::VHF_controls.png[align="center",alt="VHF Controls"]
|
||||
|
||||
- Select the desired *Submode*, which determines the spacing of
|
||||
transmitted tones. Wider spacings are used on the higher microwave
|
||||
bands to allow for larger Doppler spreads. For example, submode JT4F
|
||||
is generally used for EME on the 5.7 and 10 GHz bands.
|
||||
|
||||
- For EME QSOs some operators use short-form JT4 messages consisting
|
||||
of a single tone. To activate automatic generation of these messages,
|
||||
check the box labeled *Sh*.
|
||||
|
||||
- Select *Deep* from the *Decode* menu. You may also choose to
|
||||
*Enable averaging* over successive transmissions and/or *Enable deep
|
||||
search* (correlation decoding).
|
||||
|
||||
image::decode-menu.png[align="center",alt="Decode Menu"]
|
||||
|
||||
The following screen shot shows one transmission from a 10 GHz EME
|
||||
QSO using submode JT4F.
|
||||
|
||||
image::JT4F.png[align="center",alt="JT4F"]
|
||||
|
||||
=== JT65
|
||||
|
||||
In many ways JT65 operation on VHF and higher bands is similar to HF
|
||||
usage, but a few important differences should be noted. Typical
|
||||
VHF/UHF operation involves only a single signal (or perhaps two or
|
||||
three) in the receiver passband. You may find it best to check
|
||||
*Single decode* on the *Settings -> General* tab. There will be
|
||||
little need for *Two pass decoding* on the *Advanced* tab. With VHF
|
||||
features enabled the JT65 decoder will respond to special message
|
||||
formats often used for EME: the OOO signal report and two-tone
|
||||
shorthand messages for RO, RRR, and 73. These messages are always
|
||||
enabled for reception; they will be automatically generated for
|
||||
transmission if you check the shorthand message box *Sh*.
|
||||
|
||||
Be sure to check *Deep* on the *Decode* menu; you may optionally
|
||||
include *Enable averaging* and *Deep search*.
|
||||
|
||||
The following screen shot shows three transmissions from a 144 MHz EME
|
||||
QSO using submode JT65B and shorthand messages. Take note of the
|
||||
colored tick marks on the Wide Graph frequency scale. The green
|
||||
marker at 1220 Hz indicates the selected QSO frequency (the frequency
|
||||
of the JT65 Sync tone) and the *F Tol* range. A green tick at 1575 Hz
|
||||
marks the frequency of the highest JT65 data tone. Orange markers
|
||||
indicate the frequency of the upper tone of the two-tone signals for
|
||||
RO, RRR, and 73.
|
||||
|
||||
image::JT65B.png[align="center",alt="JT65B"]
|
||||
|
||||
=== QRA64
|
||||
|
||||
QRA64 is an experimental mode in Version 1.7 of _WSJT-X_. The mode is
|
||||
designed especially for EME on VHF and higher bands; its operation is
|
||||
generally similar to JT65. The following screen shot shows an example
|
||||
of a QRA64C transmission from DL7YC recorded at G3WDG over the EME
|
||||
path at 24 GHz. Doppler spread on the path was 78 Hz, so although the
|
||||
signal is reasonably strong its tones are broadened enough to make
|
||||
them hard to see on the waterfall. The red curve shows that the
|
||||
decoder has achieved synchronization with a signal at approximately
|
||||
967 Hz.
|
||||
|
||||
image::QRA64.png[align="center",alt="QRA64"]
|
||||
|
||||
The QRA64 decoder makes no use of a callsign database. Instead, it
|
||||
takes advantage of _a priori_ (AP) information such as one's own
|
||||
callsign and the encoded form of message word `CQ`. In normal usage,
|
||||
as a QSO progresses the available AP information increases to include
|
||||
the callsign of the station being worked and perhaps also his/her
|
||||
4-digit grid locator. The decoder always begins by attempting to
|
||||
decode the full message using no AP information. If this attempt
|
||||
fails, additional attempts are made using available AP information to
|
||||
provide initial hypotheses about the message content. At the end of
|
||||
each iteration the decoder computes the extrinsic probability of the
|
||||
most likely value for each of the message's 12 six-bit information
|
||||
symbols. A decode is declared only when the total probability for all
|
||||
12 symbols has converged to an unambiguous value very close to 1.
|
||||
|
||||
TIP: In _WSJT-X_ Version 1.7 QRA64 is different from JT65 in that the
|
||||
decoder attempts to find and decode only a single signal in the
|
||||
receiver passband. If many signals are present you may be able to
|
||||
decode them by double-clicking on the lowest tone of each one in the
|
||||
waterfall. A multi-decoder like those for JT65 and JT9 has not
|
||||
yet been written.
|
||||
|
||||
=== ISCAT
|
||||
|
||||
ISCAT is a useful mode for signals that are weak but more or less
|
||||
steady in amplitude over several seconds or longer. Aircraft scatter
|
||||
at 10 GHz is a good example. ISCAT messages are free-format and may
|
||||
have any length from 1 to 28 characters. This protocol includes no
|
||||
error-correction facility.
|
||||
|
||||
=== MSK144
|
||||
|
||||
Meteor-scatter QSOs can be made any time on the VHF bands at distances
|
||||
up to about 2100 km (1300 miles). Completing a QSO takes longer in
|
||||
the evening than in the morning, longer at higher frequencies, and
|
||||
longer at distances close to the upper limit. But with patience, 100
|
||||
Watts or more, and a single yagi it can usually be done. The
|
||||
following screen shot shows two 15-second MSK144 transmissions from
|
||||
W5ADD during a 50 MHz QSO with K1JT, at a distance of about 1800 km
|
||||
(1100 mi). The decoded segments have been encircled on the *Fast
|
||||
Graph* spectral display.
|
||||
|
||||
image::MSK144.png[align="center",alt="MSK144"]
|
||||
|
||||
Unlike other _WSJT-X_ modes, the MSK144 decoder operates in real time
|
||||
during the reception sequence. Decoded messages will appear on your
|
||||
screen almost as soon as you hear them.
|
||||
|
||||
To configure _WSJT-X_ for MSK144 operation:
|
||||
|
||||
- Select *MSK144* from the *Mode* menu.
|
||||
|
||||
- Select *Fast* from the *Decode* menu.
|
||||
|
||||
- Set the audio receiving frequency to *Rx 1500 Hz*.
|
||||
|
||||
- Set frequency tolerance to *F Tol 100*.
|
||||
|
||||
- Set the *T/R* sequence duration to 15 s.
|
||||
|
||||
- To match decoding depth to your computer's capability, click
|
||||
*Monitor* (if it's not already green) to start a receiving sequence.
|
||||
Observe the percentage figure displayed on the _Receiving_ label in
|
||||
the Status Bar:
|
||||
|
||||
image::Rx_pct_MSK144.png[align="center",alt="MSK144 Percent CPU"]
|
||||
|
||||
- The displayed number (here 17%) indicates the fraction of available
|
||||
time being used for execution of the MSK144 real-time decoder. If
|
||||
this number is well below 100% you may increase the decoding depth
|
||||
from *Fast* to *Normal* or *Deep*, and increase *F Tol* from 100 to
|
||||
200 Hz.
|
||||
|
||||
NOTE: Most modern multi-core computers can easily handle the optimum
|
||||
parameters *Deep* and *F Tol 200*. Older and slower machines may not
|
||||
be able to keep up at these settings; at the *Fast* and *Normal*
|
||||
settings there will be a small loss in decoding capability (relative
|
||||
to *Deep*) for the weakest pings.
|
||||
|
||||
- T/R sequences of 15 seconds or less requires selecting your
|
||||
transmitted messages very quickly. Check *Auto Seq* to have the
|
||||
computer make the necessary decisions automatically, based on the
|
||||
messages received.
|
||||
|
||||
- For operation at 144 MHz or above you may find it helpful to use
|
||||
short-format *Sh* messages for Tx3, Tx4, and Tx5. These messages are
|
||||
20 ms long, compared with 72 ms for full-length MSK144 messages.
|
||||
Their information content is a 12-bit hash of the two callsigns,
|
||||
rather than the callsigns themselves, plus a 4-bit numerical report,
|
||||
acknowledgment (RRR), or sign-off (73). Only the intended recipient
|
||||
can decode short-messages. They will be displayed with the callsigns
|
||||
enclosed in <> angle brackets, as in the following model QSO
|
||||
|
||||
CQ K1ABC FN42
|
||||
K1ABC W9XYZ EN37
|
||||
W9XYZ K1ABC +02
|
||||
<K1ABC W9XYZ> R+03
|
||||
<W9XYZ K1ABC> RRR
|
||||
<K1ABC W9XYZ> 73
|
||||
|
||||
|
||||
NOTE: There is little or no advantage to using MSK144 *Sh*
|
||||
messages at 50 or 70 MHz. At these frequencies, most pings are long
|
||||
enough to support standard messages -- which have the advantage of
|
||||
being readable by anyone listening in.
|
||||
|
||||
- A special *Contest Mode* for MSK144 can be activated by checking a
|
||||
box on the *Settings | Advanced* tab. This mode is configured
|
||||
especially for VHF contests in which four-character grid locators are
|
||||
the required exchange. When *Contest Mode* is active, the standard QSO
|
||||
sequence looks like this:
|
||||
|
||||
CQ K1ABC FN42
|
||||
K1ABC W9XYZ EN37
|
||||
W9XYZ K1ABC R FN42
|
||||
K1ABC W9XYZ RRR
|
||||
W9XYZ K1ABC 73
|
||||
|
||||
In contest circumstances K1ABC might choose to call CQ again rather
|
||||
than sending 73 for his third transmission.
|
||||
|
||||
=== Echo Mode
|
||||
|
||||
*Echo* mode allows you to make sensitive measurements of your own
|
||||
lunar echoes even when they are too weak to be heard. Select *Echo*
|
||||
from the *Mode* menu, aim your antenna at the moon, pick a clear
|
||||
frequency, and toggle click *Tx Enable*. _WSJT-X_ will then cycle
|
||||
through the following loop every 6 seconds:
|
||||
|
||||
1. Transmit a 1500 Hz fixed tone for 2.3 s
|
||||
2. Wait about 0.2 s for start of the return echo
|
||||
3. Record the received signal for 2.3 s
|
||||
4. Analyze, average, and display the results
|
||||
5. Repeat from step 1
|
||||
|
||||
To make a sequence of echo tests:
|
||||
|
||||
- Select *Echo* from the *Mode* menu.
|
||||
|
||||
- Check *Doppler tracking* and *Constant frequency on the Moon* on the
|
||||
Astronomical Data window.
|
||||
|
||||
- Be sure that your rig control has been set up for _Split Operation_,
|
||||
using either *Rig* or *Fake It* on the *Settings | Radio* tab.
|
||||
|
||||
- Click *Enable Tx* on the main window to start a sequence of 6-second
|
||||
cycles.
|
||||
|
||||
- _WSJT-X_ calculates and compensates for Doppler shift automatically.
|
||||
As shown in the screen shot below, when proper Doppler corrections
|
||||
have been applied your return echo should always appear at the center
|
||||
of the plot area on the Echo Graph window.
|
||||
|
||||
image::echo_144.png[align="center",alt="Echo 144 MHz"]
|
||||
|
||||
=== VHF+ Sample Files
|
||||
|
||||
Sample recordings typical of QSOs using the VHF/UHF/Microwave modes
|
||||
and features of _WSJT-X_ are available for
|
||||
<<DOWNLOAD_SAMPLES,download>>. New users of the VHF-and-up features
|
||||
are strongly encouraged to practice decoding the signals in these
|
||||
files.
|
||||
@@ -0,0 +1,182 @@
|
||||
// -*- Mode: C++ -*-
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Some code in this file and accompanying files is based on work by
|
||||
// Moe Wheatley, AE4Y, released under the "Simplified BSD License".
|
||||
// For more details see the accompanying file LICENSE_WHEATLEY.TXT
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef PLOTTER_H
|
||||
#define PLOTTER_H
|
||||
|
||||
#ifdef QT5
|
||||
#include <QtWidgets>
|
||||
#else
|
||||
#include <QtGui>
|
||||
#endif
|
||||
#include <QFrame>
|
||||
#include <QImage>
|
||||
#include <QVector>
|
||||
#include <cstring>
|
||||
|
||||
#define VERT_DIVS 7 //specify grid screen divisions
|
||||
#define HORZ_DIVS 20
|
||||
|
||||
extern bool g_single_decode;
|
||||
|
||||
class QAction;
|
||||
|
||||
class CPlotter : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CPlotter(QWidget *parent = 0);
|
||||
~CPlotter();
|
||||
|
||||
QSize minimumSizeHint() const;
|
||||
QSize sizeHint() const;
|
||||
|
||||
void draw(float swide[], bool bScroll, bool bRed); //Update the waterfall
|
||||
void replot();
|
||||
void SetRunningState(bool running);
|
||||
void setPlotZero(int plotZero);
|
||||
int plotZero();
|
||||
void setPlotGain(int plotGain);
|
||||
int plotGain();
|
||||
int plot2dGain();
|
||||
void setPlot2dGain(int n);
|
||||
int plot2dZero();
|
||||
void setPlot2dZero(int plot2dZero);
|
||||
void setStartFreq(int f);
|
||||
int startFreq();
|
||||
int plotWidth();
|
||||
void UpdateOverlay();
|
||||
void setDataFromDisk(bool b);
|
||||
void setRxRange(int fMin);
|
||||
void setBinsPerPixel(int n);
|
||||
int binsPerPixel();
|
||||
void setWaterfallAvg(int n);
|
||||
void setRxFreq(int n);
|
||||
void DrawOverlay();
|
||||
int rxFreq();
|
||||
void setFsample(int n);
|
||||
void setNsps(int ntrperiod, int nsps);
|
||||
void setTxFreq(int n);
|
||||
void setMode(QString mode);
|
||||
void setSubMode(int n);
|
||||
void setModeTx(QString modeTx);
|
||||
void SetPercent2DScreen(int percent);
|
||||
int Fmax();
|
||||
void setDialFreq(double d);
|
||||
void setCurrent(bool b) {m_bCurrent = b;}
|
||||
bool current() const {return m_bCurrent;}
|
||||
void setCumulative(bool b) {m_bCumulative = b;}
|
||||
bool cumulative() const {return m_bCumulative;}
|
||||
void setLinearAvg(bool b) {m_bLinearAvg = b;}
|
||||
bool linearAvg() const {return m_bLinearAvg;}
|
||||
void setBreadth(qint32 w) {m_w = w;}
|
||||
qint32 breadth() const {return m_w;}
|
||||
float fSpan() const {return m_fSpan;}
|
||||
void setColours(QVector<QColor> const& cl);
|
||||
void setFlatten(bool b1, bool b2);
|
||||
void setTol(int n);
|
||||
void setRxBand(QString band);
|
||||
void setReference(bool b) {m_bReference = b;}
|
||||
bool Reference() const {return m_bReference;}
|
||||
void drawRed(int ia, int ib, float swide[]);
|
||||
void setVHF(bool bVHF);
|
||||
void setRedFile(QString fRed);
|
||||
bool scaleOK () const {return m_bScaleOK;}
|
||||
signals:
|
||||
void freezeDecode1(int n);
|
||||
void setFreq1(int rxFreq, int txFreq);
|
||||
|
||||
protected:
|
||||
//re-implemented widget event handlers
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
void resizeEvent(QResizeEvent* event) override;
|
||||
void mouseReleaseEvent (QMouseEvent * event) override;
|
||||
void mouseDoubleClickEvent (QMouseEvent * event) override;
|
||||
|
||||
private:
|
||||
|
||||
void MakeFrequencyStrs();
|
||||
int XfromFreq(float f);
|
||||
float FreqfromX(int x);
|
||||
|
||||
QAction * m_set_freq_action;
|
||||
|
||||
bool m_bScaleOK;
|
||||
bool m_bCurrent;
|
||||
bool m_bCumulative;
|
||||
bool m_bLinearAvg;
|
||||
bool m_bReference;
|
||||
bool m_bReference0;
|
||||
bool m_bVHF;
|
||||
|
||||
float m_fSpan;
|
||||
|
||||
qint32 m_plotZero;
|
||||
qint32 m_plotGain;
|
||||
qint32 m_plot2dGain;
|
||||
qint32 m_plot2dZero;
|
||||
qint32 m_binsPerPixel;
|
||||
qint32 m_waterfallAvg;
|
||||
qint32 m_w;
|
||||
qint32 m_Flatten;
|
||||
qint32 m_nSubMode;
|
||||
qint32 m_ia;
|
||||
qint32 m_ib;
|
||||
|
||||
QPixmap m_WaterfallPixmap;
|
||||
QPixmap m_2DPixmap;
|
||||
QPixmap m_ScalePixmap;
|
||||
QPixmap m_OverlayPixmap;
|
||||
|
||||
QSize m_Size;
|
||||
QString m_Str;
|
||||
QString m_HDivText[483];
|
||||
QString m_mode;
|
||||
QString m_modeTx;
|
||||
QString m_rxBand;
|
||||
QString m_redFile;
|
||||
|
||||
bool m_Running;
|
||||
bool m_paintEventBusy;
|
||||
bool m_dataFromDisk;
|
||||
bool m_bReplot;
|
||||
|
||||
double m_fftBinWidth;
|
||||
double m_dialFreq;
|
||||
double m_xOffset;
|
||||
|
||||
float m_sum[2048];
|
||||
|
||||
qint32 m_dBStepSize;
|
||||
qint32 m_FreqUnits;
|
||||
qint32 m_hdivs;
|
||||
qint32 m_line;
|
||||
qint32 m_fSample;
|
||||
qint32 m_xClick;
|
||||
qint32 m_freqPerDiv;
|
||||
qint32 m_nsps;
|
||||
qint32 m_Percent2DScreen;
|
||||
qint32 m_Percent2DScreen0;
|
||||
qint32 m_h;
|
||||
qint32 m_h1;
|
||||
qint32 m_h2;
|
||||
qint32 m_TRperiod;
|
||||
qint32 m_rxFreq;
|
||||
qint32 m_txFreq;
|
||||
qint32 m_fMin;
|
||||
qint32 m_fMax;
|
||||
qint32 m_startFreq;
|
||||
qint32 m_tol;
|
||||
qint32 m_j;
|
||||
|
||||
char m_sutc[6];
|
||||
};
|
||||
|
||||
extern QVector<QColor> g_ColorTbl;
|
||||
|
||||
#endif // PLOTTER_H
|
||||
Reference in New Issue
Block a user