Exemplo n.º 1
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;
                }
            }
        }
Exemplo n.º 2
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!!!"));
        }
Exemplo n.º 3
0
        public DigitalOutput Connect(LogicalDevice.Switch logicalDevice)
        {
            logicalDevice.PowerChanged += (sender, e) =>
                {
                    this.physicalTrigger.Invoke(e.NewState);
                };

            return this;
        }
Exemplo n.º 4
0
        public Motor Connect(LogicalDevice.Motor logicalDevice)
        {
            logicalDevice.SpeedChanged += (sender, e) =>
                {
                    this.physicalTrigger(e.NewSpeed);
                };

            return this;
        }
Exemplo n.º 5
0
        public DigitalInput Connect(LogicalDevice.DigitalInput logicalDevice)
        {
            StateChanged += (sender, e) =>
                {
                    logicalDevice.Trigger(e.NewState);
                };

            return this;
        }
Exemplo n.º 6
0
        public AnalogInput Connect(LogicalDevice.AnalogInput3 logicalDevice)
        {
            ValueChanged += (sender, e) =>
            {
                logicalDevice.Value = e.NewBrightness;
            };

            return this;
        }
Exemplo n.º 7
0
        public PrimaryCommandBufferPool(Device vulkanDevice, uint FamilyIndex, int commandBufferCount)
        {
            this.LogicalDevice = vulkanDevice;
            var createPoolInfo = new CommandPoolCreateInfo {
                Flags = CommandPoolCreateFlags.ResetCommandBuffer, QueueFamilyIndex = FamilyIndex
            };

            this.CommandPool = LogicalDevice.CreateCommandPool(createPoolInfo);
            AllocateBuffers(commandBufferCount);
        }
Exemplo n.º 8
0
        void createModelDevices(NodeLD ld, IedModel model)
        {
            LogicalDevice ldevice = new LogicalDevice(ld.Name, model);

            ld.SCLServerModelObject = ldevice;

            foreach (NodeLN ln in ld.GetChildNodes())
            {
                createModelNodes(ln, ldevice);
            }
        }
Exemplo n.º 9
0
        public DigitalInput Connect(LogicalDevice.DigitalInput2 logicalDevice, bool reverse = false)
        {
            StateChanged += (sender, e) =>
            {
                if (reverse)
                    logicalDevice.Control.OnNext(!e.NewState);
                else
                    logicalDevice.Control.OnNext(e.NewState);
            };

            return this;
        }
Exemplo n.º 10
0
        protected override void AllocateBuffers(int v)
        {
            // var createPoolInfo = new CommandPoolCreateInfo { };
            //CommandPool = LogicalDevice.CreateCommandPool(createPoolInfo);
            var commandBufferAllocateInfo = new CommandBufferAllocateInfo
            {
                Level              = CommandBufferLevel.Primary,
                CommandPool        = this.CommandPool,
                CommandBufferCount = (uint)v
            };

            base.myFreeBuffers.AddRange(LogicalDevice.AllocateCommandBuffers(commandBufferAllocateInfo));
        }
Exemplo n.º 11
0
        public MotorWithFeedback Connect(LogicalDevice.MotorWithFeedback logicalDevice)
        {
            StatusChanged += (sender, e) =>
            {
                logicalDevice.Trigger(e.NewPos, e.Failed);
            };

            logicalDevice.VectorChanged += (sender, e) =>
                {
                    this.physicalTrigger(e.Vector.Target, e.Vector.Speed, e.Vector.Timeout);
                };

            return this;
        }
