Exemplo n.º 1
0
 public TargetPropertyControl(TargetPropertyDataModel model, TargetManagerDataModel host, string originalName = null)
 {
     InitializeComponent();
     DataContext     = model;
     __host          = host;
     __original_name = originalName;
 }
Exemplo n.º 2
0
        private void AddTarget_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            var targetPropertyDataModel = new TargetPropertyDataModel();

            targetPropertyDataModel.EnableRemoteOperation = __main_wnd_data_model.IsOnline == false;
            var targetPropertyControl = new TargetPropertyControl(targetPropertyDataModel, __target_manager_data_model, null);

            if (targetPropertyControl.ShowDialog() == true)
            {
                __target_manager_data_model.Add(targetPropertyDataModel);
                __main_wnd_data_model.IsDirty = true;
            }
        }
Exemplo n.º 3
0
        public async Task <DATA_SYNCHRONIZER_STATE_T> Startup(TargetPropertyDataModel target)
        {
            __sync_operation_access_lock.Wait();
            try
            {
                switch (State)
                {
                case DATA_SYNCHRONIZER_STATE_T.CONNECTED:
                    //throw new InvalidOperationException("The data synchronization thread is still running.");
                    return(DATA_SYNCHRONIZER_STATE_T.CONNECTED);

                case DATA_SYNCHRONIZER_STATE_T.EXCEPTION:
                    if (__data_sync_thread != null)
                    {
                        __data_sync_thread.Join();
                        __data_sync_thread = null;
                    }
                    break;

                case DATA_SYNCHRONIZER_STATE_T.READY:
                    break;
                }

                __stop_event.Reset();
                if (target.UDPTransportLayer)
                {
                    __io = new UDP(new System.Net.IPEndPoint(target.SourceIPv4, target.SourcePort),
                                   new System.Net.IPEndPoint(target.DestinationIPv4, target.DestinationPort),
                                   target.ReceiveBufferSize, target.SendTimeoutValue, target.ReceiveTimeoutValue);
                }
                else
                {
                    __io = new TCP(new System.Net.IPEndPoint(target.SourceIPv4, 0),
                                   new System.Net.IPEndPoint(target.DestinationIPv4, target.DestinationPort),
                                   target.SendTimeoutValue, target.ReceiveTimeoutValue);
                }
                DESTINATION_ADDRESS_T destination = new DESTINATION_ADDRESS_T(target.NetworkNumber, target.StationNumber, target.ModuleIONumber, target.MultidropNumber, target.ExtensionStationNumber);

                DeviceAccessMaster master = new DeviceAccessMaster(target.FrameType, target.DataCode, target.R_DedicatedMessageFormat, __io,
                                                                   ref destination, target.SendBufferSize, target.ReceiveBufferSize);

                if (__io is TCP)
                {
                    State = DATA_SYNCHRONIZER_STATE_T.CONNECTING;
                    await Task.Run(() => (__io as TCP).Connect());
                }

                __heartbeat_counter = 0;
                __data_sync_thread  = new Thread(new ParameterizedThreadStart(__data_sync_routine));
                __data_sync_thread.Start(Tuple.Create(master, (ushort)(target.MonitoringTimer / 250), target.PollingInterval));
                State            = DATA_SYNCHRONIZER_STATE_T.CONNECTED;
                ExceptionMessage = "";
                return(DATA_SYNCHRONIZER_STATE_T.CONNECTED);
            }
            catch (SLMPException ex)
            {
                State            = DATA_SYNCHRONIZER_STATE_T.EXCEPTION;
                ExceptionMessage = ex.Message;
                return(DATA_SYNCHRONIZER_STATE_T.EXCEPTION);
            }
            finally
            {
                __sync_operation_access_lock.Release();
            }
        }