public void LoadAssociationFile(string FilePath)
        {
            if (!(FilePath.Equals("")))
            {
                if (File.Exists(FilePath))
                {
                    oAssociations = new CycleDataAssociation();

                    if (oAssociations.ReadCycleDataAssociation(FilePath))
                    {
                        ShowAssociationConfiguration();
                    }
                    else
                    {
                        MessageBox.Show("Association configuration file reading error !\nCheck the file", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    ConfigModified = false;
                }
                else
                {
                    MessageBox.Show("Association file no longer exists !", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
        private void NewAssociationConfiguration()
        {
            if (ConfigModified)
            {
                DialogResult Rep = MessageBox.Show("The association configuration has been modified. Do you want save it ?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (Rep.Equals(DialogResult.Yes))
                {
                    SaveAssociationConfiguration();
                }
            }

            oCanConfig         = null;
            Txt_CANConfig.Text = "";

            oDataFile         = null;
            Txt_DataFile.Text = "";

            Lbl_DataFile.Enabled = false;
            Txt_DataFile.Enabled = false;
            Cmd_DataFile.Enabled = false;

            oAssociations = new CycleDataAssociation();
            Grid_Association.Rows.Clear();

            ConfigModified = false;
        }
Esempio n. 3
0
        public Frm_CycleCreation()
        {
            InitializeComponent();

            oCycle        = null;
            oCanConfig    = null;
            oAssociations = null;
            oDataFile     = null;

            oSignalLibCollection = new CS_BuiltInSignalLibCollection();
            if (File.Exists(CANStreamTools.CsDataPath + "\\BuiltInSignals.xml"))
            {
                oSignalLibCollection.LoadLibrariesList(CANStreamTools.CsDataPath + "\\BuiltInSignals.xml");
            }
        }
Esempio n. 4
0
        private void Cmb_Association_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (Cmb_Association.SelectedIndex != -1)
            {
                oAssociations      = new CycleDataAssociation();
                Txt_CanConfig.Text = "";

                if (File.Exists(Cmb_Association.Text))
                {
                    if (oAssociations.ReadCycleDataAssociation(Cmb_Association.Text))
                    {
                        if (File.Exists(oAssociations.CANConfigFile))
                        {
                            oCanConfig = new CANMessagesConfiguration();
                            if (oCanConfig.ReadCANConfigurationFile(oAssociations.CANConfigFile))
                            {
                                Txt_CanConfig.Text = oAssociations.CANConfigFile;
                            }
                            else
                            {
                                Cmb_Association.SelectedIndex = -1;
                                MessageBox.Show("CAN Configuration file reading error !", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                        else
                        {
                            Cmb_Association.SelectedIndex = -1;
                            MessageBox.Show("The CAN configuration file attached to the Cycle/Data association no longer exists.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                    }
                    else
                    {
                        Cmb_Association.SelectedIndex = -1;
                        MessageBox.Show("Cycle/Data file reading error !\nCheck the file.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    Cmb_Association.SelectedIndex = -1;
                    MessageBox.Show("The selected cycle/data association file no longer exists !", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
        public Frm_CycleDataAssociation()
        {
            InitializeComponent();

            oAssociations = new CycleDataAssociation();
            oCanConfig    = null;
            oDataFile     = null;

            oSigLibCollection = new CS_BuiltInSignalLibCollection();

            string SigLibCollectionFile = CANStreamTools.CsDataPath + "\\BuiltInSignals.xml";

            if (File.Exists(SigLibCollectionFile))
            {
                oSigLibCollection.LoadLibrariesList(SigLibCollectionFile);
            }

            GridEdition    = false;
            ConfigModified = false;
        }
        private void SaveAssociationConfiguration()
        {
            if (Grid_Association.Rows.Count == 0)
            {
                return;
            }

            if (CheckAssociationConfiguration())
            {
                saveFileDialog1.FileName         = "";
                saveFileDialog1.Filter           = "Cycle Data Association|*.cda";
                saveFileDialog1.InitialDirectory = CANStreamTools.MyDocumentPath + "\\CANStream\\Cycle Data Association";

                if (saveFileDialog1.ShowDialog().Equals(DialogResult.OK))
                {
                    oAssociations = new CycleDataAssociation();
                    oAssociations.CANConfigFile    = Txt_CANConfig.Text;
                    oAssociations.DataFileTemplate = Txt_DataFile.Text;

                    for (int iRow = 0; iRow < Grid_Association.Rows.Count; iRow++)
                    {
                        DataAssociation oAsso = new DataAssociation();

                        DataGridViewTextBoxCell  CanParam        = (DataGridViewTextBoxCell)Grid_Association.Rows[iRow].Cells[0];
                        DataGridViewComboBoxCell TypeAssociation = (DataGridViewComboBoxCell)Grid_Association.Rows[iRow].Cells[1];
                        DataGridViewComboBoxCell ChannelCell     = (DataGridViewComboBoxCell)Grid_Association.Rows[iRow].Cells[2];
                        DataGridViewComboBoxCell SignalCell      = (DataGridViewComboBoxCell)Grid_Association.Rows[iRow].Cells[3];
                        DataGridViewTextBoxCell  DefaultValCell  = (DataGridViewTextBoxCell)Grid_Association.Rows[iRow].Cells[4];

                        oAsso.CANParameterName = CanParam.Value.ToString();
                        oAsso.CANParameterMessageIdentifier = Grid_Association.Rows[iRow].HeaderCell.Value.ToString();
                        oAsso.AssociationType = (CS_DataAssociationType)Enum.Parse(typeof(CS_DataAssociationType), TypeAssociation.EditedFormattedValue.ToString());

                        switch (oAsso.AssociationType)
                        {
                        case CS_DataAssociationType.AcqData:

                            oAsso.DataColumnTitle = ChannelCell.EditedFormattedValue.ToString();
                            oAsso.SignalName      = "";
                            oAsso.SignalLibrary   = "";
                            oAsso.DefaultValue    = 0;
                            break;

                        case CS_DataAssociationType.BuiltSignal:

                            string[] SignalProps = SignalCell.EditedFormattedValue.ToString().Split(':');

                            oAsso.DataColumnTitle = "";
                            oAsso.SignalName      = SignalProps[1];
                            oAsso.SignalLibrary   = SignalProps[0];
                            oAsso.DefaultValue    = Convert.ToDouble(DefaultValCell.Value);;
                            break;

                        case CS_DataAssociationType.FixedValue:

                            oAsso.DataColumnTitle = "";
                            oAsso.SignalName      = "";
                            oAsso.SignalLibrary   = "";
                            oAsso.DefaultValue    = Convert.ToDouble(DefaultValCell.Value);
                            break;

                        default:

                            oAsso.DataColumnTitle = "";
                            oAsso.SignalName      = "";
                            oAsso.SignalLibrary   = "";
                            oAsso.DefaultValue    = 0;
                            break;
                        }

                        #region Old version

                        /*
                         * DataGridViewTextBoxCell CanParam = (DataGridViewTextBoxCell)Grid_Association.Rows[iRow].Cells[0];
                         * DataGridViewComboBoxCell ChannelCell = (DataGridViewComboBoxCell)Grid_Association.Rows[iRow].Cells[1];
                         * DataGridViewCheckBoxCell UseDefaultCell = (DataGridViewCheckBoxCell)Grid_Association.Rows[iRow].Cells[2];
                         * DataGridViewTextBoxCell DefaultValCell = (DataGridViewTextBoxCell)Grid_Association.Rows[iRow].Cells[3];
                         *
                         * oAsso.CANParameterName = CanParam.Value.ToString();
                         * oAsso.CANParameterMessageIdentifier = Grid_Association.Rows[iRow].HeaderCell.Value.ToString();
                         * oAsso.DataColumnTitle = ChannelCell.EditedFormattedValue.ToString();
                         * oAsso.UseDefaultValue = (bool)UseDefaultCell.EditedFormattedValue;
                         *
                         * if (!(DefaultValCell.Value == null))
                         * {
                         *  oAsso.DefaultValue = Convert.ToDouble(DefaultValCell.Value);
                         * }
                         * else
                         * {
                         *  oAsso.DefaultValue = 0;
                         * }
                         */
                        #endregion

                        oAssociations.Associations.Add(oAsso);
                    }

                    oAssociations.WriteCycleDataAssociation(saveFileDialog1.FileName);
                    ConfigModified = false;

                    MessageBox.Show("Association saved !", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }