/// <summary> /// Initializes a new instance of the DeviceListDialog class. /// </summary> /// <param name="resources">The resource manager object.</param> /// <param name="list">The device list object.</param> public GXDeviceListDialog(GXDeviceList list) { m_List = list; InitializeComponent(); CancelBtn.Text = Gurux.DeviceSuite.Properties.Resources.CancelTxt; OKBtn.Text = Gurux.DeviceSuite.Properties.Resources.OKTxt; label1.Text = Gurux.DeviceSuite.Properties.Resources.NameTxt; this.Text = Gurux.DeviceSuite.Properties.Resources.DeviceListSettingsTxt; this.GeneralTab.Text = Gurux.DeviceSuite.Properties.Resources.GeneralTxt; NameTB.Text = list.Name; //Add disabled actions. m_DisActions = new DisabledAction(m_List.DisabledActions); tabControl1.TabPages.Add(m_DisActions.DisabledActionsTB); }
public GXScheduleEditorDlg(GXSchedule scheduleItem, GXDeviceList deviceList) { InitializeComponent(); try { if (scheduleItem == null) { scheduleItem = new GXSchedule(); scheduleItem.ScheduleStartTime = DateTime.Now; scheduleItem.ScheduleEndTime = DateTime.MaxValue; scheduleItem.TransactionStartTime = DateTime.MinValue; scheduleItem.TransactionEndTime = DateTime.MaxValue; } m_DeviceList = deviceList; m_ScheduleItem = scheduleItem; if (System.Globalization.DateTimeFormatInfo.CurrentInfo.FirstDayOfWeek == DayOfWeek.Sunday) { Point TmpLoc = new Point(DaySunCb.Location.X, DaySunCb.Location.Y); DaySunCb.Location = DayMonCb.Location; DayMonCb.Location = DayTueCb.Location; DayTueCb.Location = DayWedCb.Location; DayWedCb.Location = DayThuCb.Location; DayThuCb.Location = DayFriCb.Location; DayFriCb.Location = DaySatCb.Location; DaySatCb.Location = TmpLoc; } FillEnums(); UpdateResouces(); NameTb.Text = m_ScheduleItem.Name; if (m_ScheduleItem.TransactionStartTime != DateTime.MinValue) { TransactionStartTimeTp.Value = m_ScheduleItem.TransactionStartTime; } else { TransactionStartTimeTp.Checked = false; } if (m_ScheduleItem.TransactionEndTime != DateTime.MaxValue) { TransactionEndTimeTp.Value = m_ScheduleItem.TransactionEndTime; } //Has to be done to uncheck, known issue in .NET TransactionEndTimeTp.Checked = true; //Has to be done to uncheck, known issue in .NET TransactionEndTimeTp.Checked = m_ScheduleItem.TransactionEndTime != DateTime.MaxValue; if (m_ScheduleItem.TransactionEndTime != DateTime.MaxValue) { TransactionEndTimeTp.Value = m_ScheduleItem.TransactionEndTime; } if (m_ScheduleItem.TransactionCount == 0) { TransactionCountCb.Checked = false; TransactionCountTb.Text = ""; } else { TransactionCountCb.Checked = true; TransactionCountTb.Text = m_ScheduleItem.TransactionCount.ToString(); } UpdateFrequencyTp.Value = new DateTime(((long)m_ScheduleItem.UpdateInterval) * 10000000 + UpdateFrequencyTp.MinDate.Ticks); RepeatModeCb.SelectedItem = ScheduleRepeatToString(m_ScheduleItem.RepeatMode); DayOfMonthTb.Text = m_ScheduleItem.DayOfMonth.ToString(); IntervalTb.Text = m_ScheduleItem.Interval.ToString(); ActionCb.SelectedItem = ScheduleActionToString(m_ScheduleItem.Action); if (m_ScheduleItem.ScheduleStartTime != DateTime.MinValue) { ScheduleStartDateTp.Value = m_ScheduleItem.ScheduleStartTime; } if (m_ScheduleItem.ScheduleEndTime != DateTime.MaxValue) { ScheduleEndDateTp.Value = m_ScheduleItem.ScheduleEndTime; } ScheduleEndDateTp.Checked = true; //Has to be done to uncheck, known issue in .NET ScheduleEndDateTp.Checked = m_ScheduleItem.ScheduleEndTime != DateTime.MaxValue; UpdateTargetCheckTree(); ErrorWaitTimeTp.Value = new DateTime(ErrorWaitTimeTp.MinDate.Ticks + ((long)m_ScheduleItem.FailWaitTime) * 10000); //ErrorWaitTimeTp.Value. = m_ScheduleItem.FailWaitTime/1000.0; ErrorTryCountTb.Text = m_ScheduleItem.FailTryCount.ToString(); ConnectionDelayTimeTp.Value = new DateTime(ConnectionDelayTimeTp.MinDate.Ticks + ((long)m_ScheduleItem.ConnectionDelayTime) * 10000); MaxThreadCountTb.Text = m_ScheduleItem.MaxThreadCount.ToString(); //ConnectionFailWaitTimeTb.Text = Convert.ToString(m_ScheduleItem.ConnectionFailWaitTime/1000.0); ConnectionFailWaitTimeTp.Value = new DateTime(ConnectionFailWaitTimeTp.MinDate.Ticks + ((long)m_ScheduleItem.ConnectionFailWaitTime) * 10000); ConnectionFailTryCountTb.Text = m_ScheduleItem.ConnectionFailTryCount.ToString(); if (m_ScheduleItem.DayOfWeeks == null) { DayMonCb.Checked = DayTueCb.Checked = DayWedCb.Checked = DayThuCb.Checked = DayFriCb.Checked = DaySatCb.Checked = DaySunCb.Checked = false; } else { System.Collections.Generic.List<DayOfWeek> list = new System.Collections.Generic.List<DayOfWeek>(); list.AddRange(m_ScheduleItem.DayOfWeeks); DayMonCb.Checked = list.Contains(DayOfWeek.Monday); DayTueCb.Checked = list.Contains(DayOfWeek.Tuesday); DayWedCb.Checked = list.Contains(DayOfWeek.Wednesday); DayThuCb.Checked = list.Contains(DayOfWeek.Thursday); DayFriCb.Checked = list.Contains(DayOfWeek.Friday); DaySatCb.Checked = list.Contains(DayOfWeek.Saturday); DaySunCb.Checked = list.Contains(DayOfWeek.Sunday); } OKBtn.Enabled = (m_ScheduleItem.Status & ScheduleState.Run) == 0; } catch (Exception Ex) { GXCommon.ShowError(this, Ex); } }
public void Close() { Disconnect(); if (DeviceList != null) { DeviceList.Dispose(); DeviceList = null; } }
/// <summary> /// Load device template and connect to the device. /// </summary> /// <param name="path"></param> /// <param name="taskinfo"></param> public void Connect(string path, GXClaimedTask taskinfo) { ExecutedTask = taskinfo; //If already connected. if (Device != null) { UpdateParameters(); if ((Device.Status & DeviceStates.Connected) == 0) { Device.Connect(); } return; } DeviceList = new GXDeviceList(); DeviceList.OnError += new Gurux.Common.ErrorEventHandler(DeviceList_OnError); DeviceList.OnUpdated += new ItemUpdatedEventHandler(DeviceList_OnUpdated); GXDeviceGroup group = new GXDeviceGroup(); DeviceList.DeviceGroups.Add(group); TargetDirectory = path; AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); AppDomain.CurrentDomain.TypeResolve += new ResolveEventHandler(CurrentDomain_TypeResolve); GXDeviceList.Update(path); string filename = Path.Combine(path, taskinfo.Device.ProfileGuid + ".gxp"); Device = GXDevice.Load(filename); Device.ID = taskinfo.Device.Id; group.Devices.Add(Device); Device.Name = taskinfo.Device.Name; //taskinfo.Device.AutoConnect; // ForcePerPropertyRead Device.UpdateInterval = taskinfo.Device.UpdateInterval; Device.WaitTime = taskinfo.Device.WaitTime; Device.ResendCount = taskinfo.Device.ResendCount; Device.DisabledActions = taskinfo.Device.DisabledActions; /* TODO: Device.FailTryCount = taskinfo.Device.FailTryCount; Device.FailWaitTime = taskinfo.Device.FailWaitTime; Device.ConnectionTryCount = taskinfo.Device.ConnectionTryCount; Device.ConnectionFailWaitTime = taskinfo.Device.ConnectionFailWaitTime; */ //Update parameters. UpdateParameters(); //Load medias to this assembly domin. Gurux.Communication.GXClient.GetAvailableMedias(); if (taskinfo.Device.TraceLevel != System.Diagnostics.TraceLevel.Off) { Device.Trace = taskinfo.Device.TraceLevel; Device.OnTrace += new TraceEventHandler(Device_OnTrace); } Exception lastException = null; int pos = -1; Gurux.Common.IGXMedia media = null; foreach (var it in taskinfo.MediaSettings) { try { ++pos; //If media is changed. if (media == null || media.MediaType != taskinfo.MediaSettings[pos].Key) { media = Device.GXClient.SelectMedia(taskinfo.MediaSettings[pos].Key); Device.GXClient.AssignMedia(media); } media.Settings = taskinfo.MediaSettings[pos].Value.Value; lastException = null; Device.Connect(); break; } catch (Exception ex) { //If connection fails try next redundant connectio. lastException = ex; } } if (lastException != null) { throw lastException; } }
void IGXDataHandler.Unload(GXDeviceList list) { m_DeviceList = null; }
void IGXDataHandler.Load(GXDeviceList list) { m_DeviceList = list; m_DeviceList.OnUpdated += new ItemUpdatedEventHandler(OnUpdated); }
private void OnLoadEnd(GXDeviceList deviceList) { //If trace level is used update it to all devices. if (TraceLevel != System.Diagnostics.TraceLevel.Off) { foreach (GXDevice it in m_DeviceList.DeviceGroups.GetDevicesRecursive()) { it.Trace = TraceLevel; } } if (InvokeRequired) { this.BeginInvoke(new Gurux.Device.LoadEndEventHandler(UpdateLoadEnd), new object[] { deviceList }); } else { UpdateLoadEnd(deviceList); } }
private void UpdateLoadEnd(GXDeviceList deviceList) { UpdateTree(true); Schedules.Items.Clear(); ScheduleToTreeNode.Clear(); foreach (GXDevice it in m_DeviceList.DeviceGroups.GetDevicesRecursive()) { GuruxAMI.Gateway.GXAmiGateway gw = it.GXClient.Media as GuruxAMI.Gateway.GXAmiGateway; if (gw != null) { gw.Host = Gurux.DeviceSuite.Properties.Settings.Default.AmiHostName; gw.UserName = Gurux.DeviceSuite.Properties.Settings.Default.AmiUserName; gw.Password = Gurux.DeviceSuite.Properties.Settings.Default.AmiPassword; gw.GXClient = it.GXClient; } } foreach (GXSchedule it in m_DeviceList.Schedules) { AddScheduleItem(it); } }
/// <summary> /// Constructor. /// </summary> public GXDirector(MainForm parent) { ParentComponent = parent; InitializeComponent(); Bitmap bm = DeviceImage.Image as Bitmap; bm.MakeTransparent(); DeviceImage.Image = bm; this.TopLevel = false; this.TopMost = false; this.FormBorderStyle = FormBorderStyle.None; TablePanel.Dock = DevicePanel.Dock = DevicesList.Dock = PropertyList.Dock = PropertyPanel.Dock = this.Dock = DockStyle.Fill; LoadDefaultImages(); m_DeviceList = new GXDeviceList(); m_DeviceList.OnDirty += new DirtyEventHandler(m_DeviceList_OnDirty); m_DeviceList.OnAdded += new ItemAddedEventHandler(this.OnAdded); m_DeviceList.OnRemoved += new ItemRemovedEventHandler(this.OnRemoved); m_DeviceList.OnUpdated += new ItemUpdatedEventHandler(OnUpdated); m_DeviceList.OnSelectedItemChanged += new SelectedItemChangedEventHandler(OnSelectedItemChanged); m_DeviceList.OnLocaleIdentifierChanged += new LocaleIdentifierChangedEventHandler(OnLocaleIdentifierChanged); m_DeviceList.OnLoadEnd += new LoadEndEventHandler(OnLoadEnd); m_DeviceList.OnClear += new ItemClearEventHandler(this.OnClear); m_DeviceList.OnUpdated += new ItemUpdatedEventHandler(OnTableChanged); m_DeviceList.OnUpdated += new ItemUpdatedEventHandler(OnPropertyChanged); m_DeviceList.OnDisplayTypeChanged += new DisplayTypeChangedEventHandler(OnDisplayTypeChanged); m_DeviceList.OnError += new Gurux.Common.ErrorEventHandler(m_DeviceList_OnError); DeviceListTree.AfterSelect += new TreeViewEventHandler(OnAfterSelect); ReadBtn.Text = Gurux.DeviceSuite.Properties.Resources.ReadTxt; WriteBtn.Text = Gurux.DeviceSuite.Properties.Resources.WriteTxt; ResetBtn.Text = Gurux.DeviceSuite.Properties.Resources.ResetTxt; TypeLbl.Text = Gurux.DeviceSuite.Properties.Resources.TypeTxt; UnitLbl.Text = Gurux.DeviceSuite.Properties.Resources.UnitTxt; NameLbl.Text = Gurux.DeviceSuite.Properties.Resources.NameTxt; ValueLbl.Text = Gurux.DeviceSuite.Properties.Resources.ValueTxt; hex = true; }