Exemplo n.º 12
0
        public Raspberry Connect(LogicalDevice.AudioPlayer logicalDevice)
        {
            this.AudioTrackDone += (o, e) =>
                {
                    logicalDevice.RaiseAudioTrackDone();
                };

            logicalDevice.AudioChanged += (sender, e) =>
                {
                    switch (e.Command)
                    {
                        case LogicalDevice.Event.AudioChangedEventArgs.Commands.PlayFX:
                            if (e.LeftVolume.HasValue && e.RightVolume.HasValue)
                                this.oscClient.Send("/audio/fx/play", e.AudioFile, (float)e.LeftVolume.Value, (float)e.RightVolume.Value);
                            else
                                this.oscClient.Send("/audio/fx/play", e.AudioFile);
                            break;

                        case LogicalDevice.Event.AudioChangedEventArgs.Commands.PlayNewFX:
                            if (e.LeftVolume.HasValue && e.RightVolume.HasValue)
                                this.oscClient.Send("/audio/fx/playnew", e.AudioFile, (float)e.LeftVolume.Value, (float)e.RightVolume.Value);
                            else
                                this.oscClient.Send("/audio/fx/playnew", e.AudioFile);
                            break;

                        case LogicalDevice.Event.AudioChangedEventArgs.Commands.CueFX:
                            this.oscClient.Send("/audio/fx/cue", e.AudioFile);
                            break;

                        case LogicalDevice.Event.AudioChangedEventArgs.Commands.CueTrack:
                            this.oscClient.Send("/audio/trk/cue", e.AudioFile);
                            break;

                        case LogicalDevice.Event.AudioChangedEventArgs.Commands.PlayTrack:
                            this.oscClient.Send("/audio/trk/play", e.AudioFile);
                            break;
                    }
                };

            logicalDevice.ExecuteCommand += (sender, e) =>
                {
                    switch (e.Command)
                    {
                        case LogicalDevice.Event.AudioCommandEventArgs.Commands.PlayBackground:
                            this.oscClient.Send("/audio/bg/play");
                            break;
                        case LogicalDevice.Event.AudioCommandEventArgs.Commands.PauseBackground:
                            this.oscClient.Send("/audio/bg/pause");
                            break;
                        case LogicalDevice.Event.AudioCommandEventArgs.Commands.ResumeFX:
                            this.oscClient.Send("/audio/fx/resume");
                            break;
                        case LogicalDevice.Event.AudioCommandEventArgs.Commands.PauseFX:
                            this.oscClient.Send("/audio/fx/pause");
                            break;
                        case LogicalDevice.Event.AudioCommandEventArgs.Commands.NextBackground:
                            this.oscClient.Send("/audio/bg/next");
                            break;
                        case LogicalDevice.Event.AudioCommandEventArgs.Commands.BackgroundVolume:
                            this.oscClient.Send("/audio/bg/volume", (float)((LogicalDevice.Event.AudioCommandValueEventArgs)e).Value);
                            break;
                        case LogicalDevice.Event.AudioCommandEventArgs.Commands.ResumeTrack:
                            this.oscClient.Send("/audio/trk/resume");
                            break;
                        case LogicalDevice.Event.AudioCommandEventArgs.Commands.PauseTrack:
                            this.oscClient.Send("/audio/trk/pause");
                            break;
                    }
                };

            return this;
        }
Exemplo n.º 13
0
        public Raspberry Connect(LogicalDevice.VideoPlayer logicalDevice)
        {
            this.VideoTrackDone += (o, e) =>
            {
                logicalDevice.RaiseVideoTrackDone();
            };

            logicalDevice.ExecuteCommand += (sender, e) =>
            {
                switch (e.Command)
                {
                    case LogicalDevice.Event.VideoCommandEventArgs.Commands.PlayVideo:
                        this.oscClient.Send("/video/play", e.VideoFile);
                        break;
                }
            };

            return this;
        }
