void ProcessObjects(List <UserLevelObject> userLevelObjects, PacketStruct packetStruct) { try { foreach (UserLevelObject userObject in userLevelObjects) { if (userObject.FunctionCode == ApplicationFunctionCodes.RESPONSE) { if (!userObject.IndicesPresent) { if (userObject.RangeFieldPresent) { if (userObject.RangePresent) { for (int i = userObject.StartIndex; i <= userObject.StopIndex; i++) { AnalogInputPoint analogInputPoint; if (!Database.AnalogInputPoints.TryGetValue(i, out analogInputPoint)) { analogInputPoint = new AnalogInputPoint(); lock (Database.lockObject) { Database.AnalogInputPoints.Add(i, analogInputPoint); } } lock (Database.lockObject) { analogInputPoint.RawOutValue = BitConverter.ToInt32(userObject.Values[i], 0); analogInputPoint.OutValue = analogInputPoint.RawOutValue * analogInputPoint.ScaleFactor + analogInputPoint.ScaleOffset; FixedValue fixedValue = null; if (Database.FixedValues.TryGetValue(new Tuple <int, PointType>(i, PointType.ANALOG_INPUT), out fixedValue)) { userObject.Values[i] = BitConverter.GetBytes(fixedValue.Value); } else { analogInputPoint.RawMasterValue = analogInputPoint.RawOutValue; analogInputPoint.MasterValue = analogInputPoint.OutValue; } } publisher.AnalogInputChange(analogInputPoint, Database.IsConfigAck); } } } } } } List <byte[]> segments = applicationHandler.PackDown(userLevelObjects, userLevelObjects[0].FunctionCode, dataLinkHandler.IsMaster, dataLinkHandler.IsPrm); int offset = packetStruct.dataOffset; int actualLen = packetStruct.dataLength; segments[0].CopyTo(packetStruct.packet, packetStruct.dataOffset); byte[] transmiterTarget = new byte[6]; for (int i = 0; i < 6; i++) { transmiterTarget[i] = packetStruct.packet[i + 6]; } byte[] receiverTarget; if (AreEqual(transmiterTarget, Database.ARPSpoofParticipantsInfo.Target1MACAddress)) { receiverTarget = Database.ARPSpoofParticipantsInfo.Target2MACAddress; } else { receiverTarget = Database.ARPSpoofParticipantsInfo.Target1MACAddress; } byte[] myAddress = Database.ARPSpoofParticipantsInfo.MyMACAddress; receiverTarget.CopyTo(packetStruct.packet, 0); myAddress.CopyTo(packetStruct.packet, 6); packetStruct.size = offset + actualLen; Task.Factory.StartNew(() => PreparePacketForSending(ref packetStruct)); } catch (Exception e) { } }