/// <summary> /// Updates the tree node that represents a communication line and its child nodes. /// </summary> public void UpdateLineNode(TreeNode lineNode) { ArgumentNullException.ThrowIfNull(lineNode, nameof(lineNode)); try { lineNode.TreeView?.BeginUpdate(); // update line text and image CommNodeTag nodeTag = (CommNodeTag)lineNode.Tag; LineConfig lineConfig = (LineConfig)nodeTag.RelatedObject; lineNode.Text = CommUtils.GetLineTitle(lineConfig); lineNode.SetImageKey(lineConfig.Active ? ImageKey.Line : ImageKey.LineInactive); // remove existing device nodes foreach (TreeNode lineSubnode in new ArrayList(lineNode.Nodes)) { if (lineSubnode.TagIs(CommNodeType.Device)) { lineSubnode.Remove(); } } // add new device nodes foreach (DeviceConfig deviceConfig in lineConfig.DevicePolling) { lineNode.Nodes.Add(CreateDeviceNode(nodeTag.CommApp, deviceConfig)); } } finally { lineNode.TreeView?.EndUpdate(); } }
public LineConfig GetLineConfig() { var appConfig = new LineConfig(); _config.GetSection("Line").Bind(appConfig); return(appConfig); }
/// <summary> /// Finds the device within the communication line, or returns an insertion index. /// </summary> private static bool FindDevice(int deviceNum, LineConfig lineConfig, out DeviceConfig deviceConfig, out int insertIndex) { int index = 0; insertIndex = -1; foreach (DeviceConfig device in lineConfig.DevicePolling) { if (device.DeviceNum == deviceNum) { deviceConfig = device; return(true); } if (deviceNum < device.DeviceNum && insertIndex < 0) { insertIndex = index; } index++; } if (insertIndex < 0) { insertIndex = lineConfig.DevicePolling.Count; } deviceConfig = null; return(false); }
/// <summary> /// Add an edge to the document /// </summary> /// <param name="label">The label for the edge</param> /// <param name="sourceNode">The source node for the edge</param> /// <param name="destNode">The destination node for the edge</param> /// <returns>The edge config, or a pre-existing one if it already exists</returns> public LineConfig AddEdge(string label, BaseNodeConfig sourceNode, BaseNodeConfig destNode) { foreach (LineConfig edge in sourceNode.EdgesFrom) { if (IsEqual(edge.DestNode, destNode) && IsEqual(edge.SourceNode, sourceNode)) { return(edge); } if (edge.BiDirection) { if (IsEqual(edge.DestNode, sourceNode) && IsEqual(edge.SourceNode, destNode)) { return(edge); } } } LineConfig newedge = new LineConfig(sourceNode, destNode, false, label, false); List <LineConfig> edges = new List <LineConfig>(_lines); edges.Add(newedge); UpdateEdges(edges); return(newedge); }
/// <summary> /// Finds the communication line in the Communicator configuration, or returns an insertion index. /// </summary> private bool FindCommLine(int commLineNum, out LineConfig lineConfig, out int insertIndex) { int index = 0; insertIndex = -1; foreach (LineConfig line in commConfig.Lines) { if (line.CommLineNum == commLineNum) { lineConfig = line; return(true); } if (commLineNum < line.CommLineNum && insertIndex < 0) { insertIndex = index; } index++; } if (insertIndex < 0) { insertIndex = commConfig.Lines.Count; } lineConfig = null; return(false); }
private ChannelWrapper channel; // the communication channel /// <summary> /// Initializes a new instance of the class. /// </summary> private CommLine(LineConfig lineConfig, CoreLogic coreLogic) { LineConfig = lineConfig ?? throw new ArgumentNullException(nameof(lineConfig)); this.coreLogic = coreLogic ?? throw new ArgumentNullException(nameof(coreLogic)); infoFileName = Path.Combine(coreLogic.AppDirs.LogDir, CommUtils.GetLineLogFileName(CommLineNum, ".txt")); devices = new List <DeviceWrapper>(); deviceMap = new Dictionary <int, DeviceWrapper>(); deviceByNumAddr = new Dictionary <int, DeviceLogic>(); deviceByStrAddr = new Dictionary <string, DeviceLogic>(); commands = new Queue <TeleCommand>(); priorityPoll = new Queue <DeviceWrapper>(); thread = null; terminated = false; lineStatus = ServiceStatus.Undefined; lastInfoLength = 0; maxDeviceTitleLength = 0; channel = null; Title = CommUtils.GetLineTitle(CommLineNum, lineConfig.Name); SharedData = null; Log = new LogFile(LogFormat.Simple) { FileName = Path.Combine(coreLogic.AppDirs.LogDir, CommUtils.GetLineLogFileName(CommLineNum, ".log")), Capacity = coreLogic.Config.GeneralOptions.MaxLogSize }; }
private void PopulateDocumentFromGraph() { if (!_populatingControl) { List <BaseNodeConfig> nodes = new List <BaseNodeConfig>(); List <LineConfig> lines = new List <LineConfig>(); GraphData graph = netEditor.Graph; foreach (var n in graph.Nodes) { BaseNodeConfig node = (BaseNodeConfig)n.Tag; node.X = n.Center.X; node.Y = n.Center.Y; node.Z = n.Z; nodes.Add(node); } foreach (var l in graph.Lines) { bool isWeak = false; if (l.Tag != null) { isWeak = (bool)l.Tag; } LineConfig line = new LineConfig((BaseNodeConfig)l.SourceShape.Tag, (BaseNodeConfig)l.DestShape.Tag, l.BiDirection, l.Label, isWeak); lines.Add(line); } _document.UpdateGraph(nodes.ToArray(), lines.ToArray()); } }
protected override void OnAfterRender(bool firstRender) { foreach (var metric in Metrics) { data.Add(new { dateValue = metric.DateValue, value = (Type == ChartType.CPU) ? ((metric.CpuValue / (1024))) : ((metric.RamValue / (1024))) }); } chartMetricConfiguration = new LineConfig { XField = "dateValue", YField = "value", Color = new[] { "#82d1de" }, ForceFit = true, Height = Height, XAxis = new ValueCatTimeAxis { Type = "dateTime", TickCount = 5 } }; chartRef.ChangeData(data); base.OnAfterRender(firstRender); }
/// <summary> /// Creates a communication line, communication channel and devices. /// </summary> public static CommLine Create(LineConfig lineConfig, CoreLogic coreLogic, DriverHolder driverHolder) { // create communication line CommLine commLine = new CommLine(lineConfig, coreLogic); // create communication channel if (string.IsNullOrEmpty(lineConfig.Channel.TypeName)) { ChannelLogic channelLogic = new ChannelLogic(commLine, lineConfig.Channel); commLine.channel = new ChannelWrapper(channelLogic, commLine.Log); } else if (driverHolder.GetDriver(lineConfig.Channel.Driver, out DriverLogic driverLogic)) { ChannelLogic channelLogic = driverLogic.CreateChannel(commLine, lineConfig.Channel); commLine.channel = new ChannelWrapper(channelLogic, commLine.Log); } else { throw new ScadaException(Locale.IsRussian ? "Драйвер для создания канала связи не найден." : "Driver for creating communication channel not found."); } // create devices foreach (DeviceConfig deviceConfig in lineConfig.DevicePolling) { if (driverHolder.GetDriver(deviceConfig.Driver, out DriverLogic driverLogic)) { DeviceLogic deviceLogic = driverLogic.CreateDevice(commLine, deviceConfig); commLine.AddDevice(deviceLogic); } } return(commLine); }
protected void InitComponent() { options = new LineOptions { Responsive = true, Title = new OptionsTitle { Display = false, Text = "" }, Legend = new Legend { Position = Position.Right, Labels = new LegendLabelConfiguration { UsePointStyle = true } }, Tooltips = new Tooltips { Mode = InteractionMode.Nearest, Intersect = false }, Scales = new Scales { xAxes = new List <CartesianAxis> { new TimeAxis { Distribution = TimeDistribution.Linear, Ticks = new TimeTicks { Source = TickSource.Data }, Time = new TimeOptions { Unit = TimeMeasurement.Millisecond, Round = TimeMeasurement.Millisecond, TooltipFormat = "DD.MM.YYYY HH:mm:ss:SSS", DisplayFormats = TimeDisplayFormats.DE_CH }, ScaleLabel = new ScaleLabel { LabelString = "Time" } } } }, Hover = new LineOptionsHover { Intersect = true, Mode = InteractionMode.Y } }; config = new LineConfig(); }
public ChartHolder(FuzzyVariable fuzzyVariable) { this.parent_variable = fuzzyVariable; this.Config = new LineConfig { Options = new LineOptions { Animation = new Animation() { Duration = 0, }, Responsive = true, Title = new OptionsTitle { Display = true, Text = $"Zmienna lingwistyczna XXXX: YYYYY" }, Tooltips = new Tooltips { Mode = InteractionMode.Nearest, Intersect = true }, Hover = new LineOptionsHover { Mode = InteractionMode.Nearest, Intersect = true }, Scales = new Scales { xAxes = new List <CartesianAxis> { new LinearCartesianAxis { ScaleLabel = new ScaleLabel("Dziedzina"), Ticks = new ChartJs.Blazor.ChartJS.Common.Axes.Ticks.LinearCartesianTicks() { Min = null, // != null Max = null }, } }, yAxes = new List <CartesianAxis> { new LinearCartesianAxis { Ticks = new ChartJs.Blazor.ChartJS.Common.Axes.Ticks.LinearCartesianTicks() { Min = 0.0, Max = 1.0 }, ScaleLabel = new ScaleLabel("Przynależność") } } } } }; }
/// <summary> /// Remove an edge from the document /// </summary> /// <param name="edge">The edge to remove</param> public void RemoveEdge(LineConfig edge) { List <LineConfig> edges = new List <LineConfig>(_lines); edges.RemoveAll(l => IsEqual(edge, l)); UpdateGraph(_nodes, edges); }
/// <summary> /// Initializes a new instance of the class. /// </summary> public FrmDeviceProps(AppDirs appDirs, LineConfig lineConfig, DeviceConfig deviceConfig, CustomUi customUi) : this() { this.appDirs = appDirs ?? throw new ArgumentNullException(nameof(appDirs)); this.lineConfig = lineConfig ?? throw new ArgumentNullException(nameof(lineConfig)); this.deviceConfig = deviceConfig ?? throw new ArgumentNullException(nameof(deviceConfig)); this.customUi = customUi ?? throw new ArgumentNullException(nameof(customUi)); }
/// <summary> /// Updates text of the tree node that represents a communication line. /// </summary> public static void UpdateLineNodeText(TreeNode lineNode) { ArgumentNullException.ThrowIfNull(lineNode, nameof(lineNode)); CommNodeTag nodeTag = (CommNodeTag)lineNode.Tag; LineConfig lineConfig = (LineConfig)nodeTag.RelatedObject; lineNode.Text = CommUtils.GetLineTitle(lineConfig); }
public RippleLineChartText() { _chartConfig = CreateNewChartConfig(); _showOnlyGraph = false; _xAxis = (TimeAxis)_chartConfig.Options.Scales.XAxes.First(); _yAxis1 = (LinearCartesianAxis)_chartConfig.Options.Scales.YAxes[0]; _yAxis2 = (LinearCartesianAxis)_chartConfig.Options.Scales.YAxes[1]; }
/// <summary> /// Creates a communication line, communication channel and devices. /// </summary> public static CommLine Create(LineConfig lineConfig, CoreLogic coreLogic, DriverHolder driverHolder) { // create communication line CommLine commLine = new CommLine(lineConfig, coreLogic); // create communication channel if (string.IsNullOrEmpty(lineConfig.Channel.Driver)) { ChannelLogic channelLogic = new ChannelLogic(commLine, lineConfig.Channel); // stub commLine.channel = new ChannelWrapper(channelLogic, commLine.Log); } else if (driverHolder.GetDriver(lineConfig.Channel.Driver, out DriverLogic driverLogic)) { ChannelLogic channelLogic = driverLogic.CreateChannel(commLine, lineConfig.Channel); commLine.channel = new ChannelWrapper(channelLogic, commLine.Log); } else { throw new ScadaException(Locale.IsRussian ? "Драйвер канала связи {0} не найден." : "Communication channel driver {0} not found.", lineConfig.Channel.Driver); } // create devices foreach (DeviceConfig deviceConfig in lineConfig.DevicePolling) { if (deviceConfig.Active && !coreLogic.DeviceExists(deviceConfig.DeviceNum)) { if (driverHolder.GetDriver(deviceConfig.Driver, out DriverLogic driverLogic)) { DeviceLogic deviceLogic = driverLogic.CreateDevice(commLine, deviceConfig); if (deviceLogic == null) { throw new ScadaException(Locale.IsRussian ? "Не удалось создать устройство {0}." : "Unable to create device {0}.", deviceConfig.Title); } commLine.AddDevice(deviceLogic); } else { throw new ScadaException(Locale.IsRussian ? "Драйвер {0} для устройства {1} не найден." : "Driver {0} for device {1} not found.", deviceConfig.Driver, deviceConfig.Title); } } } // prepare channel after adding devices commLine.channel.ChannelLogic.MakeReady(); return(commLine); }
void Awake() { lineConfig = gameObject.AddComponent <LineConfig> (); btn1.onClick.AddListener(() => SetThickness(1)); btn2.onClick.AddListener(() => SetThickness(2)); btn3.onClick.AddListener(() => SetThickness(3)); btn4.onClick.AddListener(() => SetThickness(4)); btn5.onClick.AddListener(() => SetThickness(5)); btn6.onClick.AddListener(() => SetThickness(6)); }
/// <summary> /// Initializes a new instance of the class. /// </summary> public FrmLineConfig(IAdminContext adminContext, CommApp commApp, LineConfig lineConfig) : this() { this.adminContext = adminContext ?? throw new ArgumentNullException(nameof(adminContext)); this.commApp = commApp ?? throw new ArgumentNullException(nameof(commApp)); this.lineConfig = lineConfig ?? throw new ArgumentNullException(nameof(lineConfig)); mainOptionsReady = false; customOptionsReady = false; devicePollingReady = false; }
/// <summary> /// Initializes a new instance of the class. /// </summary> public DeviceView(DriverView parentView, LineConfig lineConfig, DeviceConfig deviceConfig) : base(parentView) { AppConfig = parentView.AppConfig; LineConfig = lineConfig ?? throw new ArgumentNullException(nameof(lineConfig)); DeviceConfig = deviceConfig ?? throw new ArgumentNullException(nameof(deviceConfig)); DeviceNum = deviceConfig.DeviceNum; LineConfigModified = false; DeviceConfigModified = false; }
public static LineConfig GetLineConfig() { LineConfig _config = new LineConfig() { Options = new LineOptions { Responsive = true, Title = new OptionsTitle { Display = true, Padding = 0, FontSize = 20, FontColor = "#f2f2f2", Text = "Loading ..." }, Scales = new Scales { XAxes = new List <CartesianAxis> { new CategoryAxis { ScaleLabel = new ScaleLabel { LabelString = "Dates" }, Ticks = new CategoryTicks() { FontColor = "#919191" } } }, YAxes = new List <CartesianAxis> { new LinearCartesianAxis { ScaleLabel = new ScaleLabel { LabelString = "Winrate" }, Ticks = new LinearCartesianTicks() { BeginAtZero = false, FontColor = "#919191" } } } } } }; //_config.Options.Plugins.Add("datalabels", new ChartJsPluginDatalabelOptions() { display = false }); //_config.Options.Plugins.Add("labels", new ChartJsPluginLabelOptions()); return(_config); }
private async Task <LineConfig> CreateNewUserConfig( ChartTimeFrame tf, bool avgUserPerHour = false) { LineConfig config = null; if (!avgUserPerHour) { if (newUserConfig == null) { newUserConfig = new LineConfig(); } config = newUserConfig; } else { if (commonHoursNewUsers == null) { commonHoursNewUsers = new LineConfig(); } config = commonHoursNewUsers; } config.Options = new LineOptions() { Responsive = true, Title = new ChartJs.Blazor.Common.OptionsTitle() { Display = true, Text = avgUserPerHour ? "Users per hour" : "New users of " + GetName(tf) }, Scales = new Scales { XAxes = new List <CartesianAxis> { new CategoryAxis { ScaleLabel = new ScaleLabel { LabelString = GetLabel(tf) } } }, YAxes = new List <CartesianAxis> { new LinearCartesianAxis { ScaleLabel = new ScaleLabel { LabelString = "Value" } } } } }; return(await UpdateDatasetAsync(config, tf, avgUserPerHour)); }
private DeviceConfig deviceClipboard; // contains the copied device /// <summary> /// Initializes a new instance of the class. /// </summary> public CtrlLinePolling() { InitializeComponent(); numNumAddress.Maximum = int.MaxValue; SetColumnNames(); adminContext = null; commApp = null; lineConfig = null; changing = false; deviceClipboard = null; }
public HttpResponseMessage AddScheduleConfig([FromUri] int structId, [FromBody] LineConfig config) { using (var db = new SecureCloud_Entities()) { try { IQueryable <T_DIM_STRUCTUER_LINE> ScheduleConfig = from q in db.T_DIM_STRUCTUER_LINE where q.Id == config.LineId && q.Line_Name == config.LineName && q.Line_Length == config.LineLength && q.Start_Id == config.StartId && q.End_Id == config.EndId && q.Structure_Id == config.structureId select q; if (ScheduleConfig != null && ScheduleConfig.Count() != 0) { //判断是否有重复 //#region 日志信息 //this.Request.Properties["ActionParameter"] = JsonConvert.SerializeObject(config); //this.Request.Properties["ActionParameterShow"] // = string.Format("线路编号:{0},线路名称:{1},线路长度:{2},开始位置Id:{3},结束位置Id:{4},结构物Id:{5}", // config.LineId, // config.LineName, // config.LineLength, // config.StartId, // config.EndId, // config.structureId); //#endregion return(Request.CreateResponse(HttpStatusCode.NotAcceptable, StringHelper.GetMessageString("线路配置已存在"))); } var us = new T_DIM_STRUCTUER_LINE { Id = config.LineId, Line_Name = config.LineName, Line_Length = config.LineLength, Start_Id = config.StartId, End_Id = config.EndId, Structure_Id = config.structureId, Color = config.Color ?? null, Unit = config.Unit }; db.T_DIM_STRUCTUER_LINE.Add(us); db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.Accepted, StringHelper.GetMessageString("线路配置添加成功"))); } catch (Exception e) { return(Request.CreateResponse(HttpStatusCode.BadRequest, StringHelper.GetMessageString("线路配置添加失败"))); } } }
protected override void OnInitialized() { pieChartComponent = new PieChartComponent(); lineChartComponent = new LineChartComponent(); LastTsStatistics = DateTime.Now.ToString("dddd, dd MMMM yyyy - HH:mm:ss"); LastTsAlerts = DateTime.Now.ToString("dddd, dd MMMM yyyy - HH:mm:ss"); _pieconfig = pieChartComponent.config; _lineConfig = lineChartComponent.config; Twin = new TwinEntity(); Twin.Init(); Alerts = AlertService.GetAlertsAsync(); }
/// <summary> /// Checks feasibility of adding a device. /// </summary> private bool CheckFeasibility(out LineConfig lineConfig) { lineConfig = null; int deviceNum = Convert.ToInt32(numDeviceNum.Value); int commLineNum = (int)cbCommLine.SelectedValue; // check that device does not exist in the configuration database if (project.ConfigDatabase.DeviceTable.PkExists(deviceNum)) { ScadaUiUtils.ShowError(ExtensionPhrases.DeviceExistsInConfigDatabase); return(false); } if (chkAddToComm.Checked && cbInstance.SelectedItem is ProjectInstance instance && instance.CommApp.Enabled) { // check that communication line is selected if (commLineNum <= 0) { ScadaUiUtils.ShowError(ExtensionPhrases.ChooseLine); return(false); } // load instance configuration if (!instance.LoadAppConfig(out string errMsg)) { ScadaUiUtils.ShowError(errMsg); return(false); } // reverse search for communication line lineConfig = instance.CommApp.AppConfig.Lines.FindLast(line => line.CommLineNum == commLineNum); if (lineConfig == null) { ScadaUiUtils.ShowError(ExtensionPhrases.LineNotFoundInCommConfig); return(false); } // check that device does not exist in communication line if (lineConfig.DevicePolling.Any(device => device.DeviceNum == deviceNum)) { ScadaUiUtils.ShowError(ExtensionPhrases.DeviceExistsInLineConfig); return(false); } } return(true); }
private void SetConfig() { Config = new LineConfig { Options = new LineOptions { Responsive = true, Title = new OptionsTitle { Display = true, Text = "Temprature" }, Tooltips = new Tooltips { Mode = InteractionMode.Nearest, Intersect = true }, Hover = new Hover { Mode = InteractionMode.Nearest, Intersect = true }, Scales = new Scales { XAxes = new List <CartesianAxis> { new CategoryAxis { ScaleLabel = new ScaleLabel { LabelString = "Time" } } }, YAxes = new List <CartesianAxis> { new LinearCartesianAxis { ScaleLabel = new ScaleLabel { LabelString = "Temp (in Celsius ) " } } } } } }; }
/// <summary> /// Initializes a new instance of the class. /// </summary> public FrmLineStats(IAdminContext adminContext, LineConfig lineConfig) : this() { this.adminContext = adminContext ?? throw new ArgumentNullException(nameof(adminContext)); this.lineConfig = lineConfig ?? throw new ArgumentNullException(nameof(lineConfig)); stateBox = new RemoteLogBox(lbState) { FullLogView = true }; logBox = new RemoteLogBox(lbLog, true) { AutoScroll = true }; stateTabActive = true; isClosed = false; }
public ClusterChart() { chartMetricConfiguration = new LineConfig { XField = "dateValue", YField = "value", Color = new[] { "#82d1de" }, ForceFit = true, Height = Height, XAxis = new ValueCatTimeAxis { Type = "dateTime", TickCount = 5 } }; }
protected override void OnInitialized() { _config = new LineConfig { Options = new LineOptions { Title = new OptionsTitle { Display = true, Text = "Interaction chart" }, Responsive = true, Scales = new Scales { xAxes = new List <CartesianAxis>() { new LinearCartesianAxis { Display = AxisDisplay.True, Position = Position.Bottom, ScaleLabel = new ScaleLabel { Display = true, LabelString = "MRd" } } }, yAxes = new List <CartesianAxis>() { new LinearCartesianAxis { Display = AxisDisplay.True, Position = Position.Bottom, ScaleLabel = new ScaleLabel { Display = true, LabelString = "NRd" }, Ticks = new LinearCartesianTicks { Reverse = true, BeginAtZero = false, } } }, } } }; DiagramDatas = intCalcService.ResultsAsPoint; ForcesDatas = intCalcService.ForcesPoints; SetDiagramDatasActions(); SetForcesDatasActions(); }
private async Task <LineConfig> UpdateDatasetAsync( LineConfig config, ChartTimeFrame tf, bool avgUserPerHour) { var now = DateTime.UtcNow; var start = GetStartTime(tf, avgUserPerHour); var labels = GetChartLabels(tf, avgUserPerHour); config.Data.Labels.Clear(); foreach (var lb in labels) { config.Data.Labels.Add(lb); } var userData = await UserService.GetUsersByCreatedAsync(start, now); var outputData = GetChartData(userData, start, labels.Count, tf, avgUserPerHour); var total = outputData.Length > 0 ? outputData.Sum() : 0; LineDataset <int> dataset = new ChartJs.Blazor.LineChart.LineDataset <int>(outputData) { Label = "New users (" + total + ")", }; config.Data.Datasets.Clear(); config.Data.Datasets.Add(dataset); try { if (string.IsNullOrEmpty(config?.Options?.Title?.Text?.SingleValue)) { return(config); } var title = config?.Options?.Title?.Text?.SingleValue; if (outputData != null && outputData.Length > 0 && title != null) { config.Options.Title.Text = title + " - Total " + total; } } catch { } return(config); }