Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="tagDriverService"></param>
        public void Init(IRealTagProduct tagDriverService, ITagHisValueProduct hisValueService)
        {
            mTagDriverService      = tagDriverService;
            mHisValueDriverService = hisValueService;
            string cfgpath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(this.GetType().Assembly.Location), "Config", "Driver.cfg");

            if (System.IO.File.Exists(cfgpath))
            {
                XElement xx = XElement.Load(cfgpath);
                foreach (var vv in xx.Elements())
                {
                    try
                    {
                        string dll  = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(this.GetType().Assembly.Location), vv.Attribute("File").Value);
                        string main = vv.Attribute("MainClass").Value;
                        if (System.IO.File.Exists(dll))
                        {
                            var driver = Assembly.LoadFrom(dll).CreateInstance(main) as IProducterDriver;
                            if (!mDrivers.ContainsKey(driver.Name))
                            {
                                mDrivers.Add(driver.Name, driver);
                            }
                        }
                        else
                        {
                            LoggerService.Service.Warn("DriverManager", dll + " is not exist.");
                        }
                    }
                    catch (Exception ex)
                    {
                        LoggerService.Service.Erro("DriverManager", ex.StackTrace);
                    }
                }
            }
        }
Пример #2
0
        ///// <summary>
        /////
        ///// </summary>
        ///// <param name="sval"></param>
        //private void Log(string sval)
        //{
        //    mWriter.WriteLine(sval);
        //    mWriter.Flush();
        //}

        /// <summary>
        ///
        /// </summary>
        /// <param name="tagQuery"></param>
        private void InitTagCach(IRealTagProduct tagQuery)
        {
            mTagIdCach = tagQuery.GetTagsByLinkAddress(new List <string>()
            {
                "Sim:cos", "Sim:sin", "Sim:step", "Sim:steppoint", "Sim:square", "Sim:datetime"
            });

            mTagHisValueService = ServiceLocator.Locator.Resolve <ITagHisValueProduct>();

            foreach (var vv in mTagIdCach)
            {
                mManualRecordTagCach.Add(vv.Key, mTagHisValueService.GetTagRecordType(vv.Value.Select(e => e.Id).ToList()).Where(e => e.Value == RecordType.Driver).Select(e => e.Key).ToList());
            }
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="tagQuery"></param>
        /// <returns></returns>
        public bool Start(IRealTagProduct tagQuery, ITagHisValueProduct tagHisValueService)
        {
            Load();
            mService = new List <DataService>();

            AllowTagIds = new HashSet <int>(tagQuery.GetTagIdsByLinkAddress(this.Name + ":"));

            for (int i = mPort; i <= mEndPort; i++)
            {
                try
                {
                    var mSvc = new DataService();
                    mSvc.Start(i);
                    mService.Add(mSvc);
                }
                catch
                {
                }
            }
            return(true);
        }
Пример #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="tagQuery"></param>
        /// <returns></returns>
        public bool Start(IRealTagProduct tagQuery, ITagHisValueProduct tagHisValueService)
        {
            mIsClosed           = false;
            mTagService         = tagQuery;
            mTagHisValueService = tagHisValueService;
            InitTagCach(tagQuery);
            mScanThread = new Thread(ScanThreadPro);
            mScanThread.IsBackground = true;
            mScanThread.Start();
            //mScanTimer = new System.Timers.Timer(100);
            //mScanTimer.Elapsed += MScanTimer_Elapsed;
            //mScanTimer.Start();
            mCosThread = new Thread(CosThreadPro);
            mCosThread.IsBackground = true;
            mCosThread.Start();

            mSinThread = new Thread(SinThreadPro);
            mSinThread.IsBackground = true;
            mSinThread.Start();


            mStepThread = new Thread(StepThreadPro);
            mStepThread.IsBackground = true;
            mStepThread.Start();

            mStepPointThread = new Thread(StepPointThreadPro);
            mStepPointThread.IsBackground = true;
            mStepPointThread.Start();

            mSquareThread = new Thread(SquareThreadPro);
            mSquareThread.IsBackground = true;
            mSquareThread.Start();


            mDatetimeThread = new Thread(DateTimeThreadPro);
            mDatetimeThread.IsBackground = true;
            mDatetimeThread.Start();

            return(true);
        }
Пример #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="arg"></param>
        public void OnHisTagChanged(HisTagChangedArg arg)
        {
            if (arg.ChangedTags != null && arg.ChangedTags.Count() > 0)
            {
                mManualRecordTagCach.Clear();
                mTagHisValueService = ServiceLocator.Locator.Resolve <ITagHisValueProduct>();

                foreach (var vv in mTagIdCach)
                {
                    mManualRecordTagCach.Add(vv.Key, mTagHisValueService.GetTagRecordType(vv.Value.Select(e => e.Id).ToList()).Where(e => e.Value == RecordType.Driver).Select(e => e.Key).ToList());
                }
            }
            else
            {
                var atags = arg.AddedTags.ToList();
                var typ   = mTagHisValueService.GetTagRecordType(arg.AddedTags.ToList());
                for (int i = 0; i < atags.Count; i++)
                {
                    var tid = atags[i];
                    var tag = mTagService.GetTagById(tid);
                    if (typ[tid] == RecordType.Driver && tag.LinkAddress.StartsWith("Sim"))
                    {
                        if (mManualRecordTagCach.ContainsKey(tag.LinkAddress))
                        {
                            mManualRecordTagCach[tag.LinkAddress].Add(tag.Id);
                        }
                        else
                        {
                            mManualRecordTagCach.Add(tag.LinkAddress, new List <int>()
                            {
                                tag.Id
                            });
                        }
                    }
                }
            }
        }