Esempio n. 1
0
        private void btnRemoveCondition_Click(object sender, EventArgs e)
        {
            if (m_CurrentExpression == m_ConditionalRoot)
            {
                m_ConditionalRoot = null;
            }
            else
            {
                LogicalNode selectedLogicalNode = (LogicalNode)tlvCondition.GetParent(m_CurrentExpression);
                if (selectedLogicalNode != null)
                {
                    selectedLogicalNode.Nodes.Remove(m_CurrentExpression);
                    if (selectedLogicalNode.Nodes.Count < 2)
                    {
                        //Remove logical node
                        LogicalNode parentLogicalNode = (LogicalNode)tlvCondition.GetParent(selectedLogicalNode);

                        if (parentLogicalNode != null && selectedLogicalNode.Nodes.Count == 0)
                        {
                            parentLogicalNode.Nodes.Remove(selectedLogicalNode);
                        }
                        else if (parentLogicalNode == null && selectedLogicalNode.Nodes.Count == 1)
                        {
                            //TODO when not drinking beer: resolve lowest level in loop in case nested logical node
                            m_ConditionalRoot = selectedLogicalNode.Nodes.First();
                            selectedLogicalNode.Nodes.Clear();
                        }
                    }
                }
            }
            m_CurrentExpression = null;
            zRefreshCondition();
        }
Esempio n. 2
0
        void createModelNodes(NodeLN ln, LogicalDevice ldevice)
        {
            LogicalNode lnode = new LogicalNode(ln.Name, ldevice);

            ln.SCLServerModelObject = lnode;

            foreach (NodeBase nb in ln.GetChildNodes())
            {
                if (nb is NodeDO)
                {
                    createData(nb, lnode);
                }
                else if (nb is NodeRCB)
                {
                    IEC61850.Common.ReportOptions  rptOptions = (IEC61850.Common.ReportOptions)(nb.FindChildNode("OptFlds") as NodeData).DataValue;
                    IEC61850.Common.TriggerOptions trgOptions = (IEC61850.Common.TriggerOptions)(nb.FindChildNode("TrgOps") as NodeData).DataValue;
                    string rptId   = (string)(nb.FindChildNode("RptID") as NodeData).DataValue;
                    string datSet  = (string)(nb.FindChildNode("DatSet") as NodeData).DataValue;
                    uint   confRev = (uint)(nb.FindChildNode("ConfRev") as NodeData).DataValue;
                    uint   bufTm   = (uint)(nb.FindChildNode("BufTm") as NodeData).DataValue;
                    uint   intgPd  = (uint)(nb.FindChildNode("IntgPd") as NodeData).DataValue;

                    datSet = datSet == "" ? null : datSet;

                    IEC61850.Server.ReportControlBlock rcb =
                        new IEC61850.Server.ReportControlBlock(nb.Name, lnode, rptId, (nb as NodeRCB).isBuffered, datSet, confRev, trgOptions, rptOptions, bufTm, intgPd);
                    nb.SCLServerModelObject = rcb;
                }
            }
        }
Esempio n. 3
0
 public void Visit(LogicalNode logical)
 {
     logical.Left.Parent = logical;
     logical.Left.Accept(this);
     logical.Right.Parent = logical;
     logical.Right.Accept(this);
 }
Esempio n. 4
0
        private XmlElement LogicalToXml(XmlDocument doc, LogicalNode node)
        {
            var doubleChildLogicalNode = node as DoubleChildLogicalNode;

            if (doubleChildLogicalNode != null)
            {
                return(this.DoubleChildToXml(doc, doubleChildLogicalNode));
            }

            var multiChildLogicalNode = node as MultiChildLogicalNode;

            if (multiChildLogicalNode != null)
            {
                return(this.MultiChildToXml(doc, multiChildLogicalNode));
            }

            var singleChildLogicalNode = node as SingleChildLogicalNode;

            if (singleChildLogicalNode != null)
            {
                return(this.SingleChildToXml(doc, singleChildLogicalNode));
            }

            var infixNumeric = node as InfixNumericLogicalNode;

            if (infixNumeric != null)
            {
                return(this.InfixNumericToXml(doc, infixNumeric));
            }

            return(this.CreateElement(doc, node));
        }
