Пример #1
0
        protected override void OnSetValue(PropertySpecEventArgs e)
        {
            string paramName = e.Property.Name;

            ccParameter param = Node.properties[paramName];

            param.Value = e.Value;
            base.OnSetValue(e);
        }
Пример #2
0
        void nodeParameterList_SetValue(object sender, Flobbster.Windows.Forms.PropertySpecEventArgs e)
        {
            string paramName = e.Property.Name;

            ccParameter param = activeNode.properties[paramName];

            byte[] cmd = param.buildSetCmd();

            if (cmd != null)
            {
                routedMessage msgValSet = new routedMessage(activeNode.address, cmd);
                SendRoutedMessage(msgValSet, SERIALCON);
                Debug.WriteLine(activeNode.name + ": set parameter: " + paramName + " to: " + param.Value.ToString());
            }
        }
Пример #3
0
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            if (context == null)
            {
                return(null);
            }
            CC_paramBinder pb    = (CC_paramBinder)context.Instance;
            ccParameter    param = pb.Node.properties[context.PropertyDescriptor.Name];

            if (param != null)
            {
                return(new StandardValuesCollection(param.GetEnumList()));
            }
            else
            {
                return(null);
            }
        }
Пример #4
0
        void cmdButton_Click(object sender, EventArgs e)
        {
            //call void function(void) on remote device
            Button b = sender as Button;

            if (b != null)
            {
                ccParameter param = b.Tag as ccParameter;
                if (param != null)
                {
                    byte[] cmd = param.buildSetCmd();

                    if (cmd != null)
                    {
                        routedMessage msgValSet = new routedMessage(param.Owner.address, cmd);
                        SendRoutedMessage(msgValSet, SERIALCON);
                    }
                }
            }
        }
Пример #5
0
        private void handleCommonCommand(routedMessage msg, byte fromCon)
        {
            commandReader reader = msg.getReader();

            reader.ReadByte();

            byte cmd = reader.ReadByte();

            switch (cmd)
            {
            case 5:     //parameter count
                byte count = reader.ReadByte();
                activeNode.parameterCount = count;
                if (count > 0)
                {
                    routedMessage msgGetMeta = new routedMessage(activeNode.address, new byte[] { 0x0a, 0x6, 0x00 });
                    SendRoutedMessage(msgGetMeta, SERIALCON);
                }
                break;

            case 7:     //parameter metadata
                byte   pIdx      = reader.ReadByte();
                string pName     = reader.ReadString();
                byte   pType     = reader.ReadByte();
                UInt32 pArrayLen = reader.Read7BitEncodedUInt32();

                try
                {
                    ccParameter property = new ccParameter(pIdx, pName, pType, pArrayLen, activeNode);
                    activeNode.properties.Add(pName, property);

                    //bind to property editor
                    if (property.TypeIdx != ccParameter.CC_ENUMERATION_VALUES && property.TypeIdx != ccParameter.CC_VOID_FUNCTION)
                    {
                        Flobbster.Windows.Forms.PropertySpec p =
                            new Flobbster.Windows.Forms.PropertySpec(pName, property.type, "Parameters");

                        if (property.TypeIdx == ccParameter.CC_ENUMERATION)
                        {
                            p.ConverterTypeName = "Serial.CC_EnumTypeConverter";
                        }
                        nodeParameterList.Properties.Add(p);

                        propertyGrid1.Refresh();
                    }
                    if (property.TypeIdx == ccParameter.CC_VOID_FUNCTION)
                    {
                        Button cmdButton = new Button();
                        cmdButton.Text     = pName;
                        cmdButton.Tag      = property;
                        cmdButton.AutoSize = true;
                        cmdButton.Click   += new EventHandler(cmdButton_Click);
                        commandPanel.Controls.Add(cmdButton);

                        if (activeNode.parameterCount > activeNode.properties.Count)
                        {
                            //get next parameter
                            routedMessage msgGetMeta = new routedMessage(activeNode.address, new byte[] { 0x0a, 0x6, (byte)activeNode.properties.Count });
                            SendRoutedMessage(msgGetMeta, SERIALCON);
                        }
                    }
                    else
                    {
                        //get value
                        //TODO decide what to do with big arrays - limit to first 32 elements for now

                        routedMessage msgValReq = new routedMessage(activeNode.address, new byte[] { 0x03, pIdx, 0x00, (byte)(Math.Min(pArrayLen, 32)) });
                        SendRoutedMessage(msgValReq, SERIALCON);
                    }
                }
                catch (Exception pe)
                {
                    MessageBox.Show("get parameter error" + pe.Message);
                }
                break;
            }
        }