Hardware/Sensor.cs
changeset 109 70d0c3102424
parent 63 1a7c13ac7348
child 110 411b72b73d8f
     1.1 --- a/Hardware/Sensor.cs	Tue May 04 17:32:41 2010 +0000
     1.2 +++ b/Hardware/Sensor.cs	Thu May 06 19:20:38 2010 +0000
     1.3 @@ -46,6 +46,7 @@
     1.4      private string defaultName;
     1.5      private string name;
     1.6      private int index;
     1.7 +    private bool defaultHidden;
     1.8      private SensorType sensorType;
     1.9      private IHardware hardware;
    1.10      private ReadOnlyArray<IParameter> parameters;
    1.11 @@ -64,31 +65,37 @@
    1.12     
    1.13      public Sensor(string name, int index, SensorType sensorType,
    1.14        IHardware hardware) : this(name, index, null, sensorType, hardware, 
    1.15 -      new ParameterDescription[0]) { }
    1.16 +      null) { }
    1.17  
    1.18 -    public Sensor(string name, int index, float? limit,
    1.19 -      SensorType sensorType, IHardware hardware) : this(name, index, limit, 
    1.20 -      sensorType, hardware, new ParameterDescription[0]) { }    
    1.21 +    public Sensor(string name, int index, float? limit, SensorType sensorType,
    1.22 +      IHardware hardware, ParameterDescription[] parameterDescriptions) :
    1.23 +      this(name, index, false, limit, sensorType, hardware,
    1.24 +        parameterDescriptions) { }
    1.25  
    1.26 -    public Sensor(string name, int index, float? limit, SensorType sensorType, 
    1.27 -      IHardware hardware, ParameterDescription[] parameterDescriptions) 
    1.28 +    public Sensor(string name, int index, bool defaultHidden, 
    1.29 +      float? limit, SensorType sensorType, IHardware hardware, 
    1.30 +      ParameterDescription[] parameterDescriptions) 
    1.31      {
    1.32        this.defaultName = name;      
    1.33        this.index = index;
    1.34 +      this.defaultHidden = defaultHidden;
    1.35        this.defaultLimit = limit;
    1.36        this.sensorType = sensorType;
    1.37        this.hardware = hardware;
    1.38 -      Parameter[] parameters = new Parameter[parameterDescriptions.Length];
    1.39 +      Parameter[] parameters = new Parameter[parameterDescriptions == null ?
    1.40 +        0 : parameterDescriptions.Length];
    1.41        for (int i = 0; i < parameters.Length; i++ ) 
    1.42          parameters[i] = new Parameter(parameterDescriptions[i], this);
    1.43        this.parameters = parameters;
    1.44  
    1.45 -      string configName = Config.Settings[Identifier + "/name"];
    1.46 +      string configName = Config.Settings[
    1.47 +        new Identifier(Identifier, "name").ToString()];
    1.48        if (configName != null)
    1.49          this.name = configName;
    1.50        else
    1.51          this.name = name;
    1.52 -      string configLimit = Config.Settings[Identifier + "/limit"];
    1.53 +      string configLimit = Config.Settings[
    1.54 +        new Identifier(Identifier, "limit").ToString()];
    1.55        if (configLimit != null && configLimit != "")
    1.56          this.limit = float.Parse(configLimit);
    1.57        else
    1.58 @@ -103,10 +110,10 @@
    1.59        get { return sensorType; }
    1.60      }
    1.61  
    1.62 -    public string Identifier {
    1.63 +    public Identifier Identifier {
    1.64        get {
    1.65 -        return hardware.Identifier + "/" + sensorType.ToString().ToLower() +
    1.66 -          "/" + index;
    1.67 +        return new Identifier(hardware.Identifier, 
    1.68 +          sensorType.ToString().ToLower(), index.ToString());
    1.69        }
    1.70      }
    1.71  
    1.72 @@ -119,7 +126,7 @@
    1.73            name = value;          
    1.74          else 
    1.75            name = defaultName;
    1.76 -        Config.Settings[Identifier + "/name"] = name;
    1.77 +        Config.Settings[new Identifier(Identifier, "name").ToString()] = name;
    1.78        }
    1.79      }
    1.80  
    1.81 @@ -127,6 +134,10 @@
    1.82        get { return index; }
    1.83      }
    1.84  
    1.85 +    public bool IsDefaultHidden {
    1.86 +      get { return defaultHidden; }
    1.87 +    }
    1.88 +
    1.89      public IReadOnlyArray<IParameter> Parameters {
    1.90        get { return parameters; }
    1.91      }
    1.92 @@ -169,11 +180,11 @@
    1.93        set {
    1.94          if (value.HasValue) {
    1.95            limit = value;
    1.96 -          Config.Settings[Identifier + "/limit"] =
    1.97 +          Config.Settings[new Identifier(Identifier, "limit").ToString()] =
    1.98              limit.ToString();
    1.99          } else {
   1.100            limit = defaultLimit;
   1.101 -          Config.Settings[Identifier + "/limit"] = "";          
   1.102 +          Config.Settings[new Identifier(Identifier, "limit").ToString()] = "";          
   1.103          }        
   1.104        }
   1.105      }