//private uint memAllocSize = 0; //private IntPtr nativeMem; //============================================================================== /// <summary> /// Send a message up to the owning system so it can be routed throughout /// the simulation. Overridden to allow the message data to be converted /// to a native pointer. This enables calling from embedded Microsoft Frameworks or Mono. /// The message itself then needs to be converted from a TNativeMsgHeader to a TMsgHeader, /// which includes taking a copy of the data referenced by the data pointer /// </summary> /// <param name="inVal">Message that will be sent to the engine. /// The value passed in, although described as a "ulong", is actually /// a pointer to a native TMsgHeader /// </param> //============================================================================== public void handleMessage(ulong inVal) { // We need to copy the "native" message point into a managed object. TNativeMsgHeader src = (TNativeMsgHeader)Marshal.PtrToStructure((IntPtr)inVal, typeof(TNativeMsgHeader)); TMsgHeader msgPtr = TMessageInterpreter.NativeMsgToManagedMsg(ref src); handleMessage(msgPtr); //calls the base class function }
public CMPComponentInterface(delegateMsgCallback callback, uint componentid, uint parentid, string _dllName) { propID = 1; componentID = componentid; parentID = parentid; dllName = _dllName; //initMessageFactory(); errorHasOccurred = false; //simScript = null; //init1 = null; tick = new TimeType(); tick.startday = tick.startsec = 0; tickID = 0; haveWrittenToStdOutToday = false; _callengine = callback; interpreter = new TMessageInterpreter(componentID); interpreter.initMsgIDCounter(componentID * 100000); //ensure msgID's are interesting List <TMsgHeader> messages = new List <TMsgHeader>(); }