Beispiel #1
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);
                }
            }
        }
        private void Cmd_CANConfig_Click(object sender, EventArgs e)
        {
            openFileDialog1.FileName         = "";
            openFileDialog1.Filter           = "CAN Configuration|*.xcc";
            openFileDialog1.InitialDirectory = CANStreamTools.MyDocumentPath + "\\CANStream\\CAN Configuration";

            if (openFileDialog1.ShowDialog().Equals(DialogResult.OK))
            {
                oCanConfig = new CANMessagesConfiguration();

                if (oCanConfig.ReadCANConfigurationFile(openFileDialog1.FileName))
                {
                    GridEdition = true;

                    int RowsCount = oCanConfig.GetTxParameterCount(false);

                    if (RowsCount > 0)
                    {
                        Grid_Association.Enabled = true;
                        Grid_Association.Rows.Clear();
                        Grid_Association.Rows.Add(RowsCount);
                        int iRow = 0;

                        string[] sAssoTypes = Enum.GetNames(typeof(CS_DataAssociationType));

                        foreach (CANMessage oMessage in oCanConfig.Messages)
                        {
                            if (oMessage.RxTx.Equals(CanMsgRxTx.Tx) && (!oMessage.ContainsVirtualParameters()))
                            {
                                foreach (CANParameter oParam in oMessage.Parameters)
                                {
                                    Grid_Association.Rows[iRow].HeaderCell.Value = oMessage.Identifier;
                                    Grid_Association.Rows[iRow].Cells[0].Value   = oParam.Name;

                                    //Association types list creation
                                    DataGridViewComboBoxCell AssoCell = (DataGridViewComboBoxCell)Grid_Association.Rows[iRow].Cells[1];
                                    AssoCell.Items.Clear();

                                    foreach (string sAsso in sAssoTypes)
                                    {
                                        AssoCell.Items.Add(sAsso);
                                    }

                                    //Built-in Signals list creation
                                    DataGridViewComboBoxCell SignalCell = (DataGridViewComboBoxCell)Grid_Association.Rows[iRow].Cells[3];
                                    SignalCell.Items.Clear();

                                    foreach (CS_BuiltInSignalLibrary oSigLib in oSigLibCollection.Libraries)
                                    {
                                        foreach (CS_BuiltInSignal oSignal in oSigLib.Signals)
                                        {
                                            SignalCell.Items.Add(oSigLib.Name + ":" + oSignal.Name);
                                        }
                                    }

                                    iRow++;
                                }
                            }
                        }

                        Txt_CANConfig.Text   = openFileDialog1.FileName;
                        Lbl_DataFile.Enabled = true;
                        Txt_DataFile.Enabled = true;
                        Cmd_DataFile.Enabled = true;
                    }
                    else
                    {
                        MessageBox.Show("The CAN configuration selected contains only Rx messages !", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }

                    GridEdition = false;
                }
                else
                {
                    MessageBox.Show("CAN configuration file loading error !\nCheck the file.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private void ShowAssociationConfiguration()
        {
            FileInfo oFile = null;
            //bool bCanCfgOK = false;
            bool bDataFileOK = false;

            oFile = new FileInfo(oAssociations.CANConfigFile);
            Txt_CANConfig.Text = oFile.FullName;

            if (oFile.Exists)
            {
                oCanConfig = new CANMessagesConfiguration();
                if (!(oCanConfig.ReadCANConfigurationFile(oAssociations.CANConfigFile)))
                {
                    MessageBox.Show("CAN Configuration file reading error !\nLoad a new file in order to modify the association configuration", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                //bCanCfgOK = true;
            }
            else
            {
                MessageBox.Show("CAN Configuration file " + oFile.Name + " no longer exists.\nLoad a new file in order to modify the association configuration.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            Lbl_DataFile.Enabled = true;
            Txt_DataFile.Enabled = true;
            Cmd_DataFile.Enabled = true;

            oFile             = new FileInfo(oAssociations.DataFileTemplate);
            Txt_DataFile.Text = oFile.FullName;

            if (oFile.Exists)
            {
                oDataFile = new ImportDataFile();
                if (!(oDataFile.ReadDataFile(oAssociations.DataFileTemplate, true)))
                {
                    MessageBox.Show("Data file template reading error !\nLoad a new file in order to modify the association configuration", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                bDataFileOK = true;
            }
            else
            {
                MessageBox.Show("Data file template " + oFile.Name + " no longer exists.\nLoad a new file in order to modify the association configuration.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            GridEdition = true;

            Grid_Association.Rows.Clear();
            Grid_Association.Rows.Add(oAssociations.Associations.Count);

            for (int iRow = 0; iRow < Grid_Association.Rows.Count; iRow++)
            {
                Grid_Association.Rows[iRow].HeaderCell.Value = oAssociations.Associations[iRow].CANParameterMessageIdentifier;
                Grid_Association.Rows[iRow].Cells[0].Value   = oAssociations.Associations[iRow].CANParameterName;

                //Association types list
                DataGridViewComboBoxCell CmbCellTypeAsso = (DataGridViewComboBoxCell)Grid_Association.Rows[iRow].Cells[1];
                CmbCellTypeAsso.Items.Clear();

                string[] AssoTypes = CS_DataAssociationType.GetNames(typeof(CS_DataAssociationType));
                for (int i = 0; i < AssoTypes.Length; i++)
                {
                    CmbCellTypeAsso.Items.Add(AssoTypes[i]);
                }

                CmbCellTypeAsso.Value = oAssociations.Associations[iRow].AssociationType.ToString();

                //Data channels list
                DataGridViewComboBoxCell CmbCellChannel = (DataGridViewComboBoxCell)Grid_Association.Rows[iRow].Cells[2];
                CmbCellChannel.Items.Clear();

                if (bDataFileOK)
                {
                    for (int i = 0; i < oDataFile.Channels.Count; i++)
                    {
                        CmbCellChannel.Items.Add(oDataFile.Channels[i].ChannelName);
                    }
                }
                else
                {
                    CmbCellChannel.Items.Add(oAssociations.Associations[iRow].DataColumnTitle);
                }

                //Built-in signals list
                DataGridViewComboBoxCell CmbCellSignal = (DataGridViewComboBoxCell)Grid_Association.Rows[iRow].Cells[3];
                CmbCellSignal.Items.Clear();

                foreach (CS_BuiltInSignalLibrary oSigLib in oSigLibCollection.Libraries)
                {
                    foreach (CS_BuiltInSignal oSignal in oSigLib.Signals)
                    {
                        CmbCellSignal.Items.Add(oSigLib.Name + ":" + oSignal.Name);
                    }
                }

                switch (oAssociations.Associations[iRow].AssociationType)
                {
                case CS_DataAssociationType.AcqData:

                    CmbCellChannel.Value = oAssociations.Associations[iRow].DataColumnTitle;
                    break;

                case CS_DataAssociationType.BuiltSignal:

                    if (oSigLibCollection.SignalExistsInLibrary(oAssociations.Associations[iRow].SignalLibrary,
                                                                oAssociations.Associations[iRow].SignalName))
                    {
                        CmbCellSignal.Value = oAssociations.Associations[iRow].SignalLibrary
                                              + ":" + oAssociations.Associations[iRow].SignalName;
                    }
                    else
                    {
                        MessageBox.Show("Built-in signal " + oAssociations.Associations[iRow].SignalName
                                        + " or signal library " + oAssociations.Associations[iRow].SignalLibrary
                                        + " doesn't exist anymore !", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }

                    break;

                case CS_DataAssociationType.FixedValue:

                    Grid_Association.Rows[iRow].Cells[4].Value = oAssociations.Associations[iRow].DefaultValue.ToString();
                    break;

                default:
                    break;
                }

                #region Old version

                /*
                 * Grid_Association.Rows[iRow].HeaderCell.Value = oAssociations.Associations[iRow].CANParameterMessageIdentifier;
                 * Grid_Association.Rows[iRow].Cells[0].Value = oAssociations.Associations[iRow].CANParameterName;
                 * Grid_Association.Rows[iRow].Cells[2].Value = oAssociations.Associations[iRow].UseDefaultValue;
                 * Grid_Association.Rows[iRow].Cells[3].Value = oAssociations.Associations[iRow].DefaultValue.ToString();
                 *
                 * DataGridViewComboBoxCell CmbCell = (DataGridViewComboBoxCell)Grid_Association.Rows[iRow].Cells[1];
                 * CmbCell.Items.Clear();
                 *
                 * if (bDataFileOK)
                 * {
                 *  for (int i = 0; i < oDataFile.Channels.Count; i++)
                 *  {
                 *      CmbCell.Items.Add(oDataFile.Channels[i].ChannelName);
                 *  }
                 * }
                 * else
                 * {
                 *  CmbCell.Items.Add(oAssociations.Associations[iRow].DataColumnTitle);
                 * }
                 *
                 * Grid_Association.Rows[iRow].Cells[1].Value = oAssociations.Associations[iRow].DataColumnTitle;
                 */
                #endregion
            }

            Grid_Association.Enabled = true;

            GridEdition = false;
        }
Beispiel #4
0
        private void Cmd_CreateClick(object sender, EventArgs e)
        {
            object[] ImportOptions = new object[3];

            if (!(Lst_TrcFiles.Items.Count == 0))
            {
                string[] TrcFiles = new string[Lst_TrcFiles.Items.Count];

                for (int i = 0; i < Lst_TrcFiles.Items.Count; i++)
                {
                    TrcFiles[i] = Lst_TrcFiles.Items[i].ToString();
                }

                ImportOptions[0] = TrcFiles;
            }
            else
            {
                MessageBox.Show("Trace record file list is empty !", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            CANMessagesConfiguration oCanCfg = new CANMessagesConfiguration();

            if (!(Txt_CanConfig.Text.Equals("")))
            {
                if (!(oCanCfg.ReadCANConfigurationFile(Txt_CanConfig.Text)))
                {
                    MessageBox.Show("CAN configuration file reading error !", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else
            {
                MessageBox.Show("No CAN Configuration defined, cycle will be created using default CAN bus properties", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            ImportOptions[1] = oCanCfg;

            if (!(Txt_CycleOut.Text.Equals("")))
            {
                ImportOptions[2] = Txt_CycleOut.Text;
            }
            else
            {
                MessageBox.Show("Output cycle file name is empty", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            this.Height    = FRM_HEIGHT_PROGRESS;
            Cmd_Cancel.Top = CMD_TOP_PROGRESS;
            Cmd_Create.Top = CMD_TOP_PROGRESS;

            FileProcessedCnt = -1;
            Lbl_TrcFileListProgress.Visible = true;
            Lbl_TrcFileListProgress.Text    = "File 0 of " + Lst_TrcFiles.Items.Count.ToString()
                                              + ": " + Path.GetFileName(Lst_TrcFiles.Items[0].ToString());

            Lbl_TrcFileProcessingProgress.Visible = true;
            Lbl_TrcFileProcessingProgress.Text    = "0 %";

            PB_TrcFileListProgress.Visible = true;
            PB_TrcFileListProgress.Value   = 0;

            PB_TrcFileProcessingProgress.Visible = true;
            PB_TrcFileProcessingProgress.Value   = 0;

            BGW_TraceImport.RunWorkerAsync(ImportOptions);
        }