Пример #1
0
        public TransmitData getCurrentSelected(MaskType mt)
        {
            TransmitData sdRtn = new TransmitData();

            sdRtn.data = new CANData();
            TreeNode   tnSelected = MessageTreeView.SelectedNode;
            CANMessage cMsg;

            if (typeof(CANMessage).Equals(tnSelected.Tag.GetType()))
            {
                cMsg          = tnSelected.Tag as CANMessage;
                sdRtn.data.ID = cMsg.ID;
                sdRtn.data.SetData(cMsg.BuildMessage(mt));
                sdRtn.cycle = cMsg.TxPeriod;
            }
            else if (typeof(CANSignal).Equals(tnSelected.Tag.GetType()))
            {
                cMsg = tnSelected.Parent.Tag as CANMessage;
                CANSignal cSignal = tnSelected.Tag as CANSignal;
                sdRtn.data.ID = cMsg.ID;
                sdRtn.data.SetData(cSignal.encode(mt));
                sdRtn.cycle = cMsg.TxPeriod;
            }
            else
            {
                sdRtn = null;
            }
            return(sdRtn);
        }
Пример #2
0
        private void addSignal(SignalType st)
        {
            TreeNode   tnSelected = MessageTreeView.SelectedNode;
            CANMessage cMsg;

            if (typeof(CANMessage).Equals(tnSelected.Tag.GetType()))
            {
                cMsg = tnSelected.Tag as CANMessage;
            }
            else if (typeof(CANSignal).Equals(tnSelected.Tag.GetType()))
            {
                cMsg = tnSelected.Parent.Tag as CANMessage;
            }
            else
            {
                throw new Exception("Invalid item.");
            }
            CANSignal       newSignal = new CANSignal(st);
            FrmModifySignal fms       = new FrmModifySignal(newSignal);

            fms.ShowDialog();
            if ((fms as Ensureable).isModified())
            {
                cMsg.GetSignalList().Add(newSignal);
                reloadDisplay();
            }
        }
Пример #3
0
        public Switch(CANSignal csObjectInput)
        {
            InitializeComponent();
            csObject = csObjectInput;
            switch (csObject.DefaultValue)
            {
            case 0:
                radOff.Select();
                break;

            case 1:
                radOn.Select();
                break;

            case 2:
                radError.Select();
                break;

            case 3:
                radUnavailable.Select();
                break;

            default:
                throw new Exception("Error while decoding CANSignal:" + csObject.Name + " as a switch.");
            }
            Tuple <int, int> BitConfig = CANSignal.GetBitConfigure(csObject.BitOffset);
        }
Пример #4
0
 void Modifiable.ModifyObject()
 {
     csObject.DefaultValue = CANSignal.EncodeDM1(new DM1Value()
     {
         SPN = uint.Parse(txtSPN.Text),
         FMI = uint.Parse(txtFMI.Text)
     });
 }
Пример #5
0
        public DM1FaultCode(CANSignal csIn)
        {
            InitializeComponent();
            csObject = csIn;
            DM1Value newdm = csObject.DecodeCANMessage() as DM1Value;

            txtSPN.Text = newdm.SPN.ToString();
            txtFMI.Text = newdm.FMI.ToString();
        }
Пример #6
0
        public Continuous(CANSignal csObjectInput)
        {
            InitializeComponent();
            csObject       = csObjectInput;
            txtScale.Text  = csObject.cRatio.ToString();
            txtOffset.Text = csObject.cOffset.ToString();
            double value = (csObject.DefaultValue - csObject.cOffset) * csObject.cRatio;

            txtValue.Text = value.ToString();
        }
Пример #7
0
 private void btnModify_Click(object sender, EventArgs e)
 {
     isModify = true;
     (ucEdit as Modifiable).ModifyObject();
     //修改信号基础信息
     csObject.Name      = txtSignalName.Text;
     csObject.BitSize   = int.Parse(txtBitLen.Text);
     csObject.BitOffset = CANSignal.GetBitOffset(
         int.Parse(txtStartByte.Text),
         int.Parse(txtStartBit.Text));
     Close();
 }
Пример #8
0
 public Discrete(CANSignal csInput)
 {
     InitializeComponent();
     csObject    = csInput;
     mappingDict = new Dictionary <ulong, string>();
     sourceDict  = csObject.GetDecodeTable();
     foreach (ulong key in sourceDict.Keys)
     {
         mappingDict.Add(key, sourceDict[key]);
     }
     txtDefaultValue.Text = csObject.DefaultValue.ToString();
     refreshList();
 }
Пример #9
0
 public void refreshDisplay()
 {
     foreach (TreeNode tnMessage in MessageTreeView.Nodes)
     {
         CANMessage msg = (CANMessage)tnMessage.Tag;
         tnMessage.Text = tnMessage.ToString();
         foreach (TreeNode tnSignal in tnMessage.Nodes)
         {
             CANSignal signal = (CANSignal)tnSignal.Tag;
             tnSignal.Text = signal.ToString();
         }
     }
 }
Пример #10
0
        public FrmModifySignal(CANSignal csObjectInit)
        {
            InitializeComponent();
            csObject = csObjectInit;
            //加载基础信息
            txtSignalName.Text = csObject.Name;
            txtBitLen.Text     = csObject.BitSize.ToString();
            Tuple <int, int> offsetInfo = CANSignal.GetBitConfigure(csObject.BitOffset);

            txtStartByte.Text = offsetInfo.Item1.ToString();
            txtStartBit.Text  = offsetInfo.Item2.ToString();
            //加载分类控件
            switch (csObject.sType)
            {
            case SignalType.Continuous:
                ucEdit = new SignalEditor.Continuous(csObjectInit);
                break;

            case SignalType.Discrete:

                ucEdit = new SignalEditor.Discrete(csObjectInit);
                break;

            case SignalType.DM1FaultCode:
                txtBitLen.Text    = "24";
                csObject.BitSize  = 24;
                txtBitLen.Enabled = false;
                ucEdit            = new SignalEditor.DM1FaultCode(csObjectInit);
                break;

            case SignalType.Switch:
                txtBitLen.Text    = "2";
                csObject.BitSize  = 2;
                txtBitLen.Enabled = false;
                ucEdit            = new SignalEditor.Switch(csObjectInit);
                break;

            case SignalType.UserDefined:
                ucEdit = new SignalEditor.Userdefined(csObjectInit);
                break;

            default:
                Close();
                return;
            }
            panelModifyType.Controls.Add(ucEdit);
            ucEdit.Dock = DockStyle.Fill;
        }
Пример #11
0
 public Userdefined(CANSignal CSIn)
 {
     InitializeComponent();
     csObject = CSIn;
     txtUserDefinedFunctionName.Text = csObject.UDFName;
 }