public void Parse(Stream hs) { PackPos = hs.ReadDecodedUInt64(); NumPackStreams = hs.ReadDecodedUInt64(); Sizes = new UInt64[NumPackStreams]; Digests = new Digests(NumPackStreams); while (true) { PropertyID propertyID = GetPropertyID(this, hs); switch (propertyID) { case PropertyID.kSize: for (ulong i = 0; i < NumPackStreams; ++i) { Sizes[i] = hs.ReadDecodedUInt64(); } break; case PropertyID.kCRC: Digests.Parse(hs); break; case PropertyID.kEnd: return; default: throw new NotImplementedException(propertyID.ToString()); } } }
public void Parse(Stream hs) { while (true) { PropertyID propertyID = GetPropertyID(this, hs); switch (propertyID) { case PropertyID.kPackInfo: PackInfo = new PackInfo(); PackInfo.Parse(hs); break; case PropertyID.kUnPackInfo: UnPackInfo = new UnPackInfo(); UnPackInfo.Parse(hs); break; case PropertyID.kSubStreamsInfo: if (UnPackInfo == null) { Trace.TraceWarning("SubStreamsInfo block found, yet no UnPackInfo block has been parsed so far."); UnPackInfo = new UnPackInfo(); } SubStreamsInfo = new SubStreamsInfo(UnPackInfo); SubStreamsInfo.Parse(hs); break; case PropertyID.kEnd: return; default: throw new NotImplementedException(propertyID.ToString()); } } }
public void Parse(Stream hs) { while (true) { PropertyID propertyID = GetPropertyID(this, hs); switch (propertyID) { case PropertyID.kArchiveProperties: ArchiveProperties = new ArchiveProperties(); ArchiveProperties.Parse(hs); break; case PropertyID.kAdditionalStreamsInfo: AdditionalStreamsInfo = new StreamsInfo(); AdditionalStreamsInfo.Parse(hs); break; case PropertyID.kMainStreamsInfo: MainStreamsInfo = new StreamsInfo(); MainStreamsInfo.Parse(hs); break; case PropertyID.kFilesInfo: FilesInfo = new FilesInfo(); FilesInfo.Parse(hs); break; case PropertyID.kEnd: return; default: throw new NotImplementedException(propertyID.ToString()); } } }
public void ToStringTest2() { var pid = new PropertyID(5); var s = pid.ToString(); Assert.IsNotNull(s); Assert.IsFalse(s.Contains('.')); Assert.AreEqual(1, s.Length); }
public void ToStringTest1() { var uri = new Uri("http://folker.de/"); var pid = new PropertyID(5, new PropertyIDMapping(7, uri)); string s = pid.ToString(); Assert.IsNotNull(s); Assert.IsTrue(s.Contains('.')); Assert.AreEqual(3, s.Length); }
public void Parse(Stream hs) { NumFiles = hs.ReadDecodedUInt64(); while (true) { PropertyID propertyID = GetPropertyID(this, hs); if (propertyID == PropertyID.kEnd) { break; } FileProperty property = null; switch (propertyID) { case PropertyID.kEmptyStream: property = new PropertyEmptyStream(NumFiles); property.Parse(hs); NumEmptyStreams = (property as PropertyEmptyStream).NumEmptyStreams; break; case PropertyID.kEmptyFile: property = new PropertyEmptyFile(NumFiles, NumEmptyStreams); property.Parse(hs); break; case PropertyID.kAnti: property = new PropertyAnti(NumFiles, NumEmptyStreams); property.Parse(hs); break; case PropertyID.kCTime: case PropertyID.kATime: case PropertyID.kMTime: property = new PropertyTime(propertyID, NumFiles); property.Parse(hs); break; case PropertyID.kName: property = new PropertyName(NumFiles); property.Parse(hs); break; case PropertyID.kWinAttributes: property = new PropertyAttributes(NumFiles); property.Parse(hs); break; case PropertyID.kDummy: property = new PropertyDummy(); property.Parse(hs); break; default: throw new NotImplementedException(propertyID.ToString()); } if (property != null) { Properties.Add(property); } } }
/// <summary> /// Writes the value of the specified item property. /// </summary> protected IdentifiedResult Write(PropertyID propertyID, ItemValue value, bool validate) { // initialize result and validate property. IdentifiedResult result = new IdentifiedResult { ItemName = ItemID, ItemPath = null }; if (validate) { result.ResultID = ValidatePropertyID(propertyID, accessRights.writable); } else { result.ResultID = ResultID.S_OK; } result.DiagnosticInfo = null; //MP return if modification is not allowed //MPNI zg³osiæ Rendy'iemu if (result.ResultID.Failed()) { //nieudalo dodac sie property: #if DEBUG //tutaj chyba wyswietla wlasnie te co dodal System.Console.WriteLine( "|problem with the property (Write fails) : " + ToString() + ":" + propertyID.ToString().Replace(Opc.Namespace.OPC_DATA_ACCESS, "") + " "); #endif return(result); } // handle value writes. if (propertyID == Property.VALUE) { if (!UpdateRemote(value.Value))//MZTD: sprawdzic czy symulator bedzie dzialac (bylo przekazywane cale Opc.Da.ItemValue a teraz idzie tylko value z Opc.Da.ItemValue value) { result.ResultID = ResultID.E_TIMEDOUT; result.DiagnosticInfo = "communication error while writing to the device"; return(result); } lock (this) { m_value = value.Value; //MPTD sprawdziæ po co on to kopiuje // copy value. //m_value = Opc.Convert.Clone(value.Value); // update quality if specified. if (value.QualitySpecified) { m_quality = value.Quality; } // update time-stamp if specified. if (value.TimestampSpecified) { m_timestamp = value.Timestamp; } } // return results. return(result); } // lookup property description. PropertyDescription property = PropertyDescription.Find(propertyID); if (property == null) { result.ResultID = ResultID.Da.E_INVALID_PID; return(result); } if (!validate) { //mamy doczynienia z dodawaniem nie validowanych properties i trzeba przekonwertowac je do odpowiedniego typu switch (propertyID.Code) { // standard properties. case DATATYPE: value.Value = System.Type.GetType(System.Convert.ToString(value.Value)); break; case QUALITY: value.Value = System.Convert.ToInt16(value.Value); break; case TIMESTAMP: value.Value = System.Convert.ToDateTime(value.Value); break; case ACCESSRIGHTS: value.Value = System.Convert.ToInt16(value.Value); break; case SCANRATE: value.Value = System.Convert.ToDouble(value.Value); break; case EUTYPE: if (System.Convert.ToString(value.Value).ToLower().Equals(euType.analog.ToString().ToLower())) { value.Value = euType.analog; } else if (System.Convert.ToString(value.Value).ToLower().Equals(euType.noEnum.ToString().ToLower())) { value.Value = euType.noEnum; } else if (System.Convert.ToString(value.Value).ToLower().Equals(euType.enumerated.ToString().ToLower())) { value.Value = euType.enumerated; } else { value.Value = (int)0; } break; case EUINFO: string[] temp_euinfo = new string[1]; temp_euinfo[0] = System.Convert.ToString(value.Value); value.Value = temp_euinfo; break; case HIHI_LIMIT: case LOLO_LIMIT: case HI_LIMIT: case LO_LIMIT: case LOWEU: case HIGHEU: value.Value = System.Convert.ToDouble(value.Value); break; default: //do nothing break; } } // check data-type. if (!property.Type.IsInstanceOfType(value.Value)) { #if DEBUG //tutaj chyba wyswietla wlasnie te co dodal System.Console.WriteLine( "|problem with the property (Write fails) : " + ToString() + ":" + propertyID.ToString().Replace(Opc.Namespace.OPC_DATA_ACCESS, "") + " "); #endif result.ResultID = ResultID.Da.E_BADTYPE; return(result); } // write non-value switch (propertyID.Code) { // standard properties. case DATATYPE: { m_datatype = (System.Type)value.Value; return(result); } case QUALITY: { m_quality = (Quality)value.Value; return(result); } case TIMESTAMP: { m_timestamp = (DateTime)value.Value; return(result); } case ACCESSRIGHTS: { m_accessRights = (accessRights)value.Value; return(result); } case SCANRATE: { m_scanRate = (float)value.Value; return(result); } case EUTYPE: { m_euType = (euType)value.Value; return(result); } case EUINFO: { m_euInfo = (string[])Opc.Convert.Clone(value.Value); return(result); } case HIGHEU: { m_maxValue = (double)value.Value; return(result); } case LOWEU: { m_minValue = (double)value.Value; return(result); } // other defined properties. default: { if (!m_properties.Contains(propertyID)) { result.ResultID = ResultID.Da.E_INVALID_PID; return(result); } m_properties[propertyID] = Opc.Convert.Clone(value.Value); break; } } // write complete. return(result); } //Write