示例#1
0
 public TagNodeHandle(short tag, string key, ITagLink element, ValueChangedEventHandler handle)
 {
     _tagID   = tag;
     _key     = key;
     _element = element;
     _handle  = handle;
 }
示例#2
0
        //{Binding LowLevel, Converter={StaticResource BTV}, RelativeSource={RelativeSource TemplatedParent}}
        //

        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            Gate storegate = Template.FindName("storegate", this) as Gate;

            children = new ITagLink[] { storegate };
        }
示例#3
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            var Valve1 = Template.FindName("UnloadValve", this) as HMILable;

            children = new ITagLink[] { Valve1 };
        }
示例#4
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            Motor motor = Template.FindName("motor", this) as Motor;

            children = new ITagLink[] { motor };
        }
示例#5
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            Motor motor = Template.FindName("motor", this) as Motor;

            if (motor != null)
            {
                children = new ITagLink[] { motor }
            }
            ;
        }

        //public override Action SetTagReader(string key, Delegate tagChanged)
        //{
        //    switch (key)
        //    {

        //        case TagActions.RUN:
        //            var _funcRun = tagChanged as Func<bool>;
        //            if (_funcRun != null)
        //            {
        //                return delegate { IsMotorWorking = _funcRun(); };
        //            }
        //            else return null;
        //    }
        //    return base.SetTagReader(key, tagChanged);
        //}
    }
示例#6
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            var feedmotor = base.GetTemplateChild("motor") as Motor;

            children = new ITagLink[] { feedmotor };
        }
示例#7
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            var InOil_motor = base.GetTemplateChild("InOil_motor") as Motor;
            var Spray_motor = base.GetTemplateChild("Spray_motor") as Motor;

            children = new ITagLink[] { Spray_motor, InOil_motor };
        }
示例#8
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            var MagnetValue1 = base.GetTemplateChild("MagnetValue1") as MagnetValve;
            var MagnetValue2 = base.GetTemplateChild("MagnetValue2") as MagnetValve;

            children = new ITagLink[] { MagnetValue1, MagnetValue2 };
        }
示例#9
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            Fan   fan   = base.GetTemplateChild("fan") as Fan;
            Motor motor = base.GetTemplateChild("motor") as Motor;

            children = new ITagLink[] { motor, fan };
        }
示例#10
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            CutoffGate storegate = Template.FindName("cutoffGate1", this) as CutoffGate;
            AirHammer  airHammer = Template.FindName("airHammer1", this) as AirHammer;
            Motor      motor     = Template.FindName("motor1", this) as Motor;

            children = new ITagLink[] { storegate, airHammer, motor };
        }
示例#11
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            Motor motor     = Template.FindName("motor", this) as Motor;
            var   Valve2    = Template.FindName("GasValve", this) as HMILable;
            var   Discharge = Template.FindName("Discharge", this) as HMIText;

            children = new ITagLink[] { motor, Valve2, Discharge };
        }
示例#12
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            var alarm = Template.FindName("alarm", this) as AlarmControl;
            var fan   = Template.FindName("fan", this) as Fan;
            var gate  = Template.FindName("gate1", this) as HMILable;

            children = new ITagLink[] { alarm, fan, gate };
        }
示例#13
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            var time = base.GetTemplateChild("discharge") as HMIText;

            if (time != null)
            {
                children = new ITagLink[] { time }
            }
            ;
        }
    }
示例#14
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            var feed_motor      = base.GetTemplateChild("feed_motor") as Motor;
            var fan1_motor      = base.GetTemplateChild("fan1_motor") as Motor;
            var fan2_motor      = base.GetTemplateChild("fan2_motor") as Motor;
            var fan3_motor      = base.GetTemplateChild("fan3_motor") as Motor;
            var fan4_motor      = base.GetTemplateChild("fan4_motor") as Motor;
            var fan5_motor      = base.GetTemplateChild("fan5_motor") as Motor;
            var fan6_motor      = base.GetTemplateChild("fan6_motor") as Motor;
            var fan7_motor      = base.GetTemplateChild("fan7_motor") as Motor;
            var fan8_motor      = base.GetTemplateChild("fan8_motor") as Motor;
            var conveyor1_motor = base.GetTemplateChild("conveyor1_motor") as Motor;
            var conveyor2_motor = base.GetTemplateChild("conveyor2_motor") as Motor;
            var conveyor3_motor = base.GetTemplateChild("conveyor3_motor") as Motor;
            var conveyor4_motor = base.GetTemplateChild("conveyor4_motor") as Motor;
            var deduster1_motor = base.GetTemplateChild("deduster1_motor") as Motor;
            var deduster2_motor = base.GetTemplateChild("deduster2_motor") as Motor;

            children = new ITagLink[] { feed_motor, fan1_motor, fan2_motor, fan3_motor, fan4_motor, fan5_motor, fan6_motor, fan7_motor,
                                        fan8_motor, conveyor1_motor, conveyor2_motor, conveyor3_motor, conveyor4_motor, deduster1_motor, deduster2_motor };
        }
