protected override bool ProcessMessageInternal(ILogMethod method, FFMsg_H2G message)
        {
            if (message == null)
            {
                method.Info("Freeform message (H2G) was null.");
                return false;
            }

            this.OnModifyMessage(method, message);
            return _serverInstance.PostMessageToTransceiver(message);
        }
 internal static bool ProcessMessage(FFMsg_H2G request)
 {
     if (_executorType == 0)
     {
         return _executor.ProcessMessage(request);
     }
     else
     {
         FreeformExecutorFactory.ProcessMessage(request);
         return true;
     }
 }
        public bool ProcessMessage(FFMsg_H2G message)
        {
            using (ILogMethod method = Log.LogMethod(this.DYN_MODULE_NAME, "ProcessMessage(H2G)"))
            {
                bool result = default(bool);

                try
                {
                    result = this.ProcessMessageInternal(method, message);
                }
                catch (Exception ex)
                {
                    method.Exception(ex);
                }

                return result;
            }
        }
 void OnProcessH2GMessageFromWorker(FFMsg_H2G request)
 {
     if (request.SessionID == FF_AppId_SessionIds.GIM)
     {
         UpdateInstallationIP(request.IpAddress, request.InstallationNo);
     }
     else
     {
         PopulateIP(request);
     }
     FFMsgHandlerFactory.Current.Execute(request);
 }
        public bool ProcessMessage(FFMsg_H2G request)
        {
            using (ILogMethod method = Log.LogMethod(this.DYN_MODULE_NAME, "ProcessH2GMessage"))
            {
                bool result = false;

                try
                {
                    // find the queue executor by session id
                    IThreadPoolExecutor<FFMsg_H2G> executor = this.GetExecutorH2G(request);
                    executor.QueueWorkerItem(request);
                    result = true;
                }
                catch (Exception ex)
                {
                    method.Exception(ex);
                }

                return result;
            }
        }
        protected virtual IThreadPoolExecutor<FFMsg_H2G> GetExecutorH2G(FFMsg_H2G msg)
        {
            switch (msg.SessionID)
            {
                case FF_AppId_SessionIds.A1:
                    return _h2gExecutor_NonPrio;

                case FF_AppId_SessionIds.GIM:
                    return _h2gExecutor_GIM;

                default:
                    return _h2gExecutor_Prio;
            }
        }
 private static bool UpdateIP(ref FFMsg_H2G message)
 {
     bool retval = false;
     if (_htInstallationIp != null &&
         _htInstallationIp.ContainsKey(message.InstallationNo))
     {
         message.IpAddress = _htInstallationIp[message.InstallationNo];
         retval = true;
     }
     return retval;
 }
 protected virtual void OnModifyMessage(ILogMethod method, FFMsg_H2G message) { }
