virtual public void AddConfig(ADMMessage message)
        {
            //add board ID, device category and device name
            message.TargetID = BoardID;
            message.AddArgument((byte)Category);
            message.AddArgument(Name);

#if DEBUG
            System.Diagnostics.Debug.Print(String.Format("Adding config for device {0} ... ", ID));
#endif

            if (Mgr.Sampler != null && SampleInterval > 0 && SampleSize > 0)
            {
                Mgr.Sampler.Add(this, SampleInterval, SampleSize, SamplingOptions, SampleIntervalDeviation);
#if DEBUG
                System.Diagnostics.Debug.Print(String.Format("Adding to sampler with interval {0} and sample size {1}", SampleInterval, SampleSize));
#endif
            }
        }
Пример #2
0
        public byte SendCommand(byte targetID, ArduinoCommand command, List <Object> extraArgs = null, byte tag = 0)
        {
            var message = new ADMMessage();

            message.LittleEndian = LittleEndian;
            message.Type         = Messaging.MessageType.COMMAND;
            message.TargetID     = targetID;
            message.Tag          = tag == 0 ? MessageTags.CreateTag() : tag;
            message.CommandID    = command.ID;

            List <Object> allArgs = command.Arguments;

            if (extraArgs != null && extraArgs.Count > 0)
            {
                allArgs.AddRange(extraArgs);
            }

            foreach (Object arg in allArgs)
            {
                byte[] b;
                if (arg is String)
                {
                    b = Chetch.Utilities.Convert.ToBytes((String)arg);
                }
                else if (arg.GetType().IsValueType)
                {
                    b = Chetch.Utilities.Convert.ToBytes((ValueType)arg, LittleEndian);
                }
                else
                {
                    throw new Exception("Unable to process type " + arg.GetType());
                }
                message.AddArgument(b);
            }

            return(SendMessage(message));
        }