public override void Validate(bool designMode, GXTaskCollection tasks)
 {
     if (!designMode && Address == 0)
     {
         tasks.Add(new GXTask(this, "Address", "Address is invalid."));
     }
 }
예제 #2
0
		/// <summary>
		/// Checks if the parameter values of the property are valid.
		/// </summary>
        public virtual void Validate(bool designMode, GXTaskCollection tasks)
		{
            if (string.IsNullOrEmpty(Name))
            {
                tasks.Add(new GXTask(this, Resources.Name, Resources.PropertyNameIsUnknown));
            }
        }
예제 #3
0
		/// <summary>
		/// Causes the component to validate its state.
		/// </summary>
		/// <remarks>The framework calls this method when it needs the component to validate its state. 
		/// If an error has occurred in the component, it is added to GXTaskCollection list.</remarks>
		/// <param name="tasks">GXTaskCollection collection where new tasks are added.</param>
		public void Validate(GXTaskCollection tasks)
		{
			tasks.RemoveUnusedTasks(Parent, false);
			if (Target == null)
			{
				GXDataIOSourceAttribute att = (GXDataIOSourceAttribute)TypeDescriptor.GetAttributes(this.Parent)[typeof(GXDataIOSourceAttribute)];
				if (att == null || !att.DataIOSourceCanBeUnknown)
				{
					tasks.Add(new GXTask(Parent, "DataIOSource", Resources.DataIOSourceTargetIsUnknown));
				}
			}
		}
예제 #4
0
        public override void Validate(bool designMode, GXTaskCollection tasks)
		{
            GXDLMSDevice device = this.Device as GXDLMSDevice;
            if (device == null)//GXDeviceEditor uses this.
            {
                device = this.Site.GetService(typeof(GXDevice)) as GXDLMSDevice;
            }
			if (device != null)
			{
				if (device.UseLogicalNameReferencing)
				{
					if (string.IsNullOrEmpty(LogicalName))
		            {
		                tasks.Add(new GXTask(this, "LogicalName", "Logical Name is unknown."));
		            }
				}
				else
				{
					if (ShortName == 0)
		            {
		                tasks.Add(new GXTask(this, "ShortName", "Short name is unknown."));
		            }
				}
			}
            base.Validate(designMode, tasks);			
		}
 void ValidateTasks()
 {
     TaskView.Items.Clear();
     //Validate tasks.
     GXTaskCollection tasks = new GXTaskCollection();
     Device.Validate(true, tasks);
     foreach (GXCategory cat in Device.Categories)
     {
         cat.Validate(true, tasks);
     }
     foreach (GXTable table in Device.Tables)
     {
         table.Validate(true, tasks);
     }
     foreach (GXTask it in tasks)
     {
         ListViewItem li = TaskView.Items.Add(it.Source.ToString());
         li.SubItems.Add(it.Description);
         li.Tag = it;
     }
 }
 /// <summary>
 /// Accept changes.
 /// </summary>
 private void OkBtn_Click(object sender, EventArgs e)
 {
     try
     {
         if (NameTB.Text.Trim().Length == 0)
         {
             NameTB.Focus();
             throw new Exception(Gurux.DeviceSuite.Properties.Resources.ErrNameEmptyTxt);
         }
         
         //Apply media dialog settings.
         if (SettingsForm != null)
         {
             ((IGXPropertyPage)SettingsForm).Apply();
         }
         ((IGXPropertyPage)PropertiesForm).Apply();
         //Validate device settings.
         GXTaskCollection tasks = new GXTaskCollection();
         Device.Validate(false, tasks);
         if (tasks.Count != 0)
         {
             throw new Exception(tasks[0].Description);
         }
         //Validate media settings.
         SelectedMedia.Validate();
         int resendCount = -3;
         double NoOutput;
         if (!ResendCountTb.ReadOnly)
         {
             string tmpStr = ResendCountTb.Text.Trim();
             if (tmpStr.Length == 0)
             {
                 throw new Exception(Gurux.DeviceSuite.Properties.Resources.IncorrectResendCountTxt);
             }
             else if (!double.TryParse(tmpStr, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, out NoOutput))
             {
                 throw new Exception(Gurux.DeviceSuite.Properties.Resources.IncorrectResendCountTxt);
             }
             resendCount = (int)NoOutput;
         }
         int waitTime = -3; ;
         if (WaitTimeTb.Enabled)
         {
             waitTime = (WaitTimeTb.Value.Hour * 3600 + WaitTimeTb.Value.Minute * 60 + WaitTimeTb.Value.Second) * 1000;
         }
         Device.UpdateInterval = RefreshRateTp.Value.Second + RefreshRateTp.Value.Minute * 60 + RefreshRateTp.Value.Hour * 3600;
         Device.WaitTime = waitTime;
         if (SelectedMedia is GXAmiGateway)
         {
             (SelectedMedia as GXAmiGateway).WaitTime = waitTime;
         }
         Device.ResendCount = resendCount;
         Device.Name = NameTB.Text;                
         Device.GXClient.AssignMedia(SelectedMedia);
         //Add disabled actions.
         Device.DisabledActions = m_DisActions.DisabledActions;
     }
     catch (Exception ex)
     {
         GXCommon.ShowError(this, ex);
         DialogResult = DialogResult.None;
     }
 }
 override public void Validate(bool designMode, GXTaskCollection tasks)
 {
     if (!designMode && DeviceAddress == 0)
     {
         tasks.Add(new GXTask(this, "DeviceAddress", "Invalid device address")); 
     }
 }            
