move logging to central module. Fix orientation bug. Fix message echo bug.
parent
2ffa91d72a
commit
af29f4083f
|
@ -108,8 +108,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
||||||
//m_statsTimer.Elapsed += new System.Timers.ElapsedEventHandler(StatsTimerElapsed);
|
//m_statsTimer.Elapsed += new System.Timers.ElapsedEventHandler(StatsTimerElapsed);
|
||||||
m_sysConfig = sysConfig;
|
m_sysConfig = sysConfig;
|
||||||
|
|
||||||
logEnabled = m_sysConfig.GetBoolean("LogEnabled", false);
|
SceneToPhysEngineSyncServer.logEnabled = m_sysConfig.GetBoolean("LogEnabled", false);
|
||||||
logDir = m_sysConfig.GetString("LogDir", ".");
|
SceneToPhysEngineSyncServer.logDir = m_sysConfig.GetString("LogDir", ".");
|
||||||
|
|
||||||
//assume we are connecting to the whole scene as one big quark
|
//assume we are connecting to the whole scene as one big quark
|
||||||
m_subscribedQuarks = new QuarkSubsriptionInfo(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize);
|
m_subscribedQuarks = new QuarkSubsriptionInfo(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize);
|
||||||
|
@ -258,7 +258,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
||||||
m_client.Client.Close();
|
m_client.Client.Close();
|
||||||
m_client.Close();
|
m_client.Close();
|
||||||
}
|
}
|
||||||
LogMessageClose();
|
SceneToPhysEngineSyncServer.PhysLogMessageClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Listen for messages from a RegionSyncServer
|
// Listen for messages from a RegionSyncServer
|
||||||
|
@ -301,14 +301,12 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
||||||
// Send a message to a single connected RegionSyncServer
|
// Send a message to a single connected RegionSyncServer
|
||||||
private void Send(string msg)
|
private void Send(string msg)
|
||||||
{
|
{
|
||||||
LogMessage(logOutput, msg);
|
|
||||||
byte[] bmsg = System.Text.Encoding.ASCII.GetBytes(msg + System.Environment.NewLine);
|
byte[] bmsg = System.Text.Encoding.ASCII.GetBytes(msg + System.Environment.NewLine);
|
||||||
Send(bmsg);
|
Send(bmsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Send(RegionSyncMessage msg)
|
private void Send(RegionSyncMessage msg)
|
||||||
{
|
{
|
||||||
LogMessage(logOutput, msg);
|
|
||||||
Send(msg.ToBytes());
|
Send(msg.ToBytes());
|
||||||
//m_log.WarnFormat("{0} Sent {1}", LogHeader, msg.ToString());
|
//m_log.WarnFormat("{0} Sent {1}", LogHeader, msg.ToString());
|
||||||
}
|
}
|
||||||
|
@ -347,7 +345,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
||||||
{
|
{
|
||||||
//TO FINISH:
|
//TO FINISH:
|
||||||
|
|
||||||
LogMessage(logInput, msg);
|
SceneToPhysEngineSyncServer.PhysLogMessage(false, msg);
|
||||||
switch (msg.Type)
|
switch (msg.Type)
|
||||||
{
|
{
|
||||||
case RegionSyncMessage.MsgType.RegionName:
|
case RegionSyncMessage.MsgType.RegionName:
|
||||||
|
@ -386,14 +384,13 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
||||||
if (pa != null)
|
if (pa != null)
|
||||||
{
|
{
|
||||||
// pa.Size = data["size"].AsVector3();
|
// pa.Size = data["size"].AsVector3();
|
||||||
pa.ChangingActorID = actorID;
|
|
||||||
pa.Position = data["position"].AsVector3();
|
pa.Position = data["position"].AsVector3();
|
||||||
pa.Force = data["force"].AsVector3();
|
pa.Force = data["force"].AsVector3();
|
||||||
pa.Velocity = data["velocity"].AsVector3();
|
pa.Velocity = data["velocity"].AsVector3();
|
||||||
pa.RotationalVelocity = data["rotationalVelocity"].AsVector3();
|
pa.RotationalVelocity = data["rotationalVelocity"].AsVector3();
|
||||||
pa.Acceleration = data["acceleration"].AsVector3();
|
pa.Acceleration = data["acceleration"].AsVector3();
|
||||||
pa.Torque = data["torque"].AsVector3();
|
pa.Torque = data["torque"].AsVector3();
|
||||||
pa.Orientation = data["orientantion"].AsQuaternion();
|
pa.Orientation = data["orientation"].AsQuaternion();
|
||||||
pa.IsPhysical = data["isPhysical"].AsBoolean(); // receive??
|
pa.IsPhysical = data["isPhysical"].AsBoolean(); // receive??
|
||||||
pa.Flying = data["flying"].AsBoolean(); // receive??
|
pa.Flying = data["flying"].AsBoolean(); // receive??
|
||||||
pa.Kinematic = data["kinematic"].AsBoolean(); // receive??
|
pa.Kinematic = data["kinematic"].AsBoolean(); // receive??
|
||||||
|
@ -403,6 +400,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
||||||
{
|
{
|
||||||
pa.Shape = sop.Shape;
|
pa.Shape = sop.Shape;
|
||||||
}
|
}
|
||||||
|
pa.ChangingActorID = actorID;
|
||||||
m_validLocalScene.PhysicsScene.AddPhysicsActorTaint(pa);
|
m_validLocalScene.PhysicsScene.AddPhysicsActorTaint(pa);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -438,7 +436,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
||||||
public void SendPhysUpdateAttributes(PhysicsActor pa)
|
public void SendPhysUpdateAttributes(PhysicsActor pa)
|
||||||
{
|
{
|
||||||
// m_log.DebugFormat("{0}: SendPhysUpdateAttributes for {1}", LogHeader, pa.UUID);
|
// m_log.DebugFormat("{0}: SendPhysUpdateAttributes for {1}", LogHeader, pa.UUID);
|
||||||
OSDMap data = new OSDMap(9);
|
OSDMap data = new OSDMap(17);
|
||||||
|
data["time"] = OSD.FromString(DateTime.Now.ToString("yyyyMMddHHmmssfff"));
|
||||||
data["localID"] = OSD.FromUInteger(pa.LocalID);
|
data["localID"] = OSD.FromUInteger(pa.LocalID);
|
||||||
data["uuid"] = OSD.FromUUID(pa.UUID);
|
data["uuid"] = OSD.FromUUID(pa.UUID);
|
||||||
data["actorID"] = OSD.FromString(RegionSyncServerModule.ActorID);
|
data["actorID"] = OSD.FromString(RegionSyncServerModule.ActorID);
|
||||||
|
@ -526,84 +525,6 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Handlers for events/updates from Scene
|
#endregion Handlers for events/updates from Scene
|
||||||
#region Message Logging
|
|
||||||
private bool logInput = false;
|
|
||||||
private bool logOutput = true;
|
|
||||||
private bool logEnabled = true;
|
|
||||||
private class MsgLogger
|
|
||||||
{
|
|
||||||
public DateTime startTime;
|
|
||||||
public string path = null;
|
|
||||||
public System.IO.TextWriter Log = null;
|
|
||||||
}
|
|
||||||
private MsgLogger logWriter = null;
|
|
||||||
private TimeSpan logMaxFileTime = new TimeSpan(0, 5, 0); // (h,m,s) => 5 minutes
|
|
||||||
private string logDir = "/stats/stats";
|
|
||||||
private object logLocker = new Object();
|
|
||||||
|
|
||||||
private void LogMessage(bool direction, RegionSyncMessage rsm)
|
|
||||||
{
|
|
||||||
if (!logEnabled) return; // save to work of the ToStringFull if not enabled
|
|
||||||
LogMessage(direction, rsm.ToStringFull());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LogMessage(bool direction, string msg)
|
|
||||||
{
|
|
||||||
if (!logEnabled) return;
|
|
||||||
|
|
||||||
lock (logLocker)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DateTime now = DateTime.Now;
|
|
||||||
if (logWriter == null || (now > logWriter.startTime + logMaxFileTime))
|
|
||||||
{
|
|
||||||
if (logWriter != null && logWriter.Log != null)
|
|
||||||
{
|
|
||||||
logWriter.Log.Close();
|
|
||||||
logWriter.Log.Dispose();
|
|
||||||
logWriter.Log = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// First log file or time has expired, start writing to a new log file
|
|
||||||
logWriter = new MsgLogger();
|
|
||||||
logWriter.startTime = now;
|
|
||||||
logWriter.path = (logDir.Length > 0 ? logDir + System.IO.Path.DirectorySeparatorChar.ToString() : "")
|
|
||||||
+ String.Format("physics-{0}.log", now.ToString("yyyyMMddHHmmss"));
|
|
||||||
logWriter.Log = new StreamWriter(File.Open(logWriter.path, FileMode.Append, FileAccess.Write));
|
|
||||||
}
|
|
||||||
if (logWriter != null && logWriter.Log != null)
|
|
||||||
{
|
|
||||||
StringBuilder buff = new StringBuilder();
|
|
||||||
buff.Append(now.ToString("yyyyMMddHHmmss"));
|
|
||||||
buff.Append(" ");
|
|
||||||
buff.Append(direction ? "A->S:" : "S->A:");
|
|
||||||
buff.Append(msg);
|
|
||||||
buff.Append("\r\n");
|
|
||||||
logWriter.Log.Write(buff.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.ErrorFormat("{0}: FAILURE WRITING TO LOGFILE: {1}", LogHeader, e);
|
|
||||||
logEnabled = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LogMessageClose()
|
|
||||||
{
|
|
||||||
if (logWriter != null && logWriter.Log != null)
|
|
||||||
{
|
|
||||||
logWriter.Log.Close();
|
|
||||||
logWriter.Log.Dispose();
|
|
||||||
logWriter.Log = null;
|
|
||||||
logWriter = null;
|
|
||||||
}
|
|
||||||
logEnabled = false;
|
|
||||||
}
|
|
||||||
#endregion Message Logging
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -301,7 +301,10 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
||||||
|
|
||||||
public void SendUpdate(PhysicsActor pa)
|
public void SendUpdate(PhysicsActor pa)
|
||||||
{
|
{
|
||||||
this.m_physEngineToSceneConnector.SendPhysUpdateAttributes(pa);
|
if (this.m_physEngineToSceneConnector != null)
|
||||||
|
{
|
||||||
|
this.m_physEngineToSceneConnector.SendPhysUpdateAttributes(pa);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Console Command Interface
|
#region Console Command Interface
|
||||||
|
|
|
@ -230,6 +230,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
||||||
// We could handle messages from an incoming Queue
|
// We could handle messages from an incoming Queue
|
||||||
private void HandleMessage(RegionSyncMessage msg)
|
private void HandleMessage(RegionSyncMessage msg)
|
||||||
{
|
{
|
||||||
|
SceneToPhysEngineSyncServer.PhysLogMessage(true, msg);
|
||||||
msgCount++;
|
msgCount++;
|
||||||
//string handlerMessage = "";
|
//string handlerMessage = "";
|
||||||
switch (msg.Type)
|
switch (msg.Type)
|
||||||
|
@ -345,7 +346,6 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
||||||
PhysicsActor pa = FindPhysicsActor(uuid);
|
PhysicsActor pa = FindPhysicsActor(uuid);
|
||||||
if (pa != null)
|
if (pa != null)
|
||||||
{
|
{
|
||||||
pa.ChangingActorID = actorID;
|
|
||||||
pa.Size = data["size"].AsVector3();
|
pa.Size = data["size"].AsVector3();
|
||||||
pa.Position = data["position"].AsVector3();
|
pa.Position = data["position"].AsVector3();
|
||||||
pa.Force = data["force"].AsVector3();
|
pa.Force = data["force"].AsVector3();
|
||||||
|
@ -353,13 +353,14 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
||||||
pa.RotationalVelocity = data["rotationalVelocity"].AsVector3();
|
pa.RotationalVelocity = data["rotationalVelocity"].AsVector3();
|
||||||
pa.Acceleration = data["acceleration"].AsVector3();
|
pa.Acceleration = data["acceleration"].AsVector3();
|
||||||
pa.Torque = data["torque"].AsVector3();
|
pa.Torque = data["torque"].AsVector3();
|
||||||
pa.Orientation = data["orientantion"].AsQuaternion();
|
pa.Orientation = data["orientation"].AsQuaternion();
|
||||||
pa.IsPhysical = data["isPhysical"].AsBoolean(); // receive??
|
pa.IsPhysical = data["isPhysical"].AsBoolean(); // receive??
|
||||||
pa.Flying = data["flying"].AsBoolean(); // receive??
|
pa.Flying = data["flying"].AsBoolean(); // receive??
|
||||||
pa.Kinematic = data["kinematic"].AsBoolean(); // receive??
|
pa.Kinematic = data["kinematic"].AsBoolean(); // receive??
|
||||||
pa.Buoyancy = (float)(data["buoyancy"].AsReal());
|
pa.Buoyancy = (float)(data["buoyancy"].AsReal());
|
||||||
pa.CollidingGround = data["isCollidingGround"].AsBoolean();
|
pa.CollidingGround = data["isCollidingGround"].AsBoolean();
|
||||||
pa.IsColliding = data["isCollidingGround"].AsBoolean();
|
pa.IsColliding = data["isCollidingGround"].AsBoolean();
|
||||||
|
pa.ChangingActorID = actorID;
|
||||||
|
|
||||||
pa.RequestPhysicsterseUpdate(); // tell the system the values have changed
|
pa.RequestPhysicsterseUpdate(); // tell the system the values have changed
|
||||||
}
|
}
|
||||||
|
@ -396,7 +397,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
||||||
public void SendPhysUpdateAttributes(PhysicsActor pa)
|
public void SendPhysUpdateAttributes(PhysicsActor pa)
|
||||||
{
|
{
|
||||||
// m_log.DebugFormat("{0}: sending PhysUpdateAttributes for {1}", LogHeader, pa.UUID);
|
// m_log.DebugFormat("{0}: sending PhysUpdateAttributes for {1}", LogHeader, pa.UUID);
|
||||||
OSDMap data = new OSDMap(9);
|
OSDMap data = new OSDMap(15);
|
||||||
|
data["time"] = OSD.FromString(DateTime.Now.ToString("yyyyMMddHHmmssfff"));
|
||||||
data["localID"] = OSD.FromUInteger(pa.LocalID);
|
data["localID"] = OSD.FromUInteger(pa.LocalID);
|
||||||
data["uuid"] = OSD.FromUUID(pa.UUID);
|
data["uuid"] = OSD.FromUUID(pa.UUID);
|
||||||
data["actorID"] = OSD.FromString(RegionSyncServerModule.ActorID);
|
data["actorID"] = OSD.FromString(RegionSyncServerModule.ActorID);
|
||||||
|
|
|
@ -677,5 +677,89 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Load balancing functions
|
#endregion Load balancing functions
|
||||||
|
|
||||||
|
#region Message Logging
|
||||||
|
public static bool logInput = false;
|
||||||
|
public static bool logOutput = true;
|
||||||
|
public static bool logEnabled = true;
|
||||||
|
private class PhysMsgLogger
|
||||||
|
{
|
||||||
|
public DateTime startTime;
|
||||||
|
public string path = null;
|
||||||
|
public System.IO.TextWriter Log = null;
|
||||||
|
}
|
||||||
|
private static PhysMsgLogger logWriter = null;
|
||||||
|
private static TimeSpan logMaxFileTime = new TimeSpan(0, 5, 0); // (h,m,s) => 5 minutes
|
||||||
|
public static string logDir = "/stats/stats";
|
||||||
|
private static object logLocker = new Object();
|
||||||
|
|
||||||
|
public static void PhysLogMessage(bool direction, RegionSyncMessage rsm)
|
||||||
|
{
|
||||||
|
if (!logEnabled) return; // save to work of the ToStringFull if not enabled
|
||||||
|
PhysLogMessage(direction, rsm.ToStringFull());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Log a physics bucket message
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="direction">True of message originated from the agent</param>
|
||||||
|
/// <param name="msg">the message to log</param>
|
||||||
|
public static void PhysLogMessage(bool direction, string msg)
|
||||||
|
{
|
||||||
|
if (!logEnabled) return;
|
||||||
|
|
||||||
|
lock (logLocker)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
DateTime now = DateTime.Now;
|
||||||
|
if (logWriter == null || (now > logWriter.startTime + logMaxFileTime))
|
||||||
|
{
|
||||||
|
if (logWriter != null && logWriter.Log != null)
|
||||||
|
{
|
||||||
|
logWriter.Log.Close();
|
||||||
|
logWriter.Log.Dispose();
|
||||||
|
logWriter.Log = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// First log file or time has expired, start writing to a new log file
|
||||||
|
logWriter = new PhysMsgLogger();
|
||||||
|
logWriter.startTime = now;
|
||||||
|
logWriter.path = (logDir.Length > 0 ? logDir + System.IO.Path.DirectorySeparatorChar.ToString() : "")
|
||||||
|
+ String.Format("physics-{0}.log", now.ToString("yyyyMMddHHmmss"));
|
||||||
|
logWriter.Log = new StreamWriter(File.Open(logWriter.path, FileMode.Append, FileAccess.Write));
|
||||||
|
}
|
||||||
|
if (logWriter != null && logWriter.Log != null)
|
||||||
|
{
|
||||||
|
StringBuilder buff = new StringBuilder();
|
||||||
|
buff.Append(now.ToString("yyyyMMddHHmmssfff"));
|
||||||
|
buff.Append(" ");
|
||||||
|
buff.Append(direction ? "A->S:" : "S->A:");
|
||||||
|
buff.Append(msg);
|
||||||
|
buff.Append("\r\n");
|
||||||
|
logWriter.Log.Write(buff.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
// m_log.ErrorFormat("{0}: FAILURE WRITING TO LOGFILE: {1}", LogHeader, e);
|
||||||
|
logEnabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void PhysLogMessageClose()
|
||||||
|
{
|
||||||
|
if (logWriter != null && logWriter.Log != null)
|
||||||
|
{
|
||||||
|
logWriter.Log.Close();
|
||||||
|
logWriter.Log.Dispose();
|
||||||
|
logWriter.Log = null;
|
||||||
|
logWriter = null;
|
||||||
|
}
|
||||||
|
logEnabled = false;
|
||||||
|
}
|
||||||
|
#endregion Message Logging
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,7 @@ public class PEScene : PhysicsScene
|
||||||
foreach (PEPrim prim in m_prims)
|
foreach (PEPrim prim in m_prims)
|
||||||
{
|
{
|
||||||
// if the values have changed and it was I who changed them, send an update
|
// if the values have changed and it was I who changed them, send an update
|
||||||
if (prim.lastValues.Changed(prim) && prim.ChangingActorID == RegionSyncServerModule.ActorID)
|
if (prim.ChangingActorID == RegionSyncServerModule.ActorID && prim.lastValues.Changed(prim))
|
||||||
{
|
{
|
||||||
SceneToPhysEngineSyncServer.RouteUpdate(prim);
|
SceneToPhysEngineSyncServer.RouteUpdate(prim);
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ public class PEScene : PhysicsScene
|
||||||
{
|
{
|
||||||
// m_log.DebugFormat("[RPE]: Simulate. p={0}, a={1}", m_prims.Count, m_avatars.Count);
|
// m_log.DebugFormat("[RPE]: Simulate. p={0}, a={1}", m_prims.Count, m_avatars.Count);
|
||||||
// if the values have changed and it was I who changed them, send an update
|
// if the values have changed and it was I who changed them, send an update
|
||||||
if (actor.lastValues.Changed(actor) && actor.ChangingActorID == RegionSyncServerModule.ActorID)
|
if (actor.ChangingActorID == RegionSyncServerModule.ActorID && actor.lastValues.Changed(actor))
|
||||||
{
|
{
|
||||||
SceneToPhysEngineSyncServer.RouteUpdate(actor);
|
SceneToPhysEngineSyncServer.RouteUpdate(actor);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue