private void GetExternalChannelInfo() { try { m_Pro.GetChannelSetInfo(); m_Pro.GetYBChannelInfo(); int RowCount = ProDefine.g_ChannelInfos.Count; int ColNum = 7; for (int i = 0; i < RowCount; i++) { ChannelInfos csi = ProDefine.g_ChannelInfos[i]; int kindex = this.dataGridView1.Rows.Add(); this.dataGridView1.Rows[kindex].Cells[0].Value = csi.IsFunctionSelect; this.dataGridView1.Rows[kindex].Cells[1].Value = csi.FucntionName; this.dataGridView1.Rows[kindex].Cells[2].Value = csi.FunctionType; this.dataGridView1.Rows[kindex].Cells[3].Value = csi.XianHao; this.dataGridView1.Rows[kindex].Cells[4].Value = csi.Duanzi; this.dataGridView1.Rows[kindex].Cells[5].Value = csi.Hz; this.dataGridView1.Rows[kindex].Cells[6].Value = csi.PerCount; } } catch (System.Exception ex) { } }
/* * * public void RefreshChannelInfo(Dictionary<string, DTSEquip> equipinfos, Dictionary<string, List<ChannelInfos>> channelInfos) * { * // Dictionary<string, List<ChannelInfos>> channelInfos = ReadChannelCfg.Create().ExistChannels; * foreach (KeyValuePair<string, List<ChannelInfos>> kvp in channelInfos) * kvp.Value.Sort((x, y) => x.ChannelNum.CompareTo(y.ChannelNum)); //按照通道号排序 * * * //根据EquipInfos更新channelsInfos * foreach (KeyValuePair<string, DTSEquip> kvp in equipinfos) * { * int newchannelcount = kvp.Value.ChannelCount; * if (channelInfos.Keys.Contains(kvp.Key)) * { * //比较两者的通道数 * int oldchannelcount = channelInfos[kvp.Key].Count; * int[] channels = new int[newchannelcount + 1]; * for (int j = 0; j < oldchannelcount; j++) * { * ushort temp = channelInfos[kvp.Key][j].ChannelNum; * for (int i = 1; i < channels.Length; i++) * { * if (i == temp) * { * channels[i] = temp; * break; * } * } * } * if (newchannelcount > oldchannelcount) * { * int index = 1; * for (int i = 1; i <= newchannelcount - oldchannelcount; i++) * { * for (int j = index; j < channels.Length; j++) * { * if (channels[j] == 0) * { * channels[j] = j; * ChannelInfos temp = new ChannelInfos(); * temp.ChannelNum = (ushort)j; * temp.ZoneCount = 1; * temp.BaseTemp = 30; * temp.MeasureTime = 5; * temp.SampleInterval = 40; * temp.FiberLen = 10000; * channelInfos[kvp.Key].Add(temp); * * channelInfos[kvp.Key].Sort((x, y) => x.ChannelNum.CompareTo(y.ChannelNum)); * index = j + 1; * break; * } * } * } * } * else if (newchannelcount < oldchannelcount) * { * // channelinfos[kvp.Key].RemoveRange(0, oldchannelcount - newchannelcount); * channelInfos[kvp.Key].Sort((x, y) => x.ChannelNum.CompareTo(y.ChannelNum)); * int len = channelInfos[kvp.Key].Count; * channelInfos[kvp.Key].RemoveRange(len - (oldchannelcount - newchannelcount), oldchannelcount - newchannelcount); * } * } * else * { * //添加该设备以及设备对应的通道数 * List<ChannelInfos> channels = new List<ChannelInfos>(); * for (int j = 1; j <= newchannelcount; j++) * { * ChannelInfos temp = new ChannelInfos(); * temp.ChannelNum = (ushort)j; * temp.BaseTemp = 30; * temp.ZoneCount = 1; * temp.MeasureTime = 5; * temp.SampleInterval = 40; * temp.FiberLen = 10000; * channels.Add(temp); * } * channelInfos.Add(kvp.Key, channels); * } * } * * //删除channelcfg配置文件中多余的主机 * string[] newkeys = equipinfos.Keys.ToArray(); * if (newkeys.Length > 0) * { * string[] oldkeys1 = channelInfos.Keys.ToArray(); * string[] dif = oldkeys1.Except(newkeys).ToArray(); * * if (dif.Length > 0) * { * for (int i = 0; i < dif.Length; i++) * { * channelInfos.Remove(dif[i]); * } * } * } * * ReadChannelCfg.Create().SetValue(channelInfos); * * CombineEquipChannelZoneInfo(EquipInfos); * } * * * public void RefreshZoneInfo(Dictionary<string, List<ChannelInfos>> channelinfos, Dictionary<string, List<ChannelInfos>> zoneinfos) * { * * foreach (KeyValuePair<string, List<ChannelInfos>> kvp in channelinfos) * { * int channelcount = kvp.Value.Count; * if (!zoneinfos.Keys.Contains(kvp.Key)) //添加设备 * { * List<ChannelInfos> ci = new List<ChannelInfos>(); * zoneinfos.Add(kvp.Key, ci); * } * * for(int i=0;i<channelcount;i++) * { * ChannelInfos channel = zoneinfos[kvp.Key].Find(delegate (ChannelInfos c) { return c.ChannelNum == ushort.Parse(channelinfos[kvp.Key][i].ChannelNum.ToString()); }); * int channelindex = zoneinfos[kvp.Key].FindIndex(item => item.ChannelNum == ushort.Parse(channelinfos[kvp.Key][i].ChannelNum.ToString())); * if (channel == null) //添加通道 * { * ChannelInfos ci = new ChannelInfos(); * ci.ChannelNum = channelinfos[kvp.Key][i].ChannelNum; * zoneinfos[kvp.Key].Add(ci); * } * } * } * * //更新分区 * foreach (KeyValuePair<string, List<ChannelInfos>> kvp in channelinfos) * { * int channelcount = kvp.Value.Count; * if (zoneinfos.Keys.Contains(kvp.Key)) * { * for (int i = 0; i < channelcount; i++) * { * int channelzonecount = channelinfos[kvp.Key][i].ZoneCount; * float fiberlen = channelinfos[kvp.Key][i].FiberLen; * float sampleinterval = channelinfos[kvp.Key][i].SampleInterval; * * ChannelInfos channel = zoneinfos[kvp.Key].Find(delegate (ChannelInfos c) { return c.ChannelNum == ushort.Parse(channelinfos[kvp.Key][i].ChannelNum.ToString()); }); * int channelindex = zoneinfos[kvp.Key].FindIndex(item => item.ChannelNum == ushort.Parse(channelinfos[kvp.Key][i].ChannelNum.ToString())); * * //比较分区数 * if (channelzonecount != channel.ZoneTempInfos.Count) * { * channel.ZoneTempInfos = new List<ZoneTempInfo>(); * for (int j = 0; j < channelzonecount; j++) * { * ZoneTempInfo zone = new ZoneTempInfo(); * zone.ZoneNumber = (ushort)(j + 1); * zone.ZoneName = (j + 1).ToString(); * if (j == 0) * zone.StartPos = 0; * else * zone.StartPos = j * sampleinterval; * * if (j == channelzonecount - 1) * zone.StopPos = fiberlen; * else * zone.StopPos = j * sampleinterval + sampleinterval; * zone.TempRiseThreshold = AlarmZones.DefaultTempRiseThres; * zone.ConsTempThreshold = AlarmZones.DefaultConsTempThres; * zone.RegionTempDifThreshold = AlarmZones.DefaultRegionTempDifThres; * zone.TempRiseFlag = false; * zone.ConsTempFlag = false; * zone.RegionTempDifFlag = false; * zone.FiberBreakFlag = false; * channel.ZoneTempInfos.Add(zone); * } * } * } * } * } * * //删除alarmzonecfg中多余的主机 * string[] newkeys = channelinfos.Keys.ToArray(); * if (newkeys.Length > 0) * { * string[] oldkeys1 = zoneinfos.Keys.ToArray(); * string[] dif = oldkeys1.Except(newkeys).ToArray(); * * if (dif.Length > 0) * { * for (int i = 0; i < dif.Length; i++) * { * zoneinfos.Remove(dif[i]); * } * } * } * * //删除alarmzonecfg中多余的通道 * foreach (KeyValuePair<string, List<ChannelInfos>> kvp in zoneinfos) * { * int count = kvp.Value.Count; * for(int i=0;i<count;i++) * { * ChannelInfos channel = channelinfos[kvp.Key].Find(delegate (ChannelInfos c) { return c.ChannelNum == ushort.Parse(kvp.Value[i].ChannelNum.ToString()); }); * if(channel == null) * { * zoneinfos[kvp.Key].RemoveAt(i); * } * } * } * * ReadAlarmZoneCfg.Create().SetValue(zoneinfos); * * CombineEquipChannelZoneInfo(EquipInfos); * } * */ public void CombineEquipChannelZoneInfo(Dictionary <string, DTSEquip> equipinfo) { // ReadCfg(); foreach (KeyValuePair <string, DTSEquip> kvp in equipinfo) { if (ChannelInfos.Keys.Contains(kvp.Key)) { int channelcount = kvp.Value.ChannelCount; kvp.Value.channelInfo = new List <ChannelInfos>(); for (int i = 0; i < channelcount; i++) { ChannelInfos channel = ChannelInfos[kvp.Key][i]; if (ZoneInfos.Keys.Contains(kvp.Key)) { ChannelInfos zone = ZoneInfos[kvp.Key].Find(delegate(ChannelInfos c) { return(c.ChannelNum == channel.ChannelNum); }); int zoneind = ZoneInfos[kvp.Key].FindIndex(item => item.ChannelNum == channel.ChannelNum); if (zone != null) { channel.ZoneTempInfos = zone.ZoneTempInfos; channel.ZoneCount = (ushort)zone.ZoneTempInfos.Count; } } kvp.Value.channelInfo.Add(channel); } } } }
void _channelFactory_GetChannelsByListSucceed(object sender, HttpFactoryArgs <VodChannelListInfo> args) { _getDataStatusHelp.Clear(); var channelInfos = args.Result.Channels; var channel_count = args.Result.ChannelCount; var page_count = args.Result.PageCount; _isLoadingData = false; _channel_count = channel_count; _page_count = page_count; if (_isLongItem) { foreach (ChannelInfo item in channelInfos) { item.SlotUrl = item.SlotUrl.Substring(0, item.SlotUrl.IndexOf(".jpg")) + "_165.jpg"; ChannelInfos.Add(item); } } else//small { foreach (ChannelInfo item in channelInfos) { ChannelInfos.Add(item); } int currentIndex = 0; for (int i = 0; i < ChannelInfos.Count; i++) { if (currentIndex < i || i == 0) { ObservableCollection <ChannelInfo> tempChannelInfos = new ObservableCollection <ChannelInfo>(); for (int j = 0; j < 3; j++) { currentIndex = i + j; LogManager.Ins.DebugLog(currentIndex + ""); if (currentIndex < channelInfos.Count) { tempChannelInfos.Add(channelInfos[currentIndex]); Debug.WriteLine("添加了" + currentIndex); } } AllOneRow3ChannelInfos.Add(tempChannelInfos); } } Debug.WriteLine("总个数:" + (_isLongItem ? ChannelInfos.Count : AllOneRow3ChannelInfos.Count)); } if (_isLongItem ? ChannelInfos.Count == 0 : AllOneRow3ChannelInfos.Count == 0) { xChannelsListBox.Visibility = Visibility.Collapsed; xNullTextBlock.Text = "暂无节目"; xNullTextBlock.Visibility = Visibility.Visible; } else { xChannelsListBox.Visibility = Visibility.Visible; xNullTextBlock.Visibility = Visibility.Collapsed; } xLoadChannelsGrid.Visibility = Visibility.Collapsed; }
private void CreateData() { while (_isRunning) { int count = channelInfo.Count; List <ChannelInfos> channels = new List <ChannelInfos>(); for (int i = 0; i < count; i++) { ChannelInfos ci = CloneChanelInfo(channelInfo[i]); FiberBreakInfo fbi = CreateDatas.CreateTempData(ref ci); if (fbi.FiberBreakPos != -1) { ci.FiberBreak = CloneFiberBreakInfo(fbi); // PushCreateDatasFBI(fbi); } // PushCreateDatasCI(ci); channels.Add(ci); } EquipInfo ei = new EquipInfo(); ei = ei.DataConvert(DTSNum, channels, count, SampleInterval, this.SlaveNum); dataMange.PushEquipInfo(ei); EquipChannelTempInfo ecti = new EquipChannelTempInfo(); ecti = ecti.DataConvert(DTSNum, channels, count, SampleInterval); dataMange.PushEquipChannelTempInfo(ecti); Thread.Sleep(1000); } }
private void InserFunctionChannel(List <string> ContentStr) { try { ProDefine.g_ChannelInfos.Clear(); int RowCount = ContentStr.Count; int ColNum = ContentStr[0].Split(',').Count(); for (int i = 1; i < RowCount; i++) { ChannelInfos CI = new ChannelInfos(); CI.IndexStr = ContentStr[i].Split(',')[0]; CI.FucntionName = ContentStr[i].Split(',')[1]; CI.FunctionType = ContentStr[i].Split(',')[2]; CI.XianHao = ContentStr[i].Split(',')[3]; CI.Duanzi = ContentStr[i].Split(',')[4]; CI.Hz = Convert.ToInt32(ContentStr[i].Split(',')[5]); CI.PerCount = Convert.ToInt32(ContentStr[i].Split(',')[6]); CI.IsFunctionSelect = true; ProDefine.g_ChannelInfos.Add(CI); } } catch (System.Exception ex) { } }
public void GetChannelSetInfo() { try { string SQL = "select * from " + ChannelSetDBName + " where GUIDSTR='" + ProDefine.g_SMExpermentParam.GUID.ToString() + "'"; DataTable dt = AccessHelper.GetDataTableFromDB(SQL); if (dt != null) { if (dt.Rows.Count > 0) { ProDefine.g_ChannelInfos.Clear(); for (int i = 0; i < dt.Rows.Count; i++) { ChannelInfos csi = new ChannelInfos(); csi.IndexStr = dt.Rows[i][1].ToString(); csi.FucntionName = dt.Rows[i][2].ToString(); csi.FunctionType = dt.Rows[i][3].ToString(); csi.XianHao = dt.Rows[i][4].ToString(); csi.Duanzi = dt.Rows[i][5].ToString(); csi.Hz = Convert.ToInt32(dt.Rows[i][6].ToString()); csi.PerCount = Convert.ToInt32(dt.Rows[i][7].ToString()); csi.IsFunctionSelect = Convert.ToBoolean(dt.Rows[i][8].ToString()); ProDefine.g_ChannelInfos.Add(csi); } } } } catch (System.Exception ex) { } }
// ###################################################################### /// <summary> /// Returns true if the element has already been closed. /// </summary> /// <param name="element"></param> /// <param name="Value"></param> /// <param name="channelInfos"></param> /// <param name="IsStructure"></param> /// <param name="TheElementHaveAttributes"></param> /// <param name="TypeIndex"></param> /// <returns></returns> internal override bool ChannelEnterElementAndWriteValue( ref ChannelInfos channelInfos, Element element , out bool TheElementHaveAttributes , TypeCode TypeIndex , object Value, bool IsStructure) { StringBuilder s = new StringBuilder(); if (!this.CurrentSubBranchIsEmptyYet) { s.Append(','); } this.CurrentSubBranchIsEmptyYet = !element.IsAClosingTag; s.Append("\n\""); s.Append(JSONSerializationFormatter.JSONElementNames[(int)element.ElementType]); s.Append("\": {"); bool IsThereAnAttribute = false; IsThereAnAttribute |= _enterElementAttribute(s, AttributeTypes.InstanceIndex, element.InstanceIndex, !IsThereAnAttribute); if (element.typeIndexIsKnown) { IsThereAnAttribute |= _enterElementAttribute(s, AttributeTypes.TypeNumber, element.typeIndex, !IsThereAnAttribute); } { // special in JSON: we do not write the string length except if it 0 (to differenciate String.Empty and null at least). // The reason is JSON can determine string length by itself (contrary to binary formatters). long?noe = element.NumberOfElements != null ? (element.ElementType == ElementTypes.PrimitiveValue ? (element.NumberOfElements.Value == 0 ? element.NumberOfElements : null) : element.NumberOfElements) : null; IsThereAnAttribute |= _enterElementAttribute(s, AttributeTypes.NumberOfElements, noe, !IsThereAnAttribute); } this.CurrentSubBranchIsEmptyYet &= !IsThereAnAttribute; bool closeElement = element.IsAClosingTag; if (closeElement) { s.Append("}"); } this.ChannelWriteStringToStream(ref channelInfos, s.ToString()); if (Value != null) { this.ChannelWriteValueAsString(ref channelInfos, (string)Value, IsThereAnAttribute); } TheElementHaveAttributes = IsThereAnAttribute; return(closeElement); }
// -------------------------------------------- internal override string ChannelPrepareStringFromSimpleValue(ref ChannelInfos channelInfos, object value) { #if DEBUG throw new NotSupportedException(); #else return(null); #endif }
// -------------------------------------------- internal override void ChannelExitElement(ref ChannelInfos channelInfos, ElementTypes elementType) { this.ChannelWriteStringToStream( ref channelInfos, "</" + XmlSerializationFormatter.XmlElementNames[(int)elementType] + ">\n"); }
public ChannelInfos CloneChanelInfo(ChannelInfos obj) { MemoryStream memoryStream = new MemoryStream(); BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(memoryStream, obj); memoryStream.Position = 0; return((ChannelInfos)formatter.Deserialize(memoryStream)); }
public void DrawCurver(ChannelInfos channelinfo) { _ppListOriginal.Clear(); for (int i = 0; i < channelinfo.TempDatas.Count; i++) { _ppListOriginal.Add(i * (channelinfo.SampleInterval / 100.0), channelinfo.TempDatas[i]); } }
// -------------------------------------------- internal override string ChannelPrepareStringFromSimpleValue(ref ChannelInfos channelInfos, object value) { string StringValue = value as string; if (StringValue != null) { return(Tools.TranscodeToXmlCompatibleString(StringValue)); // transcodes xml syntax characters. } return(this.TranscodeSimpleValueToString(value)); }
// -------------------------------------------- // -------------------------------------------- // -------------------------------------------- internal override void ChannelWriteValueAsString(ref ChannelInfos channelInfos, string value, bool TheElementHaveAttributes) { StringBuilder sb = new StringBuilder(); _enterElementAttribute(sb, string.Empty, // The Value attribute has no name. value, !TheElementHaveAttributes); this.ChannelWriteStringToStream(ref channelInfos, sb.ToString()); this.CurrentSubBranchIsEmptyYet = false; }
public DMXDeviceInfo(string headerName, int channelBegin, int channelEnd) { HeaderName = headerName; ChannelBegin = channelBegin; ChannelEnd = channelEnd; for (var channleNum = ChannelBegin; channleNum <= channelEnd; channleNum++) { ChannelInfos.Add(new DMXChannelInfo(channleNum, channelBegin)); } InitOpenLogFileCommand(); }
private int GetChannelHz(int ChannelID, string FunctionName, ref int PerRead) { int Hz = 0; ChannelInfos cs = ProDefine.g_ChannelInfos.Where(m => m.FucntionName == FunctionName).SingleOrDefault(); if (cs != null) { Hz = cs.Hz; PerRead = cs.PerCount; } return(Hz); }
internal override bool ChannelEnterElementAndWriteValue( ref ChannelInfos channelInfos, Element element , out bool TheElementHaveAttributes , TypeCode TypeIndex , object Value, bool IsStructure) { bool IsThereAnAttribute = false; this.ChannelWriteStringToStream(ref channelInfos, "<"); this.ChannelWriteStringToStream(ref channelInfos, XmlSerializationFormatter.XmlElementNames[(int)element.ElementType]); IsThereAnAttribute |= _enterElementAttribute(ref channelInfos, AttributeTypes.InstanceIndex, element.InstanceIndex); if (element.typeIndexIsKnown) { IsThereAnAttribute |= _enterElementAttribute(ref channelInfos, AttributeTypes.TypeNumber, element.typeIndex); } { // special in xml: we do not write the string length except if it is 0 (to differenciate String.Empty and null at least). // The reason is xml can determine string length by itself (contrary to binary formatters). long?noe = element.NumberOfElements != null ? (element.ElementType == ElementTypes.PrimitiveValue ? (element.NumberOfElements.Value == 0 ? element.NumberOfElements : null) : element.NumberOfElements) : null; IsThereAnAttribute |= _enterElementAttribute(ref channelInfos, AttributeTypes.NumberOfElements, noe); } bool closeElement = element.IsAClosingTag; if (closeElement) { this.ChannelWriteStringToStream(ref channelInfos, "/>"); } else { this.ChannelWriteStringToStream(ref channelInfos, ">"); } if (element.ElementType != ElementTypes.PrimitiveValue) { this.ChannelWriteStringToStream(ref channelInfos, "\n"); } if (Value != null) { this.ChannelWriteValueAsString(ref channelInfos, (string)Value, IsThereAnAttribute); } TheElementHaveAttributes = IsThereAnAttribute; return(closeElement); }
void BeginLoad() { CurrentOrder = orderBar.SelectOrder; xorderButton.Visibility = System.Windows.Visibility.Visible; xorderButton.Content = orderBar.SelectText; _pageIndex = 1; AllOneRow3ChannelInfos.Clear(); ChannelInfos.Clear(); xLoadChannelsGrid.Visibility = Visibility.Visible; _isLoadingData = true; xLogTextBlock.Text = "加载新的数据 _pageIndex:" + _pageIndex + " 电影个数:" + (_isLongItem == true ? ChannelInfos.Count.ToString() : AllOneRow3ChannelInfos.Count.ToString()); _channelFactory.DownLoadDatas(TypeID, _currentSelectedTagInfos, _pageIndex, _channelItemCount, CurrentOrder); }
internal void AddAnObject( ref ChannelInfos channelInfos, object obj, string NameToWrite, int TypeNumber, L3TypeManager tm, bool AtRoot, bool WriteType) { #if DEBUG if (tm.TypeIndex == (int)TypeCode.Object && obj != null) { Debugger.Break(); } #endif bool AddSectionMark = AtRoot && this.parameters.TheStreamingMode == StreamingModes.MultiplexStream; if (AddSectionMark) { this.ChannelEnterChannelSection(ref channelInfos); } WriteType |= AtRoot && channelInfos.ChannelNumber == SerializationFormatter.ChannelNumber.InstancesChannel; if (obj == null) { this.ChannelAddNull( ref channelInfos ); } else if (tm.l2TypeManager.IsAPrimitiveType) { this.AddPrimitiveElementOrReference( ref channelInfos, obj, #if DEBUG NameToWrite, tm.l2TypeManager.L1TypeManager.type, #endif TypeNumber, null, WriteType); } else { this.AddAComplexObject(ref channelInfos, obj, #if DEBUG NameToWrite, #endif TypeNumber, tm, WriteType); } if (AddSectionMark) { this.ChannelExitChannelSection(ref channelInfos); } }
private void GetNowSelectYBInfo() { try { ChannelInfos yb = ProDefine.g_ChannelInfos.Where(m => m.FucntionName == m_NowGNFunction).SingleOrDefault(); FucntionChannelInfo fc = ProDefine.g_FunctionChannel.Where(m => m.FunctionName == m_NowGNFunction && m.YBNumber == Convert.ToInt32(m_NowYB.Substring(2, m_NowYB.Length - 2))).SingleOrDefault(); m_NowChannel = fc.ChannelNumber; m_NowChannleType = yb.FunctionType; } catch (System.Exception ex) { } }
private string GetNowChannelType(string GNFunction) { try { ChannelInfos ci = ProDefine.g_ChannelInfos.Where(m => m.FucntionName == GNFunction).SingleOrDefault(); if (ci != null) { return(ci.FunctionType); } } catch (System.Exception ex) { } return(""); }
bool _enterElementAttribute(ref ChannelInfos channelInfos, AttributeTypes AttributeType, object value) { if (value == null) { return(false); } this.ChannelWriteStringToStream(ref channelInfos, " "); this.ChannelWriteStringToStream(ref channelInfos, XmlSerializationFormatter.XmlAttributeNames[(int)AttributeType]); this.ChannelWriteStringToStream(ref channelInfos, "=\""); this.ChannelWriteStringToStream(ref channelInfos, Tools.TranscodeToXmlCompatibleString(value.ToString())); this.ChannelWriteStringToStream(ref channelInfos, "\""); return(true); }
private void DoJob() { while (true) { if (waitSend.Count > 0) { lock (obj) { string[] keys = waitSend.Keys.ToArray(); for (int i = 0; i < keys.Length; i++) { string key = keys[i]; if (waitSend[key].Count > 0) { ChannelInfos channelinfos = CloneChanelInfo(waitSend[key][0]); if (channelinfos.FiberBreakStatus == 1) { List <FiberBreakInfo> fiberBreakInfo; if (fiberBreakInfos.TryGetValue(key, out fiberBreakInfo)) { if (fiberBreakInfo.Count > 0) { channelinfos.FiberBreak = CloneFiberBreakInfo(fiberBreakInfo[0]); lock (obj1) fiberBreakInfos[key].RemoveAt(0); } } } // RegistDatas.Create().PushChannelInfos(channelinfos); if (newwaitSend.Keys.Contains(key)) { newwaitSend[key].Add(channelinfos); } else { List <ChannelInfos> c = new List <ChannelInfos>(); c.Add(channelinfos); newwaitSend.Add(key, c); } waitSend[key].RemoveAt(0); } } } Thread.Sleep(10); } } }
public override string ToString() { var sb = new StringBuilder("ChannelSyncDatas("); bool __first = true; if (ChannelInfos != null && __isset.channelInfos) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("ChannelInfos: "); ChannelInfos.ToString(sb); } if (ChannelDomains != null && __isset.channelDomains) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("ChannelDomains: "); ChannelDomains.ToString(sb); } if (__isset.revision) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("Revision: "); Revision.ToString(sb); } if (__isset.expires) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("Expires: "); Expires.ToString(sb); } sb.Append(")"); return(sb.ToString()); }
public void PushChannelInfos(ChannelInfos channelinfo) { if (channelInfos.Keys.Contains(channelinfo.ChannelNum.ToString())) { lock (obj) { channelInfos[channelinfo.ChannelNum.ToString()].Add(channelinfo); } } else { List <ChannelInfos> listchannelinfos = new List <ChannelInfos>(); listchannelinfos.Add(channelinfo); channelInfos.Add(channelinfo.ChannelNum.ToString(), listchannelinfos); } }
protected override void OnBackKeyPress(CancelEventArgs e) { if (gridtools.Visibility == System.Windows.Visibility.Visible) { SetTagsBarStatus(false); SetOrderBarStatus(false); e.Cancel = true; return; } xLoadChannelsGrid.Margin = new Thickness(0, 0, 0, 30); xLoadChannelsGrid.Visibility = Visibility.Visible; xLoadingTextBlock.Text = CommonUtils.LoadingTips; AllOneRow3ChannelInfos.Clear(); ChannelInfos.Clear(); base.OnBackKeyPress(e); }
public void PushCreateDatasCI(ChannelInfos ci) { if (ci != null) { if (Channels.Keys.Contains(ci.ChannelNum.ToString())) { lock (obj) Channels[ci.ChannelNum.ToString()].Add(ci); } else { List <ChannelInfos> temp = new List <ChannelInfos>(); temp.Add(ci); Channels.Add(ci.ChannelNum.ToString(), temp); } } }
private void CreateData() { while (_isRunning) { int count = channelInfo.Count; for (int i = 0; i < count; i++) { ChannelInfos ci = channelInfo[i]; FiberBreakInfo fbi = CreateDatas.CreateTempData(ref ci); if (fbi.FiberBreakPos != -1) { PushCreateDatasFBI(fbi); } PushCreateDatasCI(ci); Thread.Sleep(channelInfo[i].MeasureTime * 1000); } } }
private void DoJob() { while (_isRunning) { if (Channels.Count > 0) { lock (obj) { string[] keys = Channels.Keys.ToArray(); for (int i = 0; i < keys.Length; i++) { string key = keys[i]; if (Channels[key].Count > 0) { ChannelInfos channelinfos = CloneChanelInfo(Channels[key][0]); if (channelinfos.FiberBreakStatus == 1) { List <FiberBreakInfo> fiberBreakInfo; if (ChannelFiberBreakInfo.TryGetValue(key, out fiberBreakInfo)) { if (fiberBreakInfo.Count > 0) { channelinfos.FiberBreak = CloneFiberBreakInfo(fiberBreakInfo[0]); lock (obj1) ChannelFiberBreakInfo[key].RemoveAt(0); } } } RegistData rd = RegistDatas.SerialChanenlInfo(channelinfos); PushRegistDatas(rd); if (this.DTSNum == Main.oldEquipNum) { Main.channelCurvers[channelinfos.ChannelNum.ToString()].DrawCurver(channelinfos); Main.ObjRefreshZed(channelinfos.ChannelNum.ToString()); } Channels[key].RemoveAt(0); } } } Thread.Sleep(10); } } }
public void PushBaseInfo(ChannelInfos channelInfo) { if (channelInfo != null) { if (waitSend.Keys.Contains(channelInfo.ChannelNum.ToString())) { lock (obj) waitSend[channelInfo.ChannelNum.ToString()].Add(CloneChanelInfo(channelInfo)); } else { List <ChannelInfos> temp = new List <ChannelInfos>(); temp.Add(CloneChanelInfo(channelInfo)); waitSend.Add(channelInfo.ChannelNum.ToString(), temp); } // Trace.WriteLine("CreateInputRegistData:" + waitSend["1"].Count); } }
/* * public void CreateData() * { * EquipCreateDatasCI.Clear(); * EquipCreateDatasFBI.Clear(); * RegistDatas.Clear(); * foreach (KeyValuePair<string, DTSEquip> kvp in Equip) * { * kvp.Value.tcpServer.Start(); * List<ChannelInfos> channels = kvp.Value.channelInfo; * if (channels.Count > 0) * { * for (int i = 0; i < channels.Count; i++) * { * CreateDatas cd = new CreateDatas(kvp.Value,channels[i]); * int index = -1; * if (EquipCreateDatas.Keys.Contains(kvp.Key)) * { * EquipCreateDatas[kvp.Key].Add(cd); * index = EquipCreateDatas[kvp.Key].Count - 1; * } * else * { * List<CreateDatas> list = new List<CreateDatas>(); * list.Add(cd); * EquipCreateDatas.Add(kvp.Key, list); * index = 0; * } * EquipCreateDatas[kvp.Key][index].timer.Start(); * _isRunning = true; * } * } * } * * // t.Start(); * // t1.Start(); * } */ public static void PushCreateDatasCI(DTSEquip equip, ChannelInfos ci) { if (ci != null) { if (EquipCreateDatasCI.Keys.Contains(equip)) { lock (obj) EquipCreateDatasCI[equip].Add(ci); } else { List <ChannelInfos> temp = new List <ChannelInfos>(); temp.Add(ci); EquipCreateDatasCI.Add(equip, temp); } // Trace.WriteLine("CreateInputRegistData:" + waitSend["1"].Count); } }
// -------------------------------------------- internal override void ChannelExitElement(ref ChannelInfos channelInfos, ElementTypes elementType) { this.ChannelWriteStringToStream( ref channelInfos, "</" + XmlSerializationFormatter.XmlElementNames[(int)elementType] + ">\n"); }
bool _enterElementAttribute(ref ChannelInfos channelInfos, AttributeTypes AttributeType, object value) { if (value == null) return false; this.ChannelWriteStringToStream(ref channelInfos, " "); this.ChannelWriteStringToStream(ref channelInfos, XmlSerializationFormatter.XmlAttributeNames[(int)AttributeType]); this.ChannelWriteStringToStream(ref channelInfos, "=\""); this.ChannelWriteStringToStream(ref channelInfos, Tools.TranscodeToXmlCompatibleString(value.ToString())); this.ChannelWriteStringToStream(ref channelInfos, "\""); return true; }
[System.Runtime.CompilerServices.MethodImpl((System.Runtime.CompilerServices.MethodImplOptions)256)] // AggressiveInlining protected void ChannelWriteStringToStream(ref ChannelInfos channelInfos, string s) { if (this.streamWriter != null) this.streamWriter.Write(s); // multiplex. else channelInfos.streamWriterForText.Write(s); // separate files. }
[System.Runtime.CompilerServices.MethodImpl((System.Runtime.CompilerServices.MethodImplOptions)256)] // AggressiveInlining internal void ChannelExitChannelSection(ref ChannelInfos channelInfos) { switch (channelInfos.ChannelNumber) { case SerializationFormatter.ChannelNumber.TypeDescriptorsChannel: this.ChannelExitElement(ref channelInfos, ElementTypes.TypesChannelSection); break; case SerializationFormatter.ChannelNumber.InstancesChannel: this.ChannelExitElement(ref channelInfos, ElementTypes.InstancesChannelSection); break; } }
internal void ChannelExitSubBranch(ref ChannelInfos channelInfos) { this.ChannelExitElement(ref channelInfos, ElementTypes.SubBranch); }
// -------------------------------------------- // -------------------------------------------- // -------------------------------------------- internal override void ChannelWriteValueAsString(ref ChannelInfos channelInfos, string value, bool TheElementHaveAttributes) { StringBuilder sb = new StringBuilder(); _enterElementAttribute(sb, string.Empty, // The Value attribute has no name. value, !TheElementHaveAttributes); this.ChannelWriteStringToStream(ref channelInfos, sb.ToString()); this.CurrentSubBranchIsEmptyYet = false; }
// -------------------------------------------- internal override void ChannelExitElement(ref ChannelInfos channelInfos, ElementTypes elementType) { this.ChannelWriteStringToStream(ref channelInfos, "\n}"); }
[System.Runtime.CompilerServices.MethodImpl((System.Runtime.CompilerServices.MethodImplOptions)256)] // AggressiveInlining internal void ChannelAddPrimitiveElementToRoot( ref ChannelInfos channelInfos, object Value, #if DEBUG string debug_Name, #endif int? TypeNumber, TypeCode typeCode #if DEBUG , Type debug_type #endif ) { this.ChannelEnterInstancesChannelSection(ref channelInfos); this._ChannelAddPrimitiveElement( ref this.channelInfos[(int)ChannelNumber.InstancesChannel], Value, #if DEBUG debug_Name, #endif TypeNumber, typeCode #if DEBUG , debug_type #endif ); this.ChannelExitInstancesChannelSection(); }
[System.Runtime.CompilerServices.MethodImpl((System.Runtime.CompilerServices.MethodImplOptions)256)] // AggressiveInlining internal void _ChannelAddPrimitiveElement( ref ChannelInfos channelInfos, object Value, #if DEBUG string debug_Name, #endif int? TypeNumber, TypeCode typeCode #if DEBUG , Type debug_type #endif ) { #if DEBUG if (Value == null) throw new ArgumentNullException(); #endif if (this.IsStringFormatter) Value = this.ChannelPrepareStringFromSimpleValue(ref channelInfos, Value); // Depends on the formatter. bool TheElementHaveAttributes; if (!this.ChannelEnterElementAndWriteValue( ref channelInfos, new Element { ElementType = ElementTypes.PrimitiveValue, typeIndex = TypeNumber != null ? TypeNumber.Value : 0, typeIndexIsKnown = TypeNumber != null, NeedsAnEndElement = true, ContainsAValue = true } , out TheElementHaveAttributes // TODO: determine IsDefaultValue using default values in the TypeManager. , typeCode , Value , false )) { this.ChannelExitElement(ref channelInfos, ElementTypes.PrimitiveValue); } }
[System.Runtime.CompilerServices.MethodImpl((System.Runtime.CompilerServices.MethodImplOptions)256)] // AggressiveInlining internal void _ChannelAddReference( ref ChannelInfos channelInfos, #if DEBUG string debug_Name, #endif int ReferenceToInstanceNumber #if DEBUG , Type debug_type #endif ) { bool TheElementHaveAttributes; this.ChannelEnterElementAndWriteValue( ref channelInfos, new Element { ElementType = ElementTypes.Reference, InstanceIndex = ReferenceToInstanceNumber, IsAClosingTag = true, } , out TheElementHaveAttributes , TypeCode.Empty , null , false ); }
[System.Runtime.CompilerServices.MethodImpl((System.Runtime.CompilerServices.MethodImplOptions)256)] // AggressiveInlining internal void ChannelAddNull( ref ChannelInfos channelInfos ) { bool TheElementHaveAttributes; this.ChannelEnterElementAndWriteValue( ref channelInfos, new Element { ElementType = ElementTypes.Null, IsAClosingTag = true } , out TheElementHaveAttributes , TypeCode.Empty , null , false ); }
// ------------------------------------------------- internal abstract void ChannelWriteValueAsString(ref ChannelInfos channelInfos, string value, bool TheElementHaveAttributes);
// -------------------------------------------- // -------------------------------------------- // -------------------------------------------- internal override void ChannelWriteValueAsString(ref ChannelInfos channelInfos, string value, bool TheElementHaveAttributes) { this.ChannelWriteStringToStream(ref channelInfos, value); // In Xml, an element value is wrote alone. }
/// <summary> /// Text formatters can transcode a value to a string that respects the format syntax. /// </summary> /// <param name="value"></param> /// <param name="channelInfos"></param> /// <returns></returns> internal abstract string ChannelPrepareStringFromSimpleValue(ref ChannelInfos channelInfos, object value);
// ###################################################################### /// <summary> /// Returns true if the element has already been closed. /// </summary> /// <param name="element"></param> /// <param name="Value"></param> /// <param name="channelInfos"></param> /// <param name="IsStructure"></param> /// <param name="TheElementHaveAttributes"></param> /// <param name="TypeIndex"></param> /// <returns></returns> internal override bool ChannelEnterElementAndWriteValue( ref ChannelInfos channelInfos, Element element , out bool TheElementHaveAttributes , TypeCode TypeIndex , object Value, bool IsStructure) { StringBuilder s = new StringBuilder(); if (!this.CurrentSubBranchIsEmptyYet) s.Append(','); this.CurrentSubBranchIsEmptyYet = !element.IsAClosingTag; s.Append("\n\""); s.Append(JSONSerializationFormatter.JSONElementNames[(int)element.ElementType]); s.Append("\": {"); bool IsThereAnAttribute = false; IsThereAnAttribute |= _enterElementAttribute(s, AttributeTypes.InstanceIndex, element.InstanceIndex, !IsThereAnAttribute); if (element.typeIndexIsKnown) IsThereAnAttribute |= _enterElementAttribute(s, AttributeTypes.TypeNumber, element.typeIndex, !IsThereAnAttribute); { // special in JSON: we do not write the string length except if it 0 (to differenciate String.Empty and null at least). // The reason is JSON can determine string length by itself (contrary to binary formatters). long? noe = element.NumberOfElements != null ? (element.ElementType == ElementTypes.PrimitiveValue ? (element.NumberOfElements.Value == 0 ? element.NumberOfElements : null) : element.NumberOfElements) : null; IsThereAnAttribute |= _enterElementAttribute(s, AttributeTypes.NumberOfElements, noe, !IsThereAnAttribute); } this.CurrentSubBranchIsEmptyYet &= !IsThereAnAttribute; bool closeElement = element.IsAClosingTag; if (closeElement) s.Append("}"); this.ChannelWriteStringToStream(ref channelInfos, s.ToString()); if (Value != null) this.ChannelWriteValueAsString(ref channelInfos, (string)Value, IsThereAnAttribute); TheElementHaveAttributes = IsThereAnAttribute; return closeElement; }
internal void ChannelExitDictionary(ref ChannelInfos channelInfos) { this.ChannelExitElement(ref channelInfos, ElementTypes.Dictionary); }
// -------------------------------------------- internal override string ChannelPrepareStringFromSimpleValue(ref ChannelInfos channelInfos, object value) { string StringValue = value as string; if (StringValue != null) return Tools.TranscodeToJSONCompatibleString(StringValue); // transcodes JSON syntax characters. return this.TranscodeSimpleValueToString(value); }
// -------------------------------------------- internal override void ChannelExitElement(ref ChannelInfos channelInfos, ElementTypes elementType) { }
/* → le type T est un type simple (listé dans System.TypeCode à partir de Boolean, à trouver avec Type.GetTypeCode()), ou bien un byte[], OU BIEN une référence à une instance de classe*/ internal void ChannelEnterCollection( ref ChannelInfos channelInfos #if DEBUG , string Name, Type type #endif ) { bool TheElementHaveAttributes; this.ChannelEnterElementAndWriteValue( ref channelInfos, new Element { ElementType = ElementTypes.Collection, NeedsAnEndElement = true } , out TheElementHaveAttributes , TypeCode.Empty , null , false ); }
// ###################################################################### /// <summary> /// Returns true if the element has already been closed. /// </summary> /// <param name="element"></param> /// <param name="Value"></param> /// <param name="channelInfos"></param> /// <param name="IsStructure"></param> /// <param name="TheElementHaveAttributes"></param> /// <param name="TypeIndex"></param> /// <returns></returns> internal abstract bool ChannelEnterElementAndWriteValue( ref ChannelInfos channelInfos, Element element , out bool TheElementHaveAttributes , TypeCode TypeIndex , object Value, bool IsStructure );
[System.Runtime.CompilerServices.MethodImpl((System.Runtime.CompilerServices.MethodImplOptions)256)] // AggressiveInlining internal void ChannelEnterSubBranch( ref ChannelInfos channelInfos, long? NumberOfElements, #if DEBUG string Name, #endif int? TypeNumber, bool? IsDefaultValue #if DEBUG , Type type #endif , bool IsStructure ) { bool TheElementHaveAttributes; this.ChannelEnterElementAndWriteValue( ref channelInfos, new Element { ElementType = ElementTypes.SubBranch, typeIndex = TypeNumber != null ? TypeNumber.Value : 0, typeIndexIsKnown = TypeNumber != null, NeedsAnEndElement = true, NumberOfElements = NumberOfElements } , out TheElementHaveAttributes , TypeCode.Empty , null , IsStructure ); }
// -------------------------------------------- internal override string ChannelPrepareStringFromSimpleValue(ref ChannelInfos channelInfos, object value) { #if DEBUG throw new NotSupportedException(); #else return null; #endif }
internal void ChannelEnterDictionary( ref ChannelInfos channelInfos) { bool TheElementHaveAttributes; this.ChannelEnterElementAndWriteValue( ref channelInfos, new Element { ElementType = ElementTypes.Dictionary, NeedsAnEndElement = true } , out TheElementHaveAttributes , TypeCode.Empty , null , false ); }
[System.Runtime.CompilerServices.MethodImpl((System.Runtime.CompilerServices.MethodImplOptions)256)] // AggressiveInlining internal override bool ChannelEnterElementAndWriteValue( ref ChannelInfos channelInfos, Element element , out bool TheElementHaveAttributes , TypeCode TypeIndex , object Value, bool IsStructure) { var et = element.ElementType; if (et == ElementTypes.PrimitiveValue && !element.typeIndexIsKnown && TypeIndex!=TypeCode.String) // No tag for the value primitive types (if not included in an object field or property). { WriteValueToBinaryWriter(this.binaryWriter, Value, parameters.CompressIntsAs7Bits, TypeIndex); TheElementHaveAttributes = false; // useless for this formatter. return false; } if (et == ElementTypes.SubBranch && IsStructure && !element.typeIndexIsKnown && element.NumberOfElements == null) // No tag for structure types (if not included in an object field or property). { TheElementHaveAttributes = false; // useless for this formatter. return true; } FileTools.BinaryWriter2 bw = this.binaryWriter; // 1) Element code : byte { byte elementCode = unchecked((byte)et); if (element.typeIndexIsKnown) elementCode |= (byte)BinaryAttributeCode.HasATypeNumber; if (element.NumberOfElements != null) elementCode |= (byte)BinaryAttributeCode.HasANumberOfElements; bw.Write(elementCode); } // 2) typeNumber : 7 bit-compressed int // Type is written immediately after the tag, if a type attribute is required exists. if (element.typeIndexIsKnown) bw.Write7BitEncodedInt(element.typeIndex); // 3) Reference InstanceIndex : 7 bit-compressed int if (et == ElementTypes.Reference) bw.Write7BitEncodedInt(element.InstanceIndex.Value); // 4) NumberOfElements : 7 bit-compressed long if (et == ElementTypes.SubBranch) { if (element.NumberOfElements != null) bw.Write7BitEncodedLong(element.NumberOfElements.Value); } #if DEBUG else if (element.NumberOfElements != null) Debugger.Break(); #endif bool alreadyClosed = element.ElementType != ElementTypes.PrimitiveValue; if (!alreadyClosed) { #if DEBUG if (Value == null) throw new Exception(); #endif WriteValueToBinaryWriter(bw, Value, parameters.CompressIntsAs7Bits, TypeIndex); } TheElementHaveAttributes = false; // useless for this formatter. return alreadyClosed; }
internal abstract void ChannelExitElement(ref ChannelInfos channelInfos, ElementTypes elementType);
/*internal abstract void AddCollectionPrimitiveElement<T>( // semble redondant avec AddPrimitiveElement, mais peut-être parfois utile. T Value, string Name = null, int? ElementType = null, int? ReferenceToInstanceNumber = null);*/ internal void ChannelExitCollection(ref ChannelInfos channelInfos) { this.ChannelExitElement(ref channelInfos, ElementTypes.Collection); }
[System.Runtime.CompilerServices.MethodImpl((System.Runtime.CompilerServices.MethodImplOptions)256)] // AggressiveInlining internal override bool ChannelEnterElementAndWriteValue( ref ChannelInfos channelInfos, Element element , out bool TheElementHaveAttributes , TypeCode TypeIndex , object Value, bool IsStructure) { bool IsThereAnAttribute = false; this.ChannelWriteStringToStream(ref channelInfos, "<"); this.ChannelWriteStringToStream(ref channelInfos, XmlSerializationFormatter.XmlElementNames[(int)element.ElementType]); IsThereAnAttribute |= _enterElementAttribute(ref channelInfos, AttributeTypes.InstanceIndex, element.InstanceIndex); if (element.typeIndexIsKnown) IsThereAnAttribute |= _enterElementAttribute(ref channelInfos, AttributeTypes.TypeNumber, element.typeIndex); { // special in xml: we do not write the string length except if it 0 (to differenciate String.Empty and null at least). // The reason is xml can determine string length by itself (contrary to binary formatters). long? noe = element.NumberOfElements != null ? (element.ElementType == ElementTypes.PrimitiveValue ? (element.NumberOfElements.Value == 0 ? element.NumberOfElements : null) : element.NumberOfElements) : null; IsThereAnAttribute |= _enterElementAttribute(ref channelInfos, AttributeTypes.NumberOfElements, noe); } bool closeElement = element.IsAClosingTag; if (closeElement) this.ChannelWriteStringToStream(ref channelInfos, "/>"); else this.ChannelWriteStringToStream(ref channelInfos, ">"); if (element.ElementType != ElementTypes.PrimitiveValue) this.ChannelWriteStringToStream(ref channelInfos, "\n"); if (Value != null) this.ChannelWriteValueAsString(ref channelInfos, (string)Value, IsThereAnAttribute); TheElementHaveAttributes = IsThereAnAttribute; return closeElement; }
// -------------------------------------------- // -------------------------------------------- // -------------------------------------------- internal override void ChannelWriteValueAsString(ref ChannelInfos channelInfos, string value, bool TheElementHaveAttributes) { #if DEBUG throw new NotSupportedException(); #endif }