public async Task ClearOutMessageAsync()
        {
            await this.semaphoreCollection.WaitAsync().ConfigureAwait(false);

            this.outMessage = null;

            this.semaphoreCollection.Release();
        }
        private async Task PrepareOutMessageAsync(string correlationId, IEnumerable <ModbusOutValue> valueList)
        {
            await this.semaphoreCollection.WaitAsync().ConfigureAwait(false);

            ModbusOutContent content;

            if (this.outMessage == null)
            {
                content = new ModbusOutContent
                {
                    HwId = this.config.HwId,
                    Data = new List <ModbusOutData>(),
                    AdditionalProperties = this.config.AdditionalProperties
                };
                this.outMessage = content;
            }
            else
            {
                content = this.outMessage;
            }

            string        timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            ModbusOutData data      = null;

            foreach (var d in content.Data)
            {
                if (d.CorrelationId == correlationId && d.SourceTimestamp == timestamp)
                {
                    data = d;
                    break;
                }
            }
            if (data == null)
            {
                data = new ModbusOutData
                {
                    CorrelationId   = correlationId,
                    SourceTimestamp = timestamp,
                    Values          = new List <ModbusOutValue>()
                };
                content.Data.Add(data);
            }

            data.Values.AddRange(valueList);

            this.semaphoreCollection.Release();
        }
        protected void PrepareOutMessage(string HwId, string CorrelationId, List <ModbusOutValue> ValueList)
        {
            this.m_semaphore_collection.Wait();
            ModbusOutContent content = null;

            if (this.OutMessage == null)
            {
                content = new ModbusOutContent
                {
                    HwId = HwId,
                    Data = new List <ModbusOutData>()
                };
                this.OutMessage = content;
            }
            else
            {
                content = (ModbusOutContent)this.OutMessage;
            }

            string        timestamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            ModbusOutData data      = null;

            foreach (var d in content.Data)
            {
                if (d.CorrelationId == CorrelationId && d.SourceTimestamp == timestamp)
                {
                    data = d;
                    break;
                }
            }
            if (data == null)
            {
                data = new ModbusOutData
                {
                    CorrelationId   = CorrelationId,
                    SourceTimestamp = timestamp,
                    Values          = new List <ModbusOutValue>()
                };
                content.Data.Add(data);
            }

            data.Values.AddRange(ValueList);

            this.m_semaphore_collection.Release();
        }