Exemplo n.º 14
0
        public MonoExpanderInstance Connect(LogicalDevice.AudioPlayer logicalDevice)
        {
            this.AudioTrackDone += (o, e) =>
                {
                    logicalDevice.RaiseAudioTrackDone();
                };

            this.AudioTrackStart.Subscribe(x =>
                {
                    if (x.Item1 == AudioTypes.Track)
                        logicalDevice.RaiseAudioTrackStart(x.Item2);
                });

            logicalDevice.AudioChanged += (sender, e) =>
                {
                    switch (e.Command)
                    {
                        case LogicalDevice.Event.AudioChangedEventArgs.Commands.PlayNewFX:
                        case LogicalDevice.Event.AudioChangedEventArgs.Commands.PlayFX:
                            if (e.LeftVolume.HasValue && e.RightVolume.HasValue)
                                SendMessage(new AudioEffectPlay
                                {
                                    FileName = e.AudioFile,
                                    VolumeLeft = e.LeftVolume.Value,
                                    VolumeRight = e.RightVolume.Value,
                                    Simultaneous = e.Command == LogicalDevice.Event.AudioChangedEventArgs.Commands.PlayNewFX
                                });
                            else
                                SendMessage(new AudioEffectPlay
                                {
                                    FileName = e.AudioFile,
                                    Simultaneous = e.Command == LogicalDevice.Event.AudioChangedEventArgs.Commands.PlayNewFX
                                });
                            break;

                        case LogicalDevice.Event.AudioChangedEventArgs.Commands.CueFX:
                            SendMessage(new AudioEffectCue
                            {
                                FileName = e.AudioFile
                            });
                            break;

                        case LogicalDevice.Event.AudioChangedEventArgs.Commands.CueTrack:
                            SendMessage(new AudioTrackCue
                            {
                                FileName = e.AudioFile
                            });
                            break;

                        case LogicalDevice.Event.AudioChangedEventArgs.Commands.PlayTrack:
                            SendMessage(new AudioTrackPlay
                            {
                                FileName = e.AudioFile
                            });
                            break;
                    }
                };

            logicalDevice.ExecuteCommand += (sender, e) =>
                {
                    switch (e.Command)
                    {
                        case LogicalDevice.Event.AudioCommandEventArgs.Commands.PlayBackground:
                            SendMessage(new AudioBackgroundResume(), "play-bg");
                            break;

                        case LogicalDevice.Event.AudioCommandEventArgs.Commands.PauseBackground:
                            SendMessage(new AudioBackgroundPause(), "pause-bg");
                            break;

                        case LogicalDevice.Event.AudioCommandEventArgs.Commands.ResumeFX:
                            SendMessage(new AudioEffectResume());
                            break;

                        case LogicalDevice.Event.AudioCommandEventArgs.Commands.PauseFX:
                            SendMessage(new AudioEffectPause());
                            break;

                        case LogicalDevice.Event.AudioCommandEventArgs.Commands.NextBackground:
                            SendMessage(new AudioBackgroundNext());
                            break;

                        case LogicalDevice.Event.AudioCommandEventArgs.Commands.BackgroundVolume:
                            SendMessage(new AudioBackgroundSetVolume
                            {
                                Volume = ((LogicalDevice.Event.AudioCommandValueEventArgs)e).Value
                            }, "mv-bg");
                            break;

                        case LogicalDevice.Event.AudioCommandEventArgs.Commands.ResumeTrack:
                            SendMessage(new AudioTrackResume());
                            break;

                        case LogicalDevice.Event.AudioCommandEventArgs.Commands.PauseTrack:
                            SendMessage(new AudioTrackPause());
                            break;

                        case LogicalDevice.Event.AudioCommandEventArgs.Commands.EffectVolume:
                            SendMessage(new AudioEffectSetVolume
                            {
                                Volume = ((LogicalDevice.Event.AudioCommandValueEventArgs)e).Value
                            }, "mv-fx");
                            break;

                        case LogicalDevice.Event.AudioCommandEventArgs.Commands.TrackVolume:
                            SendMessage(new AudioTrackSetVolume
                            {
                                Volume = ((LogicalDevice.Event.AudioCommandValueEventArgs)e).Value
                            }, "mv-trk");
                            break;
                    }
                };

            return this;
        }
Exemplo n.º 15
0
        public MonoExpanderInstance Connect(LogicalDevice.VideoPlayer logicalDevice)
        {
            this.VideoTrackDone += (o, e) =>
            {
                logicalDevice.RaiseVideoTrackDone();
            };

            logicalDevice.ExecuteCommand += (sender, e) =>
            {
                switch (e.Command)
                {
                    case LogicalDevice.Event.VideoCommandEventArgs.Commands.PlayVideo:
                        SendMessage(new VideoPlay
                        {
                            FileName = e.VideoFile
                        });
                        break;
                }
            };

            return this;
        }
Exemplo n.º 16
0
 public void Connect(LogicalDevice.IPixel2D device, LogicalDevice.PixelMapper2D pixelMapper, int opcChannel)
 {
     device.Output.Subscribe(x =>
         {
             Send((byte)opcChannel, 0, pixelMapper.GetByteArray(x));
         });
 }
Exemplo n.º 17
0
 public LogicalNode(string name, LogicalDevice parent)
 {
     base.self = LogicalNode_create(name, parent.self);
 }
Exemplo n.º 18
0
 public LogicalNode(string name, LogicalDevice ldevice)
 {
     self = LogicalNode_create(name, ldevice.GetLibraryObject());
 }