public void EmitANDOR() { var n1 = new PhysicalValue() { Number = 51 }; var n2 = new PhysicalValue() { Number = 52 }; var sc1 = new SelectionCriteria() { BinaryRelation = ">", FirstArgument = n1, SecondArgument = n2 }; var n3 = new PhysicalValue() { Number = 53 }; var n4 = new PhysicalValue() { Number = 54 }; var sc2 = new SelectionCriteria() { BinaryRelation = "<", FirstArgument = n3, SecondArgument = n4 }; var andor = new ANDOR() { AOType = ANDORType.kAnd }; andor.Arguments.Add(sc1); andor.Arguments.Add(sc2); var ms = new StringWriter(); andor.Emit(ms); var text = ms.ToString().Split('\r').Select(l => l.Trim()).ToArray(); Assert.AreEqual("atlas:number0 rdf:type qudt:QuantityValue ;", text[0]); Assert.AreEqual("qudt:numericValue \"51\"^^xsd:decimal .", text[1]); Assert.AreEqual("", text[2]); Assert.AreEqual("atlas:number1 rdf:type qudt:QuantityValue ;", text[3]); Assert.AreEqual("qudt:numericValue \"52\"^^xsd:decimal .", text[4]); Assert.AreEqual("", text[5]); Assert.AreEqual("atlas:selectionCriteria2 rdf:type dfs:SelectionCriteria ;", text[6]); Assert.AreEqual("dfs:usesBinaryRelation dfs:greaterThan ;", text[7]); Assert.AreEqual("dfs:hasFirstArgument atlas:number0 ;", text[8]); Assert.AreEqual("dfs:hasSecondArgument atlas:number1 .", text[9]); Assert.AreEqual("", text[10]); Assert.AreEqual("atlas:number3 rdf:type qudt:QuantityValue ;", text[11]); Assert.AreEqual("qudt:numericValue \"53\"^^xsd:decimal .", text[12]); Assert.AreEqual("", text[13]); Assert.AreEqual("atlas:number4 rdf:type qudt:QuantityValue ;", text[14]); Assert.AreEqual("qudt:numericValue \"54\"^^xsd:decimal .", text[15]); Assert.AreEqual("", text[16]); Assert.AreEqual("atlas:selectionCriteria5 rdf:type dfs:SelectionCriteria ;", text[17]); Assert.AreEqual("dfs:usesBinaryRelation dfs:lessThan ;", text[18]); Assert.AreEqual("dfs:hasFirstArgument atlas:number3 ;", text[19]); Assert.AreEqual("dfs:hasSecondArgument atlas:number4 .", text[20]); Assert.AreEqual("", text[21]); Assert.AreEqual("atlas:andor6 rdf:type dfs:And ;", text[22]); Assert.AreEqual("dfs:hasOperand atlas:selectionCriteria2 , atlas:selectionCriteria5 .", text[23]); }
/// <summary> /// Emit an AND/OR guy /// </summary> /// <param name="andor"></param> /// <param name="wr"></param> /// <returns></returns> public static string Emit(this ANDOR andor, TextWriter wr) { // Get the arguments out var criteria = andor.Arguments .Select(a => { var n = a.Emit(wr); wr.WriteLine(); return(n); }) .ToArray(); // Next our body. var name = MakeName("andor"); var andorname = andor.AOType == ANDORType.kAnd ? "And" : "Or"; wr.WriteLine($"{OWLNamespace}:{name} rdf:type dfs:{andorname} ;"); wr.Write(" dfs:hasOperand "); bool first = true; foreach (var a in criteria) { if (!first) { wr.Write(" , "); } first = false; wr.Write($"{OWLNamespace}:{a}"); } wr.WriteLine(" ."); return(name); }
/// <summary> /// Basic constructor /// </summary> public DetectorFinalState() { FinalStateObjects = new List<FinalStateObject>(); Criteria = new ANDOR() { AOType = ANDORType.kAnd }; }