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. 2
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");
            }
        }
        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 Cmd_DataFile_Click(object sender, EventArgs e)
        {
            openFileDialog1.FileName         = "";
            openFileDialog1.Filter           = CANStreamConstants.DataFileFilter;
            openFileDialog1.FilterIndex      = CANStreamConstants.DataFileFilterIndex;
            openFileDialog1.InitialDirectory = "";

            if (openFileDialog1.ShowDialog().Equals(DialogResult.OK))
            {
                oDataFile = new ImportDataFile();
                Cursor    = Cursors.WaitCursor;

                if (oDataFile.ReadDataFile(openFileDialog1.FileName, true))
                {
                    Cursor      = Cursors.Default;
                    GridEdition = true;

                    for (int i = 0; i < Grid_Association.Rows.Count; i++)
                    {
                        DataGridViewComboBoxCell CmbCell = (DataGridViewComboBoxCell)Grid_Association.Rows[i].Cells[2];

                        CmbCell.Items.Clear();
                        foreach (ImportDataChannel oChan in oDataFile.Channels)
                        {
                            CmbCell.Items.Add(oChan.ChannelName);
                        }
                    }

                    GridEdition = false;

                    Txt_DataFile.Text = openFileDialog1.FileName;
                }
                else
                {
                    Cursor = Cursors.Default;
                    MessageBox.Show(CANStreamConstants.DataFileReadingErrorText, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Esempio n. 5
0
        private void CreateCycle()
        {
            #region Pre-checks

            if (!(Txt_DataFile.Text.Equals("")))
            {
                oDataFile = new ImportDataFile();
                if (!(oDataFile.ReadDataFile(Txt_DataFile.Text)))
                {
                    MessageBox.Show(CANStreamConstants.DataFileReadingErrorText, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else
            {
                MessageBox.Show("No data file selected !", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (Cmb_Association.Text.Equals(""))
            {
                MessageBox.Show("No Cycle/Data association file selected !", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (Txt_CanConfig.Text.Equals(""))
            {
                MessageBox.Show("The CAN configuation file is missing !\nPlease select a new Cycle/Data association file.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (Txt_CycleFile.Text.Equals(""))
            {
                MessageBox.Show("Cycle destination file not defined !", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            #endregion

            oCycle = new CANStreamCycle();

            ProgressBar.Value   = 0;
            ProgressBar.Visible = true;

            for (long iTime = (long)(oDataFile.Time[0] * 1000); iTime < (long)(oDataFile.Time[oDataFile.Time.Count - 1] * 1000); iTime++)
            {
                List <string> TimeEventMessageIds = GetMessagesForTimeEvent(iTime);

                if (TimeEventMessageIds.Count > 0)
                {
                    CycleTimeEvent oTimeEvent = new CycleTimeEvent();
                    oTimeEvent.TimeEvent = iTime;

                    foreach (string sMsgId in TimeEventMessageIds)
                    {
                        CANMessageData oMessageData = new CANMessageData();
                        oMessageData = BuildCANMessageData(sMsgId, iTime);

                        if (!(oMessageData == null))
                        {
                            oTimeEvent.MessagesData.Add(oMessageData);
                        }
                        else
                        {
                            ProgressBar.Visible = false;
                            return;
                        }
                    }

                    if (oTimeEvent.MessagesData.Count > 0)
                    {
                        oCycle.TimeEvents.Add(oTimeEvent);
                    }
                }

                int Progress = (int)(iTime * 100 / oDataFile.Time.Count);

                if (Progress <= 100)
                {
                    ProgressBar.Value = Progress;
                }
            }

            //oCycle.CANConfigurationFilePath=Txt_CanConfig.Text;
            oCycle.oCanNodesMap = oCanConfig;
            oCycle.Comment      = rTxt_Comments.Text;

            oCycle.WriteStreamCycle(Txt_CycleFile.Text);

            MessageBox.Show("Cycle created !", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
            ProgressBar.Visible = false;
        }
        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;
        }