9 #ifndef GwNavRuntime_VisualDebugServer_H
10 #define GwNavRuntime_VisualDebugServer_H
20 #include "../visualsystem/idisplaylistbuilder.h"
29 class ServerStatusChangedCallback;
31 class MessageAggregatedBlob;
32 class MessageBlobHandler;
33 class BlobFieldsStore;
41 class VisualDebugAttributesManager;
46 class VisualDebugServerConfig
50 static
KyUInt32 DefaultServerPort() {
return 4888; }
51 static KyUInt32 DefaultBroadcastPort() {
return 4887; }
91 #if defined(KY_OS_WIIU)
132 void SetWaitOnStart(
WaitOnStart waitOnStart) { m_waitOnStart = waitOnStart; }
145 void SetServerName(
const char* serverName) {
m_serverName = String(serverName); }
202 #if defined(KY_BUILD_SHIPPING) || !defined(KY_ENABLE_SOCKETS) || !defined(KY_ENABLE_THREADS)
203 # define KY_DISABLE_VISUALDEBUGSERVER
206 #ifndef KY_DISABLE_VISUALDEBUGSERVER
238 bool IsStarted()
const {
return m_isStarted; }
247 void SendStats(
const FloatStat& timeStat,
const char* groupName);
248 void SendStats(
const char* statName,
const FloatStat& timeStat,
const char* groupName);
254 void SendUInt32(
const char* statName,
const KyUInt32 value,
const char* groupName);
255 void SendInt32(
const char* statName,
const KyInt32 value,
const char* groupName);
256 void SendFloat32(
const char* statName,
const KyFloat32 value,
const char* groupName);
257 void SendString(
const char* statName,
const char* value,
const char* groupName);
261 void SendGameCamera(
const Vec3f& cameraPos,
const Vec3f& cameraLookAtPos,
const Vec3f& cameraUp,
KyFloat32 fovInDegrees);
262 void SendGameCameraAttitude(
const Vec3f& cameraPos,
const Vec3f& cameraRight,
const Vec3f& cameraUp,
const Vec3f& cameraFront,
KyFloat32 fovInDegrees);
266 void PauseMessageProcessing() { m_messageProcessingIsPaused =
true; }
267 void ResumeMessageProcessing() { m_messageProcessingIsPaused =
false; }
273 KyResult AggregateMessage(Ptr<BaseBlobHandler> handlerPtr);
277 KyResult SetupMessageRegistry(MessageReceiverRegistry* receiverRegistry);
281 void ClearStatistics();
282 void SendInternalStatistics();
284 void SendStatGroups();
285 VisualDebugStatGroup* GetStatGroup(
const char* groupName);
286 VisualDebugStatGroup* GetOrCreateStatGroup(
const char* groupName);
289 void OnDisconnection();
292 KyResult OnConnectionUnsafeCallback();
293 KyResult OnDisconnectionUnsafeCallback();
295 void UpdateThreadMgr(
bool& out_needToWait);
300 void InitAttributesManager();
301 void CreateProfilingAttributes();
302 void CreateAdvancedProfilingAttributes();
303 void UpdateProfilingAttributes();
304 void UpdateAdvancedProfilingAttributes();
307 void DisableSynchronization(
bool disabled) { m_synchronizationStepDisabled = disabled; }
322 KyResult ReStart() {
return Start(m_config); }
346 const KyUInt32 blobType = T::GetBlobTypeId();
347 Ptr<BaseBlobHandler> blobHandler = m_handlerRegistry.Get(blobType);
350 blobHandler = *KY_NEW BlobHandler<T>;
351 m_handlerRegistry.SetVal(blobType, blobHandler);
354 blobBuilder.Build((BlobHandler<T>&)*blobHandler);
355 return this->AggregateMessage(blobHandler);
381 void SetThreadId(ThreadId threadId) { m_operatingThreadId = threadId; }
384 ThreadId
GetThreadId()
const {
return m_operatingThreadId; }
397 void WaitForEmptiedSendQueue();
403 void OnSynchronizationDone() { m_isSynchronized =
true; }
405 Net::AMP::ThreadMgr*
GetThreadMgr() {
return m_socketThreadMgr.GetPtr(); }
406 const Net::AMP::ThreadMgr*
GetThreadMgr()
const {
return m_socketThreadMgr.GetPtr(); }
409 MemoryHeap*
GetHeap() {
return Memory::GetHeapByAddress(m_socketThreadMgr.GetPtr()); }
414 UserBlobRegistry<IDisplayListBuilder>* GetDisplayListBuilderRegistry() {
return m_displayListBuilderRegistry; }
418 VisualDebugServerConfig m_config;
421 Profiler* m_gameFrameTimeProfiler;
422 bool m_synchronizationStepDisabled;
426 bool m_isConnectionEstablished;
427 bool m_isSynchronized;
429 bool m_wasDisconnected;
430 ThreadId m_operatingThreadId;
433 Ptr<Net::AMP::ThreadMgr> m_socketThreadMgr;
434 Ptr<Net::AMP::DiscardMessageHandler> m_msgDiscarder;
435 Ptr<MessageBlobHandler> m_msgBlobHandler;
436 SocketDispatcherFactory* m_socketFactory;
439 friend class ServerStatusChangedCallback;
440 Ptr<ServerStatusChangedCallback> m_statusCallback;
441 Event m_connectedEvent;
444 typedef UserPtrBlobRegistry<BaseBlobHandler> BlobHandlerRegistry;
445 BlobHandlerRegistry m_handlerRegistry;
446 MessageAggregatedBlob* m_aggregatedBlobMsg;
449 List<Net::AMP::Message> m_msgList;
450 Kaim::UInt32 m_msgListSize;
462 UserBlobRegistry<SentBlobTypeStats> m_sentBlobTypeStatsRegistry;
465 bool m_enableAdvancedInternalStatistics;
467 VisualDebugAttributesManager* m_visualDebugAttributesManager;
471 bool m_messageProcessingIsPaused;
474 Ptr<UserBlobRegistry<IDisplayListBuilder> > m_displayListBuilderRegistry;
488 class VisualDebugServer :
public DisabledVisualDebugServer
495 #endif // GwNavRuntime_VisualDebugServer_H
DisconnectionMode
Define how to detect disconnections.
Definition: visualdebugserver.h:71
Base interface for a class that opens a file on disk.
Definition: fileopener.h:35
DisconnectionMode m_disconnectionMode
Define how to detect disconnections.
Definition: visualdebugserver.h:212
const char * m_localFileName
mandatory if m_mode = Mode_UseLocalFile.
Definition: visualdebugserver.h:186
KyInt32 KyResult
Defines a type that can be returned by methods or functions in the Gameware Navigation SDK to indicat...
Definition: types.h:254
KyUInt32 GetFrameIndex() const
Retrieves the number of the current frame.
Definition: visualdebugserver.h:466
static KyUInt32 GetInfiniteWaitDelay()
Defines a special value that can be passed to VisualDebugServer::WaitWhileEstablishingConnection() in...
Definition: visualdebugserver.h:387
KyResult Send(BaseBlobBuilder< T > &blobBuilder)
Sends a blob from a BlobBuilder, the blob will be built into the message, no copy occurs...
Definition: visualdebugserver.h:407
use socket errors to detect disconnections (recommended)
Definition: visualdebugserver.h:72
KyResult HandleMessage(Ptr< Net::AMP::Message > msg)
Handle the given message.
KyUInt32 m_expectedKiloBytesPerFrame
Specifies the expected amount of memory to allocate per frame. Used to define size of a message...
Definition: visualdebugserver.h:203
String m_serverName
Associate a name to the server to ease identification of this server when connecting from the Navigat...
Definition: visualdebugserver.h:218
Writes all visual debug information to a file on the platform.
Definition: visualdebugserver.h:61
MemoryHeap * GetHeap()
Definition: visualdebugserver.h:475
void SetAdvancedInternalStatistics(bool enable)
Enable additional statistics to be sent. These statistics are mainly useful for internal development/...
Definition: visualdebugserver.h:443
bool IsConnected()
Tells if it's worth calling the Send* functions.
Definition: visualdebugserver.h:276
void Flush()
Effectively, send/write all messages (exactly they are passed to the OS).
void SetThreadId(ThreadId threadId)
Set the ThreadId that Send and Update are supposed to be called from. By default, assigned when calli...
Definition: visualdebugserver.h:446
int KyInt32
Type used internally to represent a 32-bit integer.
Definition: types.h:35
#define KY_NULL
Null value.
Definition: types.h:247
KyInt32 m_localFileMegaBytesLimit
The size limit of the local file, when this limit is reached, the VisualDebugServer disconnects...
Definition: visualdebugserver.h:192
KyResult HandleAllReceivedMessages()
Get and handle all received messages based on the MessageReceiverRegistry parameter provided to Start...
void SetSimulationTime(KyFloat32 simulationTimeInSeconds)
Usually, set by Kaim::World with the given simulation time passed to Kaim::World::Update().
Definition: visualdebugserver.h:401
Mode m_mode
The visual debug information destination mode.
Definition: visualdebugserver.h:157
KyUInt32 m_maximumMegaBytes
Specifies the maximum amount of memory this VisualDebugServer is allowed to allocate for creating mes...
Definition: visualdebugserver.h:201
void SetMemoryConsumption(KyUInt32 expectedKiloBytesPerFrame, KyUInt32 maximumMegaBytesToUse)
Define memory limitations for the VisualDebugServer.
Definition: visualdebugserver.h:140
Ptr< Net::AMP::Message > GetNextReceivedMessage()
Return next received message.
bool CanSafelyOperate() const
Check if it is safe to call Update and Send functions.
Definition: visualdebugserver.h:452
void NewFrame()
Indicates the beginning of a new game frame.
Configure the VisualDebugServer.
Definition: visualdebugserver.h:48
A group of Key / valuetype / arrayof values, where the keys and types are created once...
Definition: visualdebugattributes.h:109
KyUInt32 m_broadcastPort
The port used to broadcast the existence of this server.
Definition: visualdebugserver.h:169
FloatStat maintains current, average, min, max statistics in a sliding window of frames.
Definition: floatstat.h:23
RunMode
Determine how the data are sent.
Definition: visualdebugserver.h:77
Definition: gamekitcrowddispersion.h:20
run in current thread (recommended for most platforms)
Definition: visualdebugserver.h:78
bool WaitWhileEstablishingConnection(KyUInt32 maxDelayMilliseconds)
Wait for the connection to be established (pass GetInfiniteWaitDelay() to wait infinitely if no conne...
Sends visual debug information to the NavigationLab over the Network.
Definition: visualdebugserver.h:60
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
bool IsStarted() const
Definition: visualdebugserver.h:273
The VisualDebugServer manages the sending of data to clients.
Definition: visualdebugserver.h:254
Net::AMP::ThreadMgr * GetThreadMgr()
Accessor to the internal ThreadMgr.
Definition: visualdebugserver.h:471
KyUInt32 m_serverPort
The port used to listen to NavigationLab incoming connections.
Definition: visualdebugserver.h:166
use secondary threads for sending blobs
Definition: visualdebugserver.h:79
bool IsConnectionEstablished() const
Indicates whether the ThreadManager has established a connection to a network socket or if the localF...
FileOpenerBase * m_localFileOpener
if m_localFileOpener is NULL, DefaultFileOpener will be used
Definition: visualdebugserver.h:189
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
MessageReceiverRegistry * m_navigationLabCommandHandlers
Optional, handles the commands that come from the Gameware Navigation from the Network.
Definition: visualdebugserver.h:177
Mode
Enumerates the visual debug information destination.
Definition: visualdebugserver.h:59
bool IsSynchronizing()
Tells if currently synchronizing, in this state Send should only be called to send synchronization da...
Definition: visualdebugserver.h:460
KyResult HandleNextReceivedMessage()
Start will block until a connection occurs.
Definition: visualdebugserver.h:67
RunMode m_runMode
Define how to run the server, either directly in the current thread (recommended), or using secondary threads.
Definition: visualdebugserver.h:215
ThreadId GetThreadId() const
Get the ThreadId that Send and Update are supposed to be called from.
Definition: visualdebugserver.h:449
Start won't wait for a connection.
Definition: visualdebugserver.h:66
void UseNavigationLab(KyUInt32 serverPort=DefaultServerPort(), KyUInt32 broadcastPort=DefaultBroadcastPort(), MessageReceiverRegistry *navigationLabCommandHandlers=0)
Reduce chances of selecting conflicting ports by looking at :
Definition: visualdebugserver.h:115
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43
This class defines a three-dimensional vector whose coordinates are stored using floating-point numbe...
Definition: vec3f.h:23
use heartbeat messages to detect disconnections (disconnection can occur when breakpointing) ...
Definition: visualdebugserver.h:73
WaitOnStart
Define the behavior for VisualDebugServer::Start.
Definition: visualdebugserver.h:65