Example #1
0
 /// <summary>
 /// Adds asequence operation.
 /// </summary>
 /// <param name="dps">digital pin state to be set</param>
 /// <param name="starttime">Time after the last operation or start</param>
 public void AddSequenceOperation(DPinState dps, TimeSpan duration)
 {
     Chain.Add(new SequenceOperation()
     {
         State    = dps,
         Duration = duration,
         Moment   = new TimeSpan(Chain.Sum(o => o.Duration.Ticks))
     });
 }
Example #2
0
        /// <summary>
        /// Sets the state of the pin.
        /// </summary>
        /// <param name="nr">Nr.</param>
        /// <param name="state">State.</param>
        public static void SetPinState(uint nr, DPinState state)
        {
            var command = new SendCommand((int)Command.SetPinState, (int)Command.SetPinState, 50);

            command.AddArgument(nr);
            command.AddArgument((Int16)state);
            var ret = _cmdMessenger.SendCommand(command);

            if (!ret.Ok)
            {
                Console.Error.WriteLine("SetPinState " + nr + " " + state + " failed");
                LastCommunication = DateTime.Now;
            }
        }
Example #3
0
 /// <summary>
 /// Sets the pin.
 /// </summary>
 /// <param name="nr">Nr.</param>
 /// <param name="mode">Mode.</param>
 /// <param name="state">State.</param>
 public static void SetPin(uint nr, PinMode mode, DPinState state)
 {
                 #if !FAKESERIAL
     var command = new SendCommand((int)Command.SetPin, (int)Command.SetPin, 100);
     command.AddArgument((UInt16)nr);
     command.AddArgument((Int16)mode);
     command.AddArgument((Int16)state);
     var ret = _cmdMessenger.SendCommand(command);
     if (ret.Ok)
     {
         if (!(nr == (uint)ret.ReadInt32Arg() && (Int16)mode == ret.ReadInt16Arg() && (Int16)state == ret.ReadInt16Arg()))
         {
             Console.Error.WriteLine(DateTime.Now.ToString("HH:mm:ss tt zz") + "\t" + nr + "\t" + mode + "\t" + state);
         }
         LastCommunication = DateTime.Now;
     }
                 #endif
 }
Example #4
0
		/// <summary>
		/// Sets the pin.
		/// </summary>
		/// <param name="nr">Nr.</param>
		/// <param name="mode">Mode.</param>
		/// <param name="state">State.</param>
		public static void SetPin (uint nr, PinMode mode, DPinState state)
		{
			#if !FAKESERIAL
			var command = new SendCommand ((int)Command.SetPin, (int)Command.SetPin, 100);
			command.AddArgument ((UInt16)nr);
			command.AddArgument ((Int16)mode);
			command.AddArgument ((Int16)state);
			var ret = _cmdMessenger.SendCommand (command);
			if (ret.Ok)
			{
				if (!(nr == (uint)ret.ReadInt32Arg () && (Int16)mode == ret.ReadInt16Arg () && (Int16)state == ret.ReadInt16Arg ()))
				{
					Console.Error.WriteLine (DateTime.Now.ToString ("HH:mm:ss tt zz") + "\t" + nr + "\t" + mode + "\t" + state);
				}
				LastCommunication = DateTime.Now;
			}
			#endif
		}
Example #5
0
		/// <summary>
		/// Sets the state of the pin.
		/// </summary>
		/// <param name="nr">Nr.</param>
		/// <param name="state">State.</param>
		public static void SetPinState (uint nr, DPinState state)
		{
			var command = new SendCommand ((int)Command.SetPinState, (int)Command.SetPinState, 50);
			command.AddArgument (nr);
			command.AddArgument ((Int16)state);
			var ret = _cmdMessenger.SendCommand (command);
			if (!ret.Ok)
			{
				Console.Error.WriteLine ("SetPinState " + nr + " " + state + " failed");
				LastCommunication = DateTime.Now;
			}
		}
Example #6
0
 /// <summary>
 /// Adds asequence operation.
 /// </summary>
 /// <param name="dps">digital pin state to be set</param>
 /// <param name="starttime">Time after the last operation or start</param>
 public void AddSequenceOperation(DPinState dps, TimeSpan duration)
 {
     Chain.Add (new SequenceOperation () {
         State = dps,
         Duration = duration,
         Moment = new TimeSpan (Chain.Sum (o => o.Duration.Ticks))
     });
 }