示例#15
0
        static ITagLink FindElement(ITagLink tag, string key)
        {
            ITagLink tagConn = tag;

            string[] strs = key.Split('.');
            for (int i = 0; i < strs.Length; i++)
            {
                var c = tagConn as ITagReader;
                if (c == null || c.Children == null)
                {
                    break;
                }
                foreach (var item in c.Children)
                {
                    if (item.Node == strs[i])
                    {
                        tagConn = item;
                        break;
                    }
                }
            }
            return(tagConn);
        }
示例#16
0
        private static void BindingControl(ITagLink taglink, List <TagNodeHandle> valueChangedList, ExpressionEval eval)
        {
            var ctrl = taglink as UIElement;

            if (ctrl == null)
            {
                return;
            }
            var complex = taglink as ITagReader;

            if (complex != null)
            {
                string txt = complex.TagReadText;
                if (!string.IsNullOrEmpty(txt))
                {
                    foreach (var v in txt.GetListFromText())
                    {
                        ITagLink tagConn = complex;
                        string[] strs    = v.Key.Split('.');
                        if (strs.Length > 1)
                        {
                            for (int i = 0; i < strs.Length - 1; i++)
                            {
                                var c = tagConn as ITagReader;
                                if (c == null || c.Children == null)
                                {
                                    break;
                                }
                                foreach (var item in c.Children)
                                {
                                    if (item.Node == strs[i])
                                    {
                                        tagConn = item;
                                        break;
                                    }
                                }
                            }
                        }
                        var r   = tagConn as ITagReader;
                        var key = strs[strs.Length - 1];
                        try
                        {
                            var action = r.SetTagReader(key, eval.Eval(v.Value));
                            if (action != null)
                            {
                                action();
                                ValueChangedEventHandler handle = (s1, e1) =>
                                {
                                    ctrl.InvokeAsynchronously(action);
                                };
                                foreach (ITag tag in eval.TagList)
                                {
                                    valueChangedList.Add(new TagNodeHandle(tag.ID, key, tagConn, handle));
                                    tag.ValueChanged += handle;
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            App.AddErrorLog(e);
                            MessageBox.Show(string.Format("设备'{0}'属性'{1}'的值'{2}'转化出错!", string.IsNullOrEmpty(r.Node) ? r.GetType().ToString() : r.Node, key, v.Value));
                        }
                        if (Attribute.IsDefined(tagConn.GetType(), typeof(StartableAttribute), false))
                        {
                            FrameworkElement element = tagConn as FrameworkElement;
                            element.Cursor = Cursors.UpArrow;
                            element.AddHandler(UIElement.MouseEnterEvent, new MouseEventHandler(element_MouseEnter));
                            element.AddHandler(UIElement.MouseLeaveEvent, new MouseEventHandler(element_MouseLeave));
                            element.AddHandler(UIElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(element_MouseLeftButtonDown));
                        }
                        var hmi = tagConn as HMIControlBase;
                        if (hmi != null && hmi.ShowCaption && !string.IsNullOrEmpty(hmi.Caption))
                        {
                            AdornerLayer lay = AdornerLayer.GetAdornerLayer(hmi);
                            if (lay != null)
                            {
                                TextAdorner frame = new TextAdorner(hmi);
                                frame.Text = hmi.Caption;
                                lay.Add(frame);
                            }
                        }
                    }
                }
            }
            var writer = taglink as ITagWriter;

            if (writer != null && !string.IsNullOrEmpty(writer.TagWriteText))
            {
                var delgts = new List <Delegate>();
                foreach (var item in writer.TagWriteText.GetListFromText())
                {
                    try
                    {
                        if (!string.IsNullOrEmpty(item.Value))
                        {
                            delgts.Add(eval.WriteEval(item.Key, item.Value));
                        }
                        else
                        {
                            delgts.Add(eval.WriteEval(item.Key));
                        }
                    }
                    catch (Exception e)
                    {
                        App.AddErrorLog(e);
                        MessageBox.Show(string.Format("设备{0}变量{1}写入PLC公式转换失败", taglink.Node, item.Key) + "\n" + e.Message);
                    }
                    writer.SetTagWriter(delgts);
                }
            }
        }