private void ApplyButton_Click(object sender, EventArgs e) { CommonData.applied = true; Section current = CommonData.sectionList[CommonData.selectedArtic]; //Section current = new Section(); string articFullName = PossibleArtics.Text; string[] articNameSplit = articFullName.Split(new Char[] { '-' }, 2); CommonData.objectName = articNameSplit[0]; CommonData.articName = articNameSplit[1]; current.startTimeValue = StartTimeValue.Text; current.durationValue = DurationValue.Text; current.startValue = StartValue.Text; current.endValue = EndValue.Text; current.deadbandValue = DBValue.Text; current.accelValue = AcValue.Text; current.decelValue = DcValue.Text; current.dutyValue = DCDeltaValue.Text; current.periodValue = Period.Text; current.sectionName = sectionName.Text; current.articName = CommonData.articName; current.objectName = CommonData.objectName; string section = ArticFunctions.CreateSection(CommonData.objectName, CommonData.articName, current.startTimeValue, current.durationValue, current.startValue, current.endValue, current.deadbandValue, current.accelValue, current.decelValue, current.dutyValue, current.periodValue, current.sectionName); current.sectionText = section; CommonData.sectionList[CommonData.selectedArtic] = current; this.Close(); }
private void CreateButton_Click(object sender, EventArgs e) { CommonData.added = true; Section current = new Section(); current.isLinked = false; current.sectionNumber = CommonData.totalSectionCount + 1; current.startTimeValue = StartTimeValue.Text; current.durationValue = DurationValue.Text; current.startValue = StartValue.Text; current.endValue = EndValue.Text; current.deadbandValue = DBValue.Text; current.accelValue = AcValue.Text; current.decelValue = DcValue.Text; current.dutyValue = DCDeltaValue.Text; current.periodValue = Period.Text; current.sectionName = sectionName.Text; current.articName = CommonData.articName; current.objectName = CommonData.objectName; string section = ArticFunctions.CreateSection(CommonData.objectName, CommonData.articName, current.startTimeValue, current.durationValue, current.startValue, current.endValue, current.deadbandValue, current.accelValue, current.decelValue, current.dutyValue, current.periodValue, current.sectionName); current.sectionText = section; CommonData.sectionList.Add(current); this.Close(); }
private void Link_Click(object sender, EventArgs e) { if (IncrementCheck.Checked && String.IsNullOrWhiteSpace(IncrementStepValue.Text)) { MessageBox.Show("IncrementStep Value Required"); } else if (Events.SelectedIndex == -1) { MessageBox.Show("Please select Interval List"); } else { int index = Events.SelectedIndex; IAgCrdnEventIntervalList currentList; List <string> startTimes = new List <string>(); List <string> stopTimes = new List <string>(); string listName; if (cbStkObjects.Text.Contains("Access")) { currentList = accessEventIntervalsCollections[index]; IAgCrdn currentListRe = accessEventIntervalsCollections[index] as IAgCrdn; listName = currentListRe.Name; } else { currentList = eventIntervalsCollections[index]; IAgCrdn currentListRe = eventIntervalsCollections[index] as IAgCrdn; listName = currentListRe.Name; } IAgCrdnIntervalListResult intervals = currentList.FindIntervals(); int numIntervals = intervals.Intervals.Count; for (int i = 0; i < numIntervals; i++) { IAgCrdnInterval interval = intervals.Intervals[i]; string startStr = interval.Start.ToString(); string stopStr = interval.Stop.ToString(); startTimes.Add(startStr); stopTimes.Add(stopStr); } CommonData.sectionList[CommonData.selectedArtic].linkedToList = true; string linkedText; string line1 = "BEGIN SMARTEPOCH \n"; string line2 = "BEGIN EVENT \n"; string line3 = "Type EVENT_LINKTO \n"; string line4 = null; string line5 = null; linkedText = line1 + line2 + line3; if (typeEnum == 0) { if (cbStkObjects.Text.Contains("Access")) { for (int i = 0; i < startTimes.Count; i++) { string name = "ArticCreatorList_" + listName + "_" + "StartTime" + i.ToString(); CommonData.sectionList[CommonData.selectedArtic].linkedToListInstantNames.Add(name); IAgCrdnEvent timeEvent = null; if (access.Vgt.Events.Contains(name)) { foreach (IAgCrdnEvent @event in access.Vgt.Events) { // All events implement IAgCrdn interface which provides // information about the event instance and its type. IAgCrdn crdn = @event as IAgCrdn; if (crdn.Name == name) { timeEvent = @event; } } } else { timeEvent = access.Vgt.Events.Factory.CreateEventEpoch(name, "Description"); } IAgCrdnEventEpoch asEpoch = timeEvent as IAgCrdnEventEpoch; asEpoch.Epoch = startTimes[i]; IAgCrdn currentEvent = (IAgCrdn)timeEvent; string eventName = currentEvent.Name; string pathStr = currentEvent.Path; line4 = "Name " + eventName + " \n"; line5 = "RelativePath " + pathStr.Substring(0, pathStr.IndexOf(" ")) + " \n"; string line6 = "END EVENT" + " \n"; string line7 = "END SMARTEPOCH" + " \n"; string linkedTextFinal = linkedText + line4 + line5 + line6 + line7; CommonData.sectionList[CommonData.selectedArtic].linkedToListStrings.Add(linkedTextFinal); } } else { for (int i = 0; i < startTimes.Count; i++) { string name = "ArticCreatorList_" + listName + "_" + "StartTime" + i.ToString(); CommonData.sectionList[CommonData.selectedArtic].linkedToListInstantNames.Add(name); IAgCrdnEvent timeEvent = null; if (obj.Vgt.Events.Contains(name)) { foreach (IAgCrdnEvent @event in obj.Vgt.Events) { // All events implement IAgCrdn interface which provides // information about the event instance and its type. IAgCrdn crdn = @event as IAgCrdn; if (crdn.Name == name) { timeEvent = @event; } } } else { timeEvent = obj.Vgt.Events.Factory.CreateEventEpoch(name, "Description"); } IAgCrdnEventEpoch asEpoch = timeEvent as IAgCrdnEventEpoch; asEpoch.Epoch = startTimes[i]; IAgCrdn currentEvent = (IAgCrdn)timeEvent; string eventName = currentEvent.Name; string pathStr = currentEvent.Path; line4 = "Name " + eventName + " \n"; line5 = "RelativePath " + pathStr.Substring(0, pathStr.IndexOf(" ")) + " \n"; string line6 = "END EVENT" + " \n"; string line7 = "END SMARTEPOCH" + " \n"; string linkedTextFinal = linkedText + line4 + line5 + line6 + line7; CommonData.sectionList[CommonData.selectedArtic].linkedToListStrings.Add(linkedTextFinal); } } } else if (typeEnum == 1) { if (cbStkObjects.Text.Contains("Access")) { for (int i = 0; i < stopTimes.Count; i++) { string name = "ArticCreatorList_" + listName + "_" + "StopTime" + i.ToString(); CommonData.sectionList[CommonData.selectedArtic].linkedToListInstantNames.Add(name); IAgCrdnEvent timeEvent = null; if (access.Vgt.Events.Contains(name)) { foreach (IAgCrdnEvent @event in access.Vgt.Events) { // All events implement IAgCrdn interface which provides // information about the event instance and its type. IAgCrdn crdn = @event as IAgCrdn; if (crdn.Name == name) { timeEvent = @event; } } } else { timeEvent = access.Vgt.Events.Factory.CreateEventEpoch(name, "Description"); } IAgCrdnEventEpoch asEpoch = timeEvent as IAgCrdnEventEpoch; asEpoch.Epoch = stopTimes[i]; IAgCrdn currentEvent = (IAgCrdn)timeEvent; string eventName = currentEvent.Name; string pathStr = currentEvent.Path; line4 = "Name " + eventName + " \n"; line5 = "RelativePath " + pathStr.Substring(0, pathStr.IndexOf(" ")) + " \n"; string line6 = "END EVENT" + " \n"; string line7 = "END SMARTEPOCH" + " \n"; string linkedTextFinal = linkedText + line4 + line5 + line6 + line7; CommonData.sectionList[CommonData.selectedArtic].linkedToListStrings.Add(linkedTextFinal); } } else { for (int i = 0; i < startTimes.Count; i++) { string name = "ArticCreatorList_" + listName + "_" + "StopTime" + i.ToString(); CommonData.sectionList[CommonData.selectedArtic].linkedToListInstantNames.Add(name); IAgCrdnEvent timeEvent = null; if (obj.Vgt.Events.Contains(name)) { foreach (IAgCrdnEvent @event in obj.Vgt.Events) { // All events implement IAgCrdn interface which provides // information about the event instance and its type. IAgCrdn crdn = @event as IAgCrdn; if (crdn.Name == name) { timeEvent = @event; } } } else { timeEvent = obj.Vgt.Events.Factory.CreateEventEpoch(name, "Description"); } IAgCrdnEventEpoch asEpoch = timeEvent as IAgCrdnEventEpoch; asEpoch.Epoch = stopTimes[i]; IAgCrdn currentEvent = (IAgCrdn)timeEvent; string eventName = currentEvent.Name; string pathStr = currentEvent.Path; line4 = "Name " + eventName + " \n"; line5 = "RelativePath " + pathStr.Substring(0, pathStr.IndexOf(" ")) + " \n"; string line6 = "END EVENT" + " \n"; string line7 = "END SMARTEPOCH" + " \n"; string linkedTextFinal = linkedText + line4 + line5 + line6 + line7; CommonData.sectionList[CommonData.selectedArtic].linkedToListStrings.Add(linkedTextFinal); } } } if (IncrementCheck.Checked) { CommonData.sectionList[CommonData.selectedArtic].isIncremented = true; int numSections = intervals.Intervals.Count; double startValueOG = Convert.ToDouble(CommonData.sectionList[CommonData.selectedArtic].startValue); double stepValueDouble = Convert.ToDouble(IncrementStepValue.Text); for (int i = 0; i < numSections; i++) { LinkedListSection current = new LinkedListSection(); current.startValue = Convert.ToString((startValueOG + i * stepValueDouble)); current.endValue = Convert.ToString((startValueOG + (i + 1) * stepValueDouble)); current.startTimeValue = CommonData.sectionList[CommonData.selectedArtic].startTimeValue; current.durationValue = CommonData.sectionList[CommonData.selectedArtic].durationValue; current.deadbandValue = CommonData.sectionList[CommonData.selectedArtic].deadbandValue; current.accelValue = CommonData.sectionList[CommonData.selectedArtic].accelValue; current.dutyValue = CommonData.sectionList[CommonData.selectedArtic].dutyValue; current.decelValue = CommonData.sectionList[CommonData.selectedArtic].decelValue; current.periodValue = CommonData.sectionList[CommonData.selectedArtic].periodValue; current.sectionName = CommonData.sectionList[CommonData.selectedArtic].sectionName; string section = ArticFunctions.CreateSection(CommonData.sectionList[CommonData.selectedArtic].objectName, CommonData.sectionList[CommonData.selectedArtic].articName, current.startTimeValue, current.durationValue, current.startValue, current.endValue, current.deadbandValue, current.accelValue, current.decelValue, current.dutyValue, current.periodValue, current.sectionName); current.sectionText = section; CommonData.sectionList[CommonData.selectedArtic].linkedListSections.Add(current); } } ArticFunctions.CreateFile(CommonData.fileStr); this.Close(); } }