示例#9
0
 protected virtual void OnParseEntityPart2(FFMsg_H2G msg, ref List <byte> buffer)
 {
 }
        protected virtual bool OnProcessMessageInternal(FFMsg_H2G message)
        {
            using (ILogMethod method = Log.LogMethod(this.DYN_MODULE_NAME, "OnProcessMessageInternal(H2G)"))
            {
                bool result = default(bool);

                try
                {
                    if (message == null)
                    {
                        method.Info("Freeform message (H2G) was null.");
                        return false;
                    }

                    result = _serverInstance.PostMessageToTransceiver(message);
                }
                catch (Exception ex)
                {
                    method.Exception(ex);
                }

                return result;
            }
        }
 protected abstract bool ProcessMessageInternal(ILogMethod method, FFMsg_H2G message);
 public static void ProcessMessage(FFMsg_H2G message)
 {
     using (ILogMethod method = Log.LogMethod(DYN_MODULE_NAME, "ProcessMessage(H2G)"))
     {
         try
         {
             FreeformExecutorBase executor = GetMessageType(message.SessionID);
             if (message.SessionID == FF_AppId_SessionIds.GIM)
             {
                 UpdateInstallationIP(message.IpAddress, message.InstallationNo);
             }
             else
             {
                 UpdateIP(ref message);
             }
             executor.ProcessMessage(message);
         }
         catch (Exception ex)
         {
             method.Exception(ex);
         }
     }
 }
 protected virtual void OnParseEntityPart1(FFMsg_H2G msg, ref List<byte> buffer)
 {
     buffer.Add((byte)msg.DeviceType);
     buffer.Add(msg.PollCode.GetGmuIdInt8());
     buffer.Add(msg.SessionID.GetGmuIdInt8().CreateRequestResponseId(msg.IsResponseRequired));
     buffer.Add((byte)msg.TransactionID);
 }
 protected virtual void OnParseEntityPart2(FFMsg_H2G msg, ref List<byte> buffer) { }
        protected virtual void OnParseBufferPart3(FFMsg_H2G msg, byte[] buffer, ref int offset)
        {
            msg.DataLength = buffer.GetValue<ushort>(offset, _parentParser.DataLength);
            offset += _parentParser.DataLength;
            msg.EntityData = buffer.GetValue<byte[]>(offset, msg.DataLength);
            offset += msg.DataLength;

            msg.Checksum = buffer.GetBytesToNumberUInt8(-1, 1);
            msg.ChecksumCalculated = FreeformHelper.CalculateCheckSum(buffer, 0, buffer.Length - 1);
        }
 protected virtual void OnParseBufferPart2(FFMsg_H2G msg, byte[] buffer, ref int offset) { }
 protected virtual void OnParseBufferPart1(FFMsg_H2G msg, byte[] buffer, FF_AppId_SessionIds sessionId, ref int offset)
 {
     msg.DeviceType = (FF_GmuId_DeviceTypes)buffer[offset++];
     msg.PollCode = buffer.GetBytesToNumberUInt8(offset++, 1).GetAppId<FF_GmuId_H2G_PollCodes, FF_AppId_H2G_PollCodes>();
     msg.SessionID = sessionId;
     offset++;
     msg.TransactionID = buffer.GetBytesToNumberUInt8(offset++, 1);
 }
示例#18
0
        private bool PopulateIP(FFMsg_H2G message)
        {
            using (ILogMethod method = Log.LogMethod(this.DYN_MODULE_NAME, "UpdateInstallationNo"))
            {
                bool retval = default(bool);

                try
                {
                    if (_mapInstallationIP != null &&
                        _mapInstallationIP.ContainsKey(message.InstallationNo))
                    {
                        message.IpAddress = _mapInstallationIP[message.InstallationNo];
                        retval = true;
                    }
                }
                catch (Exception ex)
                {
                    method.Exception(ex);
                }

                return retval;
            }
        }
 protected override void OnParseEntityPart2(FFMsg_H2G msg, ref List<byte> buffer)
 {
     FFMsg_H2G_1 msg2 = msg as FFMsg_H2G_1;
     buffer.SetValue(msg2.SegmentCount, 2);
     buffer.SetValue(msg2.SegmentNumber, 2);
 }
 protected virtual void OnParseEntityPart3(FFMsg_H2G msg, ref List<byte> buffer)
 {
     msg.EntityData = this.TargetParser.ParseTarget(msg);
     if (msg.EntityData == null) msg.EntityData = new byte[msg.DataLength];
     msg.DataLength = (ushort)msg.EntityData.Length;
     buffer.SetValue(msg.DataLength, _parentParser.DataLength);
     buffer.AddRange(msg.EntityData);
     buffer.CalculateAndStoreChecksum();
 }
示例#21
0
 protected virtual void OnParseBufferPart2(FFMsg_H2G msg, byte[] buffer, ref int offset)
 {
 }
 protected override void OnParseBufferPart2(FFMsg_H2G msg, byte[] buffer, ref int offset)
 {
     FFMsg_H2G_1 msg2 = msg as FFMsg_H2G_1;
     msg2.SegmentNumber = buffer.GetValue<ushort>(offset, 2);
     offset += 2;
     msg2.SegmentCount = buffer.GetValue<ushort>(offset, 2);
     offset += 2;
 }
        public bool ProcessMessage(FFMsg_H2G message)
        {
            using (ILogMethod method = Log.LogMethod(this.DYN_MODULE_NAME, "ProcessMessage(H2G)"))
            {
                bool result = default(bool);

                try
                {
                    var sessionId = (int)message.SessionID;
                    result = _handlers.ContainsKey(sessionId) ?
                        _handlers[sessionId].ProcessMessage(message) :
                        _genericHandler.ProcessMessage(message);
                }
                catch (Exception ex)
                {
                    method.Exception(ex);
                }

                return result;
            }
        }