예제 #8
0
        public override void Validate(bool designMode, GXTaskCollection tasks)
		{
			if (Convert.ToInt32(ClientID) == 0)
			{
				tasks.Add(new GXTask(this, "ClientID", "Client ID is unknown."));
			}
			if (Convert.ToInt32(PhysicalAddress) == 0)
			{
                tasks.Add(new GXTask(this, "PhysicalAddress", "Physical Address is unknown."));
			}
            base.Validate(designMode, tasks);
		}
예제 #9
0
 /// <summary>
 /// Checks if the properties in the category are valid. 
 /// </summary>
 /// <param name="designMode"></param>
 /// <param name="tasks">Collection of tasks.</param>
 public virtual void Validate(bool designMode, GXTaskCollection tasks)
 {
     if (string.IsNullOrEmpty(Name))
     {
         tasks.Add(new GXTask(this, Resources.Name, Resources.CategoryNameIsUnknown));
     }
     foreach (GXProperty it in Properties)
     {
         it.Validate(designMode, tasks);
     }
 }
예제 #10
0
		/// <summary>
        /// Checks if the properties in the table are valid.
		/// </summary>
		/// <param name="designMode"></param>
		/// <param name="tasks">Collection of tasks.</param>
        public virtual void Validate(bool designMode, GXTaskCollection tasks)
		{
            if (string.IsNullOrEmpty(Name))
            {
                tasks.Add(new GXTask(this, Resources.Name, Resources.TableNameIsUnknown));
            }
            foreach (GXProperty prop in Columns)
            {
                prop.Validate(designMode, tasks);
            }
		}
        /// <summary>
        /// Accept changes.
        /// </summary>
        private void OkBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (NameTB.Text.Trim().Length == 0)
                {
                    NameTB.Focus();
                    throw new Exception(Gurux.DeviceSuite.Properties.Resources.ErrNameEmptyTxt);
                }
                
                //Apply media dialog settings.
                if (SettingsForm != null)
                {
                    ((IGXPropertyPage)SettingsForm).Apply();
                }

                foreach(var it in DeviceParameters)
                {
                    //UIDevice
                }
                ((IGXPropertyPage)PropertiesForm).Apply();                
                //Validate media settings.
                SelectedMedia.Validate();
                //If we are adding new device.
                if (MediaConnections.Count == 0)
                {
                    MediaConnections.Add(new GXAmiDeviceMedia());
                }
                MediaConnections[0].Name = SelectedMedia.MediaType;
                MediaConnections[0].Settings = SelectedMedia.Settings;
                int resendCount = -3;
                double NoOutput;
                if (!ResendCountTb.ReadOnly)
                {
                    string tmpStr = ResendCountTb.Text.Trim();
                    if (tmpStr.Length == 0)
                    {
                        throw new Exception(Gurux.DeviceSuite.Properties.Resources.IncorrectResendCountTxt);
                    }
                    else if (!double.TryParse(tmpStr, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, out NoOutput))
                    {
                        throw new Exception(Gurux.DeviceSuite.Properties.Resources.IncorrectResendCountTxt);
                    }
                    resendCount = (int)NoOutput;
                }
                int waitTime = -3; ;
                if (WaitTimeTb.Enabled)
                {
                    waitTime = (WaitTimeTb.Value.Hour * 3600 + WaitTimeTb.Value.Minute * 60 + WaitTimeTb.Value.Second) * 1000;
                }

                //Update settings
                if (UIDevice != null)
                {
                    PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(UIDevice);
                    object tmp;
                    foreach (GXAmiParameter it in Device.Parameters)
                    {
                        if (it.Type.IsEnum)
                        {
                            tmp = Enum.Parse(properties[it.Name].PropertyType, it.Value.ToString());
                        }
                        else
                        {
                            tmp = Convert.ChangeType(it.Value, properties[it.Name].PropertyType);
                        }                        
                        properties[it.Name].SetValue(UIDevice, tmp);
                    }
                    //Validate device settings.
                    GXTaskCollection tasks = new GXTaskCollection();
                    UIDevice.Validate(false, tasks);
                    if (tasks.Count != 0)
                    {
                        throw new Exception(tasks[0].Description);
                    }
                }
                
                Device.UpdateInterval = RefreshRateTp.Value.Second + RefreshRateTp.Value.Minute * 60 + RefreshRateTp.Value.Hour * 3600;
                Device.WaitTime = waitTime;
                Device.ResendCount = resendCount;
                Device.Name = NameTB.Text;
                int index = -1;
                foreach (var it in MediaConnections)
                {
                    it.Index = ++index;
                }
                Device.Medias = MediaConnections.ToArray();
                //Add disabled actions.
                Device.DisabledActions = m_DisActions.DisabledActions;
                if (Device.Id == 0)
                {
                    Client.AddDevice(Device, Client.GetDeviceGroups(false));                   
                }
                else
                {
                    Client.Update(Device);
                }
            }
            catch (Exception ex)
            {
                GXCommon.ShowError(this, ex);
                DialogResult = DialogResult.None;
            }
        }
예제 #12
0
		/// <summary>
		/// Checks if the properties of the device are valid. 
		/// </summary>
		/// <param name="designMode"></param>
		/// <param name="tasks">Collection of tasks.</param>
		public virtual void Validate(bool designMode, GXTaskCollection tasks)
		{
		}
예제 #13
0
        public override void Validate(bool designMode, GXTaskCollection tasks)
		{		
			GXDLMSDevice device = this.Device as GXDLMSDevice;
			if (device != null)
			{
				if (device.UseLogicalNameReferencing)
				{
					if (string.IsNullOrEmpty(LogicalName))
		            {
		                tasks.Add(new GXTask(this, "LogicalName", "Logical Name is unknown."));
		            }
				}
				else
				{
					if (ShortName == 0)
		            {
                        if (this.Parent == null || !(this.Parent.Parent is GXDLMSTable))
                        {
                            tasks.Add(new GXTask(this, "ShortName", "Short name is unknown."));
                        }
		            }
				}
			}
            base.Validate(designMode, tasks);			
		}