示例#1
0
        /// <summary>
        /// Генерация текста исходного кода для заданного элемента списка сигналов
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        private IEnumerable <string> GetPeripheryCode(SymbolTableItemModel item)
        {
            var p = new ObservableCollection <string>();

            var          loadPath   = item.DbFullName + "." + item.DbArrayName + "[" + item.DbArrayIndex + "]." + item.DeviceTag + ";";
            var          loadSymbol = "\"" + item.SignalName + "\";";
            const string loadA      = "A ";
            const string loadAn     = "AN ";
            const string loadEq     = "= ";
            const string loadL      = "L ";
            const string loadT      = "T ";

            var t = item.SignalType;


            switch (t)
            {
            case "Q":
                p.Add(loadA + loadPath);
                p.Add(loadEq + loadSymbol);
                break;

            case "I":
                if (item.DeviceType.Equals("Y"))
                {
                    p.Add(loadAn + loadSymbol);
                }
                else
                {
                    p.Add(loadA + loadSymbol);
                }
                p.Add(loadEq + loadPath);
                break;

            case "IW":
                p.Add(loadL + loadSymbol);
                p.Add(loadT + loadPath);
                break;

            case "QW":
                //p.Add(load_L + load_path);
                p.Add(loadL + item.DbFullName + ".LMN;");
                p.Add(loadT + loadSymbol);
                break;

            default:
                p.Add("// There no automated generated code for " + item.Codename);
                p.Add("NOP 0");
                p.Add("// ");
                break;
            }

            return(p);
        }
示例#2
0
        /// <summary>
        /// Поиск на листе Excel по частичным текстовым совпадениям строк и ключей
        /// </summary>
        /// <param name="sourceSheet">Лист для поиска, источник</param>
        /// <param name="key">Ключ для текстового поиска</param>
        /// <returns>Список строк, преобразованный в список элементов класса символьной таблицы</returns>
        private List <SymbolTableItemModel> OneClick_SearchKey(string sourceSheet, string key)
        {
            var sheets = excelbook.Worksheets;
            var sheet  = (Microsoft.Office.Interop.Excel.Worksheet)sheets.get_Item(sourceSheet);

            sheet.Select();

            Microsoft.Office.Interop.Excel.Range currentFind = null;
            Microsoft.Office.Interop.Excel.Range firstFind   = null;
            Microsoft.Office.Interop.Excel.Range oneRow      = null;

            var s7_list = new List <SymbolTableItemModel>();

            //------ Поиск ------------------------------------------
            currentFind = excelapp.Columns.Find(key, Type.Missing,
                                                Microsoft.Office.Interop.Excel.XlFindLookIn.xlValues,
                                                Microsoft.Office.Interop.Excel.XlLookAt.xlPart,
                                                Microsoft.Office.Interop.Excel.XlSearchOrder.xlByRows,
                                                Microsoft.Office.Interop.Excel.XlSearchDirection.xlNext, false);

            while (currentFind != null) //&(final<10) )
            {
                // Keep track of the first range you find.
                if (firstFind == null)
                {
                    firstFind = currentFind;
                }

                // If you didn't move to a new range, you are done.
                else if (currentFind.get_Address(Type.Missing, Type.Missing, Microsoft.Office.Interop.Excel.XlReferenceStyle.xlA1, Type.Missing, Type.Missing)
                         == firstFind.get_Address(Type.Missing, Type.Missing, Microsoft.Office.Interop.Excel.XlReferenceStyle.xlA1, Type.Missing, Type.Missing))
                {
                    break;
                }

                var r       = currentFind.Row;
                var s7_item = new SymbolTableItemModel();

                // Строка символьной таблицы, [А234:K234]
                oneRow = sheet.Range["A" + r.ToString() + ":K" + r.ToString()];
                //s7_item = generateListFromRange(oneRow);

                s7_list.Add(s7_item);

                currentFind.EntireRow.Clear();
                currentFind = excelapp.Columns.FindNext(currentFind);
            }
            return(s7_list);
        }
示例#3
0
        private static List <SymbolTableItemModel> GenRandomItemsList(string s)
        {
            var list = new List <SymbolTableItemModel>();

            for (var i = 0; i < 10; i++)
            {
                var item = new SymbolTableItemModel();

                item.Name        = "Name " + s + i.ToString();
                item.SignalName  = "SignalName " + s + i.ToString();
                item.Codename    = "Codename " + s + i.ToString();
                item.Description = "Description " + s + i.ToString();


                list.Add(item);
            }
            return(list);
        }
示例#4
0
        public MainFramesView(string mdfFilename)
        {
            InitializeComponent();
            Context = new OneDbContext(mdfFilename);

            try
            {
                Context.dbCategory.Include(c => c.Keys).Include(c => c.S7Items).Include(c => c.Db).Load();
                Context.dbSymbolTableItem.Include(i => i.PeripheryCode).Load();
                var n = new SymbolTableItemModel();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Database load error: " + ex.Message.ToString());
            }

            _windowDbView = new FrameDbView(Context.dbCategory.Local);
            this.MainFrame.NavigationService.Navigate(_windowDbView);
        }