Esempio n. 5
0
        private void TestServer(object obj)
        {
            SCLServer self  = (SCLServer)obj;
            IedModel  model = new IedModel("bubak");

            LogicalDevice ldevice1 = new LogicalDevice("strasidlo", model);

            LogicalNode lln0 = new LogicalNode("LLN0", ldevice1);

            DataObject lln0_mod    = CDCFactory.CDC_ENG("Mod", lln0, CDCOptions.NONE);
            DataObject lln0_health = CDCFactory.CDC_ENG("Health", lln0, CDCOptions.NONE);

            SettingGroupControlBlock sgcb = new SettingGroupControlBlock(lln0, 1, 1);

            /* Add a temperature sensor LN */
            LogicalNode ttmp1       = new LogicalNode("TTMP1", ldevice1);
            DataObject  ttmp1_tmpsv = CDCFactory.CDC_SAV("TmpSv", ttmp1, 0, false);

            DataAttribute temperatureValue     = ttmp1_tmpsv.GetChild_DataAttribute("instMag.f");
            DataAttribute temperatureTimestamp = ttmp1_tmpsv.GetChild_DataAttribute("t");

            IEC61850.Server.DataSet dataSet = new IEC61850.Server.DataSet("events", lln0);
            DataSetEntry            dse     = new DataSetEntry(dataSet, "TTMP1$MX$TmpSv$instMag$f", -1, null);

            IEC61850.Common.ReportOptions rptOptions = IEC61850.Common.ReportOptions.SEQ_NUM | IEC61850.Common.ReportOptions.TIME_STAMP | IEC61850.Common.ReportOptions.REASON_FOR_INCLUSION;

            IEC61850.Server.ReportControlBlock rcb1 = new IEC61850.Server.ReportControlBlock("events01", lln0, "events01", false, null, 1, IEC61850.Common.TriggerOptions.DATA_CHANGED, rptOptions, 50, 0);
            IEC61850.Server.ReportControlBlock rcb2 = new IEC61850.Server.ReportControlBlock("events02", lln0, "events02", true, null, 1, IEC61850.Common.TriggerOptions.DATA_CHANGED | IEC61850.Common.TriggerOptions.GI, rptOptions, 50, 0);

            IedServer server = new IedServer(model);

            server.Start(tcpPort);

            logger.LogInfo(String.Format("SCL Server Started at port 102!!!"));

            float val = 0.0f;

            while (_run)
            {
                server.LockDataModel();
                temperatureValue.MmsValue.SetFloat(val);
                temperatureTimestamp.MmsValue.SetUtcTimeMs(Util.GetTimeInMs());
                server.UnlockDataModel();

                val += 0.1f;

                int waitres = WaitHandle.WaitAny(_waitHandles, 500);
                switch (waitres)
                {
                case 0:         // endthread
                    self._run = false;
                    break;

                case WaitHandle.WaitTimeout:
                    break;
                }
            }
            logger.LogInfo(String.Format("SCL Server Finished!!!"));
        }
Esempio n. 6
0
 void createVL(NodeVL vl, LogicalNode ln)
 {
     IEC61850.Server.DataSet dataSet = new IEC61850.Server.DataSet(vl.Name, ln);
     vl.SCLServerModelObject = dataSet;
     foreach (NodeVLM vlm in vl.GetChildNodes())
     {
         DataSetEntry dse = new DataSetEntry(dataSet, vlm.SCL_ServerLink, -1, null);
         vlm.SCLServerModelObject = dse;
     }
 }
Esempio n. 7
0
 public void Dispose()
 {
     renderTarget?.Dispose();
     if (LogicalNode is ImageNode)
     {
         primitive?.Dispose();
         primitive = null;
     }
     renderTarget = null;
     LogicalNode  = null;
 }
