/// <summary> /// Конструктор по умолчанию /// </summary> public NetworkController() { _Status = Status.Stopped; // По умолчанию физического уровня нет. _CanPort = null; // Ищем уникальное имя и когда находим его, присваиваем сети lock (_SyncRoot) { _NetworkId = CreateNetwrokId(); } _Description = String.Format("CanNetworkController{0}", _NetworkId); DeviceChangedData = new EventHandler(EventHandlerDeviceChangedValue); DeviceChangedStatus = new EventHandler(EventHandlerDeviceChangedStatus); // Инициализируем спусок устройств в сети _DevicesList = new DevicesCollection(this); _DevicesList.CollectionWasChanged += new EventHandler <KeyedCollectionWasChangedEventArgs <DeviceBase> > (EventHandler_DevicesListWasChanged); // Инициализируем список сетевых сервисов this.InitNetworkServices(); }
//-------------------------------------------------------------------------------- /// <summary> /// Обработчик события нажатия кнопки "OK" /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EventHandler_ButtonOK_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.OK; SplitContainer splitContainer = (SplitContainer)this.Controls["_SplitContainerMainWindows"]; splitContainer = (SplitContainer)splitContainer.Panel1.Controls["_SplitContainerManufactures"]; Panel settingsPanel = splitContainer.Panel2; foreach (System.Windows.Forms.Control control in settingsPanel.Controls) { if (control is Design.Controls.ICanPortEditor) { Design.Controls.ICanPortEditor editor = (Design.Controls.ICanPortEditor)control; this.ICanPort = editor.CanPort; } //if (control is Design.Controls.IXXATCanPortTuner) //{ // Design.Controls.IXXATCanPortTuner ixxatTnr = // (Design.Controls.IXXATCanPortTuner)control; // this._ICanPort = (ICanPort)ixxatTnr.CanPort; //} //else if (control is Design.Controls.FastwelNIM351PortTuner) //{ // Design.Controls.FastwelNIM351PortTuner nim351Tnr = // (Design.Controls.FastwelNIM351PortTuner)control; // this._ICanPort = (ICanPort)nim351Tnr.CanPort; //} } this.Close(); return; }
private void EmitPosition(ICanPort Port, EarthPoint Position, bool Reliability) { CanFrame frame = new MmAltLongFrame(Position.Latitude, Position.Longitude, Reliability).GetCanFrame(); CanFrame fx = CanFrame.NewWithId(0x5c0, frame.Data); Port.BeginSend(fx); }
private void EmitSpeed(ICanPort Port, double Speed) { var frame = new IpdEmulation { Sensor1State = IpdEmulation.SensorState.Get(Speed, Cogs, Diameter, IpdEmulation.SensorState.DpsSensorPlacement.Left), Sensor2State = IpdEmulation.SensorState.Get(Speed, Cogs, Diameter, IpdEmulation.SensorState.DpsSensorPlacement.Left) }; Port.BeginSend(frame); }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bool ICanPortEditor.CanEditCanPort(ICanPort canPort) { if (canPort is Fastwel.NIM351.CanPort) { return(true); } else { // Это CAN-порт другого производителя return(false); } }
/// <summary> /// Конструктор для десериализации /// </summary> /// <param name="info"></param> /// <param name="context"></param> private NetworkController(SerializationInfo info, StreamingContext context) { DeviceBase device; // Восстанавливаем сохранённые параметры _NetworkId = info.GetUInt32("NetworkId"); _Description = info.GetString("Description"); _CanPort = (ICanPort)info.GetValue("CanPort", typeof(ICanPort)); if (_CanPort != null) { _CanPort.Stop(); _CanPort.MessageReceived += new EventHandler(EventHandler_CanPort_MessageReceived); //_CanPort.PortChangedStatus += // new EventHandlerPortChangesStatus(EventHandler_CanPort_PortChangesStatus); //_CanPort.ErrorReceived += // new EventHandlerErrorRecived(EventHandler_CanPort_ErrorReceived); } _TotalAttempts = info.GetInt32("TotalAttempts"); // Восстанавливаем список устройств _DevicesList = new DevicesCollection(this); List <string> list = (List <string>)info.GetValue("Devices", typeof(List <string>)); foreach (string str in list) { device = DeviceBase.Create(str); _DevicesList.Add(device); } // Запускаем сетевые сервисы InitNetworkServices(); // Настройки сетевых сервисов ((ServicePdoReceive)_NetworkServices[ServiceType.PdoReceive]).Interval = info.GetInt32("PdoReceiveInterval"); ((ServiceSync)_NetworkServices[ServiceType.Sync]).PeriodSync = info.GetDouble("SyncPeriodSync"); foreach (Service service in _NetworkServices) { service.TotalAttempts = _TotalAttempts; } DeviceChangedData = new EventHandler(EventHandlerDeviceChangedValue); DeviceChangedStatus = new EventHandler(EventHandlerDeviceChangedStatus); }
public CanWheel(ICanPort Port) { this.Port = Port; GetParameters(); var descriptor = BlokFrame.GetDescriptors<IpdState>()[HalfsetKind.SetA]; Port.Rx.WaitForTransactionCompleated() .Where(f => f.Descriptor == descriptor) .Select(BlokFrame.GetBlokFrame<IpdState>) .Subscribe(ProcessIpdState); _pumpTimer = new Timer(100); _pumpTimer.Elapsed += PumpTimerOnElapsed; _pumpTimer.Start(); _milageValue = 0; _milage = new Subject<double>(); }
//-------------------------------------------------------------------------------- public override object ConvertTo( ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { // Преобразуем объект ICanPort в строку if (destinationType == typeof(String)) { if (value != null) { if (value is ICanPort) { ICanPort port = (ICanPort)value; return(String.Format("{0}; {1}; {2}; {3}; {4}; {5}", port.Manufacturer, port.HardwareType, port.PortName, port.BitRate, port.Mode, port.FrameFormat)); } } } return(base.ConvertTo(context, culture, value, destinationType)); }
/// <summary> /// Конструктор /// </summary> /// <param name="port">CAN-порт</param> /// <param name="NetworkId">Наименование сети</param> public NetworkController(ICanPort port, UInt32 networkId) { _Status = Status.Stopped; NetworkId = networkId; _Description = String.Format("CanNetworkController{0}", NetworkId); this._CanPort = port; if (this._CanPort != null) { if (this._CanPort.IsOpen) { this._CanPort.Close(); } } DeviceChangedData = new EventHandler(EventHandlerDeviceChangedValue); DeviceChangedStatus = new EventHandler(EventHandlerDeviceChangedStatus); // Инициализируем спусок устройств в сети _DevicesList = new DevicesCollection(this); _DevicesList.CollectionWasChanged += new EventHandler <KeyedCollectionWasChangedEventArgs <DeviceBase> > (EventHandler_DevicesListWasChanged); // Инициализируем список сетевых сервисов InitNetworkServices(); _CanPort.MessageReceived += new EventHandler(EventHandler_CanPort_MessageReceived); //_CanPort.PortChangedStatus += // new EventHandlerPortChangesStatus(EventHandler_CanPort_PortChangesStatus); //_CanPort.ErrorReceived += // new EventHandlerErrorRecived(EventHandler_CanPort_ErrorReceived); }
//-------------------------------------------------------------------------------- bool ICanPortEditor.CanEditCanPort(ICanPort canPort) { if (canPort is IXXAT.CanPort) { return true; } else { // Это CAN-порт другого производителя return false; } }
public bool Equals(ICanPort other) => Equals(this, other as DebugCanPort);
public Handler(ICanPort Port) { this.Port = Port; }
/// <summary> /// Конструктор для десериализации /// </summary> /// <param name="info"></param> /// <param name="context"></param> private NetworkController(SerializationInfo info, StreamingContext context) { DeviceBase device; // Восстанавливаем сохранённые параметры _NetworkId = info.GetUInt32("NetworkId"); _Description = info.GetString("Description"); _CanPort = (ICanPort)info.GetValue("CanPort", typeof(ICanPort)); if (_CanPort != null) { _CanPort.Stop(); _CanPort.MessageReceived += new EventHandler(EventHandler_CanPort_MessageReceived); //_CanPort.PortChangedStatus += // new EventHandlerPortChangesStatus(EventHandler_CanPort_PortChangesStatus); //_CanPort.ErrorReceived += // new EventHandlerErrorRecived(EventHandler_CanPort_ErrorReceived); } _TotalAttempts = info.GetInt32("TotalAttempts"); // Восстанавливаем список устройств _DevicesList = new DevicesCollection(this); List<string> list = (List<string>)info.GetValue("Devices", typeof(List<string>)); foreach (string str in list) { device = DeviceBase.Create(str); _DevicesList.Add(device); } // Запускаем сетевые сервисы InitNetworkServices(); // Настройки сетевых сервисов ((ServicePdoReceive)_NetworkServices[ServiceType.PdoReceive]).Interval = info.GetInt32("PdoReceiveInterval"); ((ServiceSync)_NetworkServices[ServiceType.Sync]).PeriodSync = info.GetDouble("SyncPeriodSync"); foreach (Service service in _NetworkServices) { service.TotalAttempts = _TotalAttempts; } DeviceChangedData = new EventHandler(EventHandlerDeviceChangedValue); DeviceChangedStatus = new EventHandler(EventHandlerDeviceChangedStatus); }
/// <summary> /// Конструктор /// </summary> /// <param name="port">CAN-порт</param> /// <param name="NetworkId">Наименование сети</param> public NetworkController(ICanPort port, UInt32 networkId) { _Status = Status.Stopped; NetworkId = networkId; _Description = String.Format("CanNetworkController{0}", NetworkId); this._CanPort = port; if (this._CanPort != null) { if (this._CanPort.IsOpen) { this._CanPort.Close(); } } DeviceChangedData = new EventHandler(EventHandlerDeviceChangedValue); DeviceChangedStatus = new EventHandler(EventHandlerDeviceChangedStatus); // Инициализируем спусок устройств в сети _DevicesList = new DevicesCollection(this); _DevicesList.CollectionWasChanged += new EventHandler<KeyedCollectionWasChangedEventArgs<DeviceBase>> (EventHandler_DevicesListWasChanged); // Инициализируем список сетевых сервисов InitNetworkServices(); _CanPort.MessageReceived += new EventHandler(EventHandler_CanPort_MessageReceived); //_CanPort.PortChangedStatus += // new EventHandlerPortChangesStatus(EventHandler_CanPort_PortChangesStatus); //_CanPort.ErrorReceived += // new EventHandlerErrorRecived(EventHandler_CanPort_ErrorReceived); }
/// <summary> /// Конструктор по умолчанию /// </summary> public NetworkController() { _Status = Status.Stopped; // По умолчанию физического уровня нет. _CanPort = null; // Ищем уникальное имя и когда находим его, присваиваем сети lock (_SyncRoot) { _NetworkId = CreateNetwrokId(); } _Description = String.Format("CanNetworkController{0}", _NetworkId); DeviceChangedData = new EventHandler(EventHandlerDeviceChangedValue); DeviceChangedStatus = new EventHandler(EventHandlerDeviceChangedStatus); // Инициализируем спусок устройств в сети _DevicesList = new DevicesCollection(this); _DevicesList.CollectionWasChanged += new EventHandler<KeyedCollectionWasChangedEventArgs<DeviceBase>> (EventHandler_DevicesListWasChanged); // Инициализируем список сетевых сервисов this.InitNetworkServices(); }