コード例 #1
0
 /// <summary>
 /// Attempts to parse the sting into a valid serial number.
 /// </summary>
 /// <param name="serialNumber">Serial number.</param>
 public static ISerialNumber ParseSerialNumber(this string serialNumber)
 {
     if (GaugeSerialNumber.IsValid(serialNumber))
     {
         return(GaugeSerialNumber.Parse(serialNumber));
     }
     else
     {
         // do not throw exceptions
         //throw new Exception("Cannot parse serial number: invalid serial number: " + serialNumber);
         return(null);
     }
 }
コード例 #2
0
        public GaugeDevice(GaugeSerialNumber serialNumber, IConnection connection, IGaugeProtocol protocol)
        {
            __serialNumber  = serialNumber;
            this.connection = connection;
            __protocol      = protocol;
            name            = serialNumber.ToString();

            connection.onStateChanged += ((IConnection conn, EConnectionState state) => {
                NotifyOfDeviceEvent(DeviceEvent.EType.ConnectionChange);
                foreach (GaugeDeviceSensor sensor in sensors)
                {
                    sensor.NotifyInvalidated();
                }
            });

            connection.onDataReceived += ((IConnection conn, byte[] packet) => {
                HandlePacket(packet);
            });

            lastNotify = DateTime.Now;
        }
コード例 #3
0
 /// <summary>
 /// Queries whether or not the given string is a valid serial number.
 /// </summary>
 /// <returns><c>true</c> if is valid serial number the specified serialNumber; otherwise, <c>false</c>.</returns>
 /// <param name="serialNumber">Serial number.</param>
 public static bool IsValidSerialNumber(this string serialNumber)
 {
     return(GaugeSerialNumber.IsValid(serialNumber));
 }