Esempio n. 8
0
        private void btnAddCondition_Click(object sender, EventArgs e)
        {
            Conditional    conditional   = (Conditional)Enum.Parse(typeof(Conditional), cbCondition.SelectedItem.ToString());
            ExpressionNode newExpression = new ExpressionNode();

            newExpression.StateVariable = cbVariable.Items[0].ToString();

            if (m_ConditionalRoot == null)
            {
                m_ConditionalRoot = newExpression;
            }
            else
            {
                LogicalNode selectedLogicalNode = (LogicalNode)tlvCondition.GetParent(m_CurrentExpression);
                if (selectedLogicalNode == null)
                {
                    m_ConditionalRoot = new LogicalNode()
                    {
                        Nodes = new List <ConditionNode>()
                        {
                            m_ConditionalRoot,
                            newExpression
                        },
                        ConditionalOperator = conditional
                    };
                }
                else if (selectedLogicalNode.ConditionalOperator != conditional)
                {
                    LogicalNode newLogicalNode = new LogicalNode()
                    {
                        Nodes = new List <ConditionNode>()
                        {
                            newExpression
                        },
                        ConditionalOperator = conditional
                    };
                    selectedLogicalNode.Nodes.Add(newLogicalNode);
                }
                else
                {
                    selectedLogicalNode.Nodes.Add(newExpression);
                }
            }

            m_CurrentExpression = newExpression;
            zUpdateExpressionBuilder();
            zRefreshCondition();

            btnRemoveCondition.Enabled     = true;
            panelExpressionBuilder.Enabled = true;
        }
Esempio n. 9
0
 public VisualNode(GraphicsDevice device, LogicalNode lnode)
 {
     this.LogicalNode             = lnode;
     this.graphicsDevice          = device;
     this.BackgroundColor         = Color.Transparent;
     this.ForegroundColor         = Color.Transparent;
     this.BorderColor             = Color.Transparent;
     this.fontSize                = 0;
     this.borderSize              = 0;
     this.text                    = "";
     this.VerticalTextAlignment   = VerticalAlignment.Top;
     this.HorizontalTextAlignment = HorizontalAlignment.Left;
     this.Primitive               = PrimitiveHandler.GetRectangle(device);
 }
Esempio n. 10
0
        void MergeConditionIntoTree(LogicalOperator desiredLogicalOperator, ConditionNode newCondition)
        {
            if (newCondition == null)
            {
                throw new ArgumentNullException("newCondition", "condition may not be null");
            }

            if (_topNode is LogicalNode && ((LogicalNode)_topNode).Operator == desiredLogicalOperator)
            {
                LogicalNode logicalNode = _topNode as LogicalNode;
                logicalNode.AddCondition(newCondition);
            }
            else
            {
                LogicalNode newTopNode = new LogicalNode(desiredLogicalOperator);
                newTopNode.AddCondition(_topNode);
                newTopNode.AddCondition(newCondition);
                _topNode = newTopNode;
            }
        }
Esempio n. 11
0
 public VisualNode(GraphicsDevice device, double width, double height, LogicalTree.LogicalNode lnode, Color backgroundColor, Color foregroundColor, Color borderColor,
                   string text = "", int fontSize = 12, int borderSize = 0, VerticalAlignment verticalTextAlignment = VerticalAlignment.Center,
                   HorizontalAlignment horizontalTextAlignment = HorizontalAlignment.Center, SpriteFont font = null)
 {
     graphicsDevice               = device;
     this.LogicalNode             = lnode;
     this.height                  = height;
     this.width                   = width;
     this.BackgroundColor         = backgroundColor;
     this.ForegroundColor         = foregroundColor;
     this.BorderColor             = borderColor;
     this.text                    = text;
     this.fontSize                = fontSize;
     this.borderSize              = borderSize;
     this.verticalTextAlignment   = verticalTextAlignment;
     this.horizontalTextAlignment = horizontalTextAlignment;
     renderTarget                 = new RenderTarget2D(device, (int)Math.Ceiling(width), (int)Math.Ceiling(height), false, SurfaceFormat.Color, DepthFormat.None, 0, RenderTargetUsage.PreserveContents);
     if (font != null)
     {
         this.font = font;
     }
 }
Esempio n. 12
0
        void MergeConditionIntoTree(LogicalOperator desiredLogicalOperator, ConditionNode newCondition)
        {
            if (newCondition == null)
            {
                throw new ArgumentNullException("newCondition", "condition may not be null");
            }

            if (_topNode is LogicalNode && ((LogicalNode)_topNode).Operator == desiredLogicalOperator)
            {
                // top node is already of the desired type, so just add into it
                LogicalNode logicalNode = _topNode as LogicalNode;
                logicalNode.AddCondition(newCondition);
            }
            else
            {
                // push existing top node down to be beneath this node...
                LogicalNode newTopNode = new LogicalNode(desiredLogicalOperator);
                newTopNode.AddCondition(_topNode);
                newTopNode.AddCondition(newCondition);
                _topNode = newTopNode;
            }
        }
Esempio n. 13
0
 public DataSet(string name, LogicalNode parentNode)
 {
     self = DataSet_create(name, parentNode.GetLibraryObject());
 }
Esempio n. 14
0
 /**
  * \brief create a new report control block (RCB)
  *
  * Create a new report control block (RCB) and add it to the given logical node (LN).
  *
  * \param name name of the RCB relative to the parent LN
  * \param parent the parent LN.
  * \param rptId of the report. If NULL the default report ID (object reference) is used.
  * \param isBuffered true for a buffered RCB - false for unbuffered RCB
  * \param dataSetName name (object reference) of the default data set or NULL if no data
  *        is set by default
  * \param confRef the configuration revision
  * \param trgOps the trigger options supported by this RCB (bit set)
  * \param options the inclusion options. Specifies what elements are included in a report (bit set)
  * \param bufTm the buffering time of the RCB in milliseconds (time between the first event and the preparation of the report).
  * \param intgPd integrity period in milliseconds
  *
  * \return the new RCB instance.
  */
 public ReportControlBlock(string name, LogicalNode parent, string rptId, bool isBuffered, string dataSetName, uint confRef, TriggerOptions trgOps, ReportOptions options, uint bufTm, uint intgPd)
 {
     self = ReportControlBlock_create(name, parent.GetLibraryObject(), rptId, isBuffered, dataSetName, confRef, (byte)trgOps, (byte)options, bufTm, intgPd);
 }
Esempio n. 15
0
        public override void Trigger(LogicalNode node)
        {
            string v = string.Copy(value);

            switch (eventTarget)
            {
            case Target.BorderColor:
                node.BorderColor = MonoMenu.ColorFromString(value);
                break;

            case Target.Background:
                node.Background = MonoMenu.ColorFromString(value);
                break;

            case Target.Foreground:
                node.Foreground = MonoMenu.ColorFromString(value);
                break;

            case Target.Height:
                if (value.Contains('%'))
                {
                    v = v.Replace(" ", "");
                    v = v.Replace("%", "");
                    node.PercentageHeight = true;
                }
                else
                {
                    node.PercentageHeight = false;
                }
                node.DesiredHeight = int.Parse(v);
                break;

            case Target.Width:
                if (value.Contains('%'))
                {
                    v = v.Replace(" ", "");
                    v = v.Replace("%", "");
                    node.PercentageWidth = true;
                }
                else
                {
                    node.PercentageWidth = false;
                }
                node.DesiredWidth = int.Parse(v);
                break;

            case Target.HorizontalAlignment:
                node.HorizontalAlignment = (HorizontalAlignment)Enum.Parse(typeof(HorizontalAlignment), value);
                break;

            case Target.VerticalAlignment:
                node.VerticalAlignment = (VerticalAlignment)Enum.Parse(typeof(VerticalAlignment), value);
                break;

            case Target.RelativeX:
                Point xnewPos = node.DesiredRelativePosition;
                if (value.Contains('%'))
                {
                    v = v.Replace(" ", "");
                    v = v.Replace("%", "");
                    node.PercentageX = true;
                }
                else
                {
                    node.PercentageX = false;
                }
                xnewPos.X = int.Parse(v);
                node.DesiredRelativePosition = xnewPos;
                break;

            case Target.RelativeY:
                Point ynewPos = node.DesiredRelativePosition;
                if (value.Contains('%'))
                {
                    v = v.Replace(" ", "");
                    v = v.Replace("%", "");
                    node.PercentageY = true;
                }
                else
                {
                    node.PercentageY = false;
                }
                ynewPos.Y = int.Parse(v);
                node.DesiredRelativePosition = ynewPos;
                break;

            case Target.BorderSize:
                node.BorderSize = int.Parse(value);
                break;

            case Target.FontSize:
                node.FontSize = int.Parse(value);
                break;

            case Target.Visibility:
                node.Visibility = (Visibility)Enum.Parse(typeof(Visibility), value);
                break;

            default:
                break;
            }
        }
Esempio n. 16
0
        void MergeConditionIntoTree(LogicalOperator desiredLogicalOperator, ConditionNode newCondition)
        {
            if (newCondition == null)
                throw new ArgumentNullException("newCondition", "condition may not be null");

            if (_topNode is LogicalNode && ((LogicalNode)_topNode).Operator == desiredLogicalOperator)
            {
                // top node is already of the desired type, so just add into it
                LogicalNode logicalNode = _topNode as LogicalNode;
                logicalNode.AddCondition(newCondition);
            }
            else
            {
                // push existing top node down to be beneath this node...
                LogicalNode newTopNode = new LogicalNode(desiredLogicalOperator);
                newTopNode.AddCondition(_topNode);
                newTopNode.AddCondition(newCondition);
                _topNode = newTopNode;
            }
        }
Esempio n. 17
0
 public virtual void Trigger(LogicalNode node)
 {
 }
Esempio n. 18
0
 public DataSet(string name, LogicalNode parent)
 {
     self = DataSet_create(name, parent.self);
 }
Esempio n. 19
0
 public ReportControlBlock(string name, LogicalNode parent, string rptId, bool isBuffered,
                           string dataSetName, uint confRev, byte trgOps, byte options, uint bufTm, uint intgPd)
 {
     self = ReportControlBlock_create(name, parent.self, rptId, isBuffered, dataSetName, confRev, trgOps, options, bufTm, intgPd);
 }
Esempio n. 20
0
        public override void Trigger(LogicalNode node)
        {
            BaseAnimation anim;
            string        from     = string.Copy(this.from);
            string        to       = string.Copy(this.to);
            Target        target   = this.eventTarget;
            TimeSpan      duration = TimeSpan.FromMilliseconds(double.Parse(this.duration));

            switch (eventTarget)
            {
            case Target.Height:
                if (to.Contains('%'))
                {
                    from = from.Replace(" ", "");
                    from = from.Replace("%", "");
                    to   = to.Replace(" ", "");
                    to   = to.Replace("%", "");
                    node.PercentageHeight = true;
                }
                else
                {
                    node.PercentageHeight = false;
                }
                break;

            case Target.Width:
                if (to.Contains('%'))
                {
                    from = from.Replace(" ", "");
                    from = from.Replace("%", "");
                    to   = to.Replace(" ", "");
                    to   = to.Replace("%", "");
                    node.PercentageWidth = true;
                }
                else
                {
                    node.PercentageWidth = false;
                }
                break;

            case Target.RelativeX:
                if (to.Contains('%'))
                {
                    from             = from.Replace(" ", "");
                    from             = from.Replace("%", "");
                    to               = to.Replace(" ", "");
                    to               = to.Replace("%", "");
                    node.PercentageX = true;
                }
                else
                {
                    node.PercentageX = false;
                }
                break;

            case Target.RelativeY:
                if (to.Contains('%'))
                {
                    from             = from.Replace(" ", "");
                    from             = from.Replace("%", "");
                    to               = to.Replace(" ", "");
                    to               = to.Replace("%", "");
                    node.PercentageY = true;
                }
                else
                {
                    node.PercentageY = false;
                }
                break;

            default:
                break;
            }
            if (target == Target.Background || target == Target.Foreground || target == Target.BorderColor)
            {
                anim = new ColorAnimation(animName, from, to, duration, node, target);
            }
            else
            {
                anim = new DoubleAnimation(animName, from, to, duration, node, target);
            }
            anim.Enable();
            node.AddAnimation(anim);
        }