Exemple #1
0
        protected void SettingsMessageProceed(Message msg)
        {
            lock (ViewSettingsSynchronizator)
            {
                if (ViewSettingsWindow == null)
                {
                    return;
                }

                lock (ViewSettingsWindow.SyncStatus)
                {
                    ISettingsMessageData idata = msg.Data;

                    if ((idata.GetFlags() & MessageDataContainer.MissionInform) != 0)
                    {
                        ViewSettingsWindow.UpdateBinocularParams(
                            idata.GetFocusDistance()
                            , idata.GetFocusVerticalCoordinate()
                            , idata.GetSimpleViewWidth()
                            , idata.GetSimpleViewHeight()
                            );
                    }

                    ViewSettingsWindow.DeviceStatus = ViewSettings.StatusReady;
                    ViewSettingsWindow.UpdateDeviceStatus(
                        ((IHelloMessageData)ViewSettingsWindow.DeviceHelloMessage.RecievedMessage.Data).GetName()
                        , ViewSettingsWindow.DeviceStatus);
                }
            }
        }
            public static byte[] ComposeSettingsBytes(MessageDataContainer msgDataContainer)
            {
                ISettingsMessageData idata = msgDataContainer;
                int totalCount             =
                    +1   //message mission(flags)
                    + 4  //focusDist
                    + 4  //focusVert
                    + 4  //simpleWidth
                    + 4  //simpleHeight
                    + 4  //inet4address //[nulls]
                    + 2; //port         //[nulls]

                //create array
                byte[] ret = new byte[totalCount];

                //assign flags
                ret[0] = idata.GetFlags();

                if ((idata.GetFlags() & (MissionAssign | MissionInform)) !=
                    0)
                {
                    _assign_32bit_int_to_array(ret, 1, idata.GetFocusDistance());
                    _assign_32bit_int_to_array(ret, 5, idata.GetFocusVerticalCoordinate());
                    _assign_32bit_int_to_array(ret, 9, idata.GetSimpleViewWidth());
                    _assign_32bit_int_to_array(ret, 13, idata.GetSimpleViewHeight());
                }

                if ((idata.GetFlags() & MissionRequest) != 0)
                {
                    Array.Copy(idata.GetRemoteAddress().GetAddressBytes(), 0, ret, 17, 4);
                    ret[21] = (byte)(idata.GetRemotePort() % 256);
                    ret[22] = (byte)(idata.GetRemotePort() / 256);
                }

                //return packet
                return(ret);
            }