Example #1
0
 //NamedValues1
 public static LeMondeType GetType(NamedValues<ZValue> values)
 {
     LeMondeType type = LeMondeType.Unknow;
     if (values.ContainsKey("type_code"))
     {
         type = GetTypeCode((string)values["type_code"]);
     }
     else if (values.ContainsKey("type_quo") && values["type_quo"] != null)
     {
         type = LeMondeType.Quotidien;
         if (values.ContainsKey("types_quo_sup"))
         {
             object o = values["types_quo_sup"];
             if (o != null && !(o is string[]))
                 throw new PBException("error creating LeMonde value types_quo_sup should be a string array : {0}", o);
             foreach (string s in (string[])o)
                 type |= GetTypeSup(s);
         }
     }
     else
     {
         if (!values.ContainsKey("type_sup"))
             throw new PBException("error creating LeMonde unknow type_sup");
         object o = values["type_sup"];
         if (!(o is string))
             throw new PBException("error creating LeMonde value type_sup should be a string : {0}", o);
         type = GetTypeSup((string)o);
     }
     return type;
 }
 public void SetParameters(NamedValues<ZValue> parameters)
 {
     if (parameters == null)
         return;
     foreach (KeyValuePair<string, ZValue> parameter in parameters)
         SetParameter(parameter);
 }
Example #3
0
 public static object[] GetParameters(MethodInfo methodInfo, NamedValues<ZValue> namedParameters, ErrorOptions option = ErrorOptions.None)
 {
     if (methodInfo == null)
         return null;
     List<object> parameters = new List<object>();
     //ParameterInfo[] methodParameters = methodInfo.GetParameters();
     foreach (ParameterInfo parameter in methodInfo.GetParameters())
     {
         object value;
         if (namedParameters != null && namedParameters.ContainsKey(parameter.Name))
         {
             // no control between parameter type and named parameter type
             value = namedParameters[parameter.Name].ToObject();
         }
         else if (parameter.HasDefaultValue)
         {
             value = parameter.DefaultValue;
         }
         else
         {
             Error.WriteMessage(option, $"no value for parameter \"{parameter.Name}\" of method \"{methodInfo.zGetName()}\", use default value");
             value = zReflection.GetDefaultValue(parameter.ParameterType);
         }
         parameters.Add(value);
     }
     return parameters.ToArray();
 }
Example #4
0
 //NamedValues1
 public override bool TrySetValues(NamedValues<ZValue> values)
 {
     if (!base.TrySetValues(values))
         return false;
     //_type = GetType(values);
     if (!TryGetType(values, out _type))
         return false;
     _typeCode = null;
     return true;
 }
Example #5
0
 // bool initServers = false
 public static DownloadAutomateManagerCreator GetDownloadAutomateManagerCreator(NamedValues<ZValue> parameters, bool test)
 {
     //if (initServers)
     //    InitServers();
     DownloadAutomateManagerCreator downloadAutomateManagerCreator = new DownloadAutomateManagerCreator();
     downloadAutomateManagerCreator.Init(GetDownloadAutomateManagerConfig(test), XmlConfig.CurrentConfig);
     if (parameters != null)
         downloadAutomateManagerCreator.SetParameters(parameters);
     return downloadAutomateManagerCreator;
 }
Example #6
0
 //NamedValues1
 public override bool TrySetValues(NamedValues<ZValue> values)
 {
     if (!base.TrySetValues(values))
         return false;
     if (values.ContainsKey("es"))
         _es = true;
     if (values.ContainsKey("styles"))
         _styles = true;
     if (values.ContainsKey("type_code"))
         //string
         SetType((string)values["type_code"]);
     return true;
 }
Example #7
0
 //NamedValues1
 public LeFigaro(NamedValues<ZValue> values)
 {
     if (!values.ContainsKey("day_near_current_date"))
     {
         if (!values.ContainsKey("year"))
             throw new PBException("error creating LeFigaro unknow year");
         if (!values.ContainsKey("month"))
             throw new PBException("error creating LeFigaro unknow month");
         if (!values.ContainsKey("day"))
             throw new PBException("error creating LeFigaro unknow day");
     }
     _date = zdate.CreateDate(values);
 }
Example #8
0
 //NamedValues1
 public override bool TrySetValues(NamedValues<ZValue> values)
 {
     if (!base.TrySetValues(values))
         return false;
     _eco = false;
     _mag = false;
     if (values.ContainsKey("eco"))
         _eco = true;
     if (values.ContainsKey("mag"))
         _mag = true;
     if (values.ContainsKey("type_code"))
         SetType((string)values["type_code"]);
     return true;
 }
Example #9
0
 public void readTags(CustomReportSection section)
 {
     PISDK.Server server=PIServerInfo.getPIServer("DEFAULT");
     IGetPoints2 srv=server as IGetPoints2;
     NamedValues nvs=new NamedValues();
     PointList points=srv.GetPoints2(section.FindString, nvs,GetPointsRetrievalTypes.useGetPoints);
     Tags = new List<CustomReportDataString>();
     foreach (PIPoint point in points) {
         CustomReportDataString tag=new CustomReportDataString();
         tag.TagName = point.Name;
         tag.TagTitle = point.PointAttributes["descriptor"].Value;
         tag.AvgData = false;
         tag.MaxData = false;
         tag.MinData = false;
         Tags.Add(tag);
     }
 }
Example #10
0
 //NamedValues1
 public LaCroix(NamedValues<ZValue> values)
 {
     // year          : mandatory, int or numeric string
     // day           : mandatory, int or numeric string
     // month         : mandatory, int or numeric string
     // number        : not used, int or numeric string
     if (!values.ContainsKey("day_near_current_date"))
     {
         if (!values.ContainsKey("year"))
             throw new PBException("error creating LaCroix unknow year");
         if (!values.ContainsKey("month"))
             throw new PBException("error creating LaCroix unknow month");
         if (!values.ContainsKey("day"))
             throw new PBException("error creating LaCroix unknow day");
     }
     _date = zdate.CreateDate(values);
 }
Example #11
0
 public static bool TryGetDay(NamedValues<ZValue> values, out int day)
 {
     day = 0;
     if (values.ContainsKey("day"))
     {
         ZValue v = values["day"];
         if (v is ZString)
         {
             day = GetDayNumber((string)v);
             if (day != 0)
                 return true;
         }
         else
             Trace.WriteLine("error day should be a string : {0}", v);
     }
     return false;
 }
Example #12
0
 //NamedValues1
 public override bool TrySetValues(NamedValues<ZValue> values)
 {
     if (!base.TrySetValues(values))
         return false;
     _weekEnd = false;
     _extra = false;
     _focus = false;
     if (values.ContainsKey("we"))
         _weekEnd = true;
     if (values.ContainsKey("extra"))
         _extra = true;
     if (values.ContainsKey("focus"))
         _focus = true;
     if (values.ContainsKey("type_code"))
         SetType((string)values["type_code"]);
     return true;
 }
Example #13
0
 //NamedValues1
 public LeMonde0(NamedValues<ZValue> values)
 {
     // year          : mandatory, int or numeric string
     // day           : mandatory, int or numeric string
     // month         : mandatory, int or numeric string
     // type_quo      : optional, string null, "_quo"
     // types_quo_sup : optional, string[], "tv", "argent"
     // type_sup      : optional, string null, "livres"
     // number        : not used, int or numeric string
     // type          : not used, string "_quo", "-livres", "_quo+tv", "_quo+tv+argent"
     if (!values.ContainsKey("year"))
         throw new PBException("error creating LeMonde unknow year");
     if (!values.ContainsKey("month"))
         throw new PBException("error creating LeMonde unknow month");
     if (!values.ContainsKey("day"))
         throw new PBException("error creating LeMonde unknow day");
     _date = zdate.CreateDate(values);
     _type = GetType(values);
 }
Example #14
0
        public static NamedValues<ZValue> ParseValues(string values, bool useLowercaseKey = false)
        {
            // datetime yyyy-mm-jj hh:mm:ss(.fff), datetime yyyy-mm-jj hh:mm:ss(.fff), date jj/mm/yyyy, date yyyy-mm-jj, time ((d.)hh:)mm:ss(.fff), double 1.(234), int 123, text 'text', text "text"
            // "datetime1 = 01/01/2015 01:35:52.123, datetime2 = 2015-01-01 01:35:52.123, date1 = 01/01/2015, date2 = 2015-01-01, time = 1.01:35:52.1234567, double = 1.123, int = 3, bool1 = true, bool2 =  false, text1 = 'toto', text2 = \"toto\""
            // "version = 3, date = 01/01/2015, text1 = 'toto', text2 = \"toto\", time = 01:35:52"
            NamedValues<ZValue> namedValues = new NamedValues<ZValue>(useLowercaseKey);
            if (values == null)
                return namedValues;
            Match match = __parseValues.Match(values);
            while (match.Success)
            {
                string name = match.Groups[1].Value;
                ZValue value = null;
                if (match.Groups[2].Value != "")
                {
                    // datetime jj/mm/yyyy hh:mm:ss(.fff) : Groups[2] day, Groups[3] month, Groups[4] year, Groups[5] hour, Groups[6] minute, Groups[7] second, Groups[8] millisecond
                    value = new DateTime(int.Parse(match.Groups[4].Value), int.Parse(match.Groups[3].Value), int.Parse(match.Groups[2].Value), int.Parse(match.Groups[5].Value),
                        int.Parse(match.Groups[6].Value), int.Parse(match.Groups[7].Value), int.Parse(match.Groups[8].Value.PadRight(3, '0')));
                }
                else if (match.Groups[9].Value != "")
                {
                    // datetime yyyy-mm-jj hh:mm:ss(.fff) : Groups[9] year, Groups[10] month, Groups[11] day, Groups[12] hour, Groups[13] minute, Groups[14] second, Groups[15] millisecond
                    value = new DateTime(int.Parse(match.Groups[9].Value), int.Parse(match.Groups[10].Value), int.Parse(match.Groups[11].Value), int.Parse(match.Groups[12].Value),
                        int.Parse(match.Groups[13].Value), int.Parse(match.Groups[14].Value), int.Parse(match.Groups[15].Value.PadRight(3, '0')));
                }
                else if (match.Groups[16].Value != "")
                {
                    // date jj/mm/yyyy : Groups[16] day, Groups[17] month, Groups[18] year
                    value = new DateTime(int.Parse(match.Groups[18].Value), int.Parse(match.Groups[17].Value), int.Parse(match.Groups[16].Value));
                }
                else if (match.Groups[19].Value != "")
                {
                    // date yyyy-mm-jj : Groups[19] year, Groups[20] month, Groups[21] day
                    value = new DateTime(int.Parse(match.Groups[19].Value), int.Parse(match.Groups[20].Value), int.Parse(match.Groups[21].Value));
                }
                else if (match.Groups[22].Value != "")
                {
                    // time ((d.)hh:)mm:ss(.fffffff) : Groups[22] days, Groups[23] hours, Groups[24] minutes, Groups[25] seconds, Groups[26] seconds decimales
                    int days = 0;
                    string group = match.Groups[22].Value;
                    if (group != "")
                        days = int.Parse(group);

                    int hours = 0;
                    group = match.Groups[23].Value;
                    if (group != "")
                        hours = int.Parse(group);

                    int minutes = 0;
                    group = match.Groups[24].Value;
                    if (group != "")
                        minutes = int.Parse(group);

                    int seconds = 0;
                    group = match.Groups[25].Value;
                    if (group != "")
                        seconds = int.Parse(group);

                    // ticks 1 234 567
                    int ticks = 0;
                    group = match.Groups[26].Value;
                    if (group != "")
                        ticks = int.Parse(group.PadRight(7, '0'));

                    value = zparse.CreateTimeSpan(days, hours, minutes, seconds, ticks);
                }
                else if (match.Groups[27].Value != "")
                {
                    // double 1.(234) : Groups[27] double
                    value = double.Parse(match.Groups[27].Value);
                }
                else if (match.Groups[28].Value != "")
                {
                    // int 123 : Groups[28] int
                    value = int.Parse(match.Groups[28].Value);
                }
                else if (match.Groups[29].Value != "")
                {
                    // bool true false : Groups[29] bool
                    value = bool.Parse(match.Groups[29].Value);
                }
                else if (match.Groups[30].Value != "")
                {
                    // text 'text' : Groups[30] text
                    value = match.Groups[30].Value;
                }
                else if (match.Groups[31].Value != "")
                {
                    // text "text" : Groups[31] text
                    value = match.Groups[31].Value;
                }
                //namedValues.Add(name, value);
                namedValues.SetValue(name, value);
                match = match.NextMatch();
            }
            return namedValues;
        }
Example #15
0
 public static void TraceValues(NamedValues<ZValue> values)
 {
     foreach (KeyValuePair<string, ZValue> value in values)
         Trace.WriteLine("name {0} value {1}", value.Key, value.Value);
 }
Example #16
0
 public static bool GetTestValue(NamedValues<ZValue> parameters)
 {
     if (parameters.ContainsKey("test"))
         return (bool)parameters["test"];
     return false;
 }
Example #17
0
 public PrintTitleInfos ExtractTitleInfos(string title)
 {
     // LES JOURNAUX -  MERCREDI 29 / 30 OCTOBRE 2014 & + [PDF][Lien Direct]
     // extract [PDF][Lien Direct]
     //string title = post.title;
     if (title == null)
         return new PrintTitleInfos { foundInfo = false };
     NamedValues<ZValue> infos = new NamedValues<ZValue>();
     bool foundInfo = false;
     while (true)
     {
         Match match = __rgTitleInfo.Match(title);
         if (!match.Success)
             break;
         foundInfo = true;
         infos.SetValue(match.Groups[1].Value, null);
         title = match.zReplace(title, "_");
     }
     if (foundInfo)
     {
         title = Trim(title);
         return new PrintTitleInfos { foundInfo = true, title = title, infos = infos };
     }
     else
         return new PrintTitleInfos { foundInfo = false };
 }
Example #18
0
 private string ExtractTextValues(NamedValues<ZValue> infos, string s)
 {
     // French | PDF | 107 MB -*- French | PDF |  22 Pages | 7 MB -*- PDF | 116 pages | 205/148 pages | 53 Mb | French -*- Micro Application | 2010 | ISBN: 2300028441 | 221 pages | PDF
     // pb : |I|N|F|O|S|, |S|Y|N|O|P|S|I|S|, |T|E|L|E|C|H|A|R|G|E|R|
     // example http://www.telechargement-plus.com/e-book-magazines/bande-dessines/136846-season-one-100-marvel-syrie-en-cours-10-tomes-comicmulti.html
     if (s.Contains('|'))
     {
         //Trace.CurrentTrace.WriteLine("info \"{0}\"", s);
         foreach (string s2 in zsplit.Split(s, '|', true))
         {
             string s3 = s2;
             NamedValues<ZValue> values = _textInfoRegexList.ExtractTextValues(ref s3);
             infos.SetValues(values);
             //s3 = s3.Trim();
             s3 = Trim(s3);
             if (s3 != "")
             {
                 string name;
                 string value;
                 if (ExtractTextValues2(s3, out name, out value))
                     infos.SetValue(name, value);
                 else
                     infos.SetValue(s3, null);
             }
         }
         return "";
     }
     else
     //{
     //    NamedValues<ZValue> values = _textInfoRegexList.ExtractTextValues(ref s);
     //    infos.SetValues(values);
     //    return s;
     //}
     return s;
 }
Example #19
0
 public static FindPrintManager Create(XElement xe = null, NamedValues<ZValue> parameters = null, int version = 0)
 {
     FindPrintManagerCreator createFindPrintManager = new FindPrintManagerCreator();
     createFindPrintManager.Init(xe);
     if (version != 0)
         createFindPrintManager.Version = version;
     createFindPrintManager.SetParameters(parameters);
     return createFindPrintManager.Create();
 }
Example #20
0
        private Function DefineFunction(Function function, ExpressionContext body)
        {
            if (!function.IsDeclaration)
            {
                throw new ArgumentException($"Function {function.Name} cannot be redefined", nameof(function));
            }

            var proto      = FunctionPrototypes[function.Name];
            var basicBlock = function.AppendBasicBlock("entry");

            InstructionBuilder.PositionAtEnd(basicBlock);

            var diFile = Module.DICompileUnit.File;
            var scope  = Module.DICompileUnit;

            LexicalBlocks.Push(function.DISubProgram);

            // Unset the location for the prologue emission (leading instructions with no
            // location in a function are considered part of the prologue and the debugger
            // will run past them when breaking on a function)
            EmitLocation(null);

            NamedValues.Clear( );
            foreach (var arg in function.Parameters)
            {
                uint line = ( uint )proto.Parameters[( int )(arg.Index)].Span.StartLine;
                uint col  = ( uint )proto.Parameters[( int )(arg.Index)].Span.StartColumn;

                var             argSlot  = CreateEntryBlockAlloca(function, arg.Name);
                DILocalVariable debugVar = Module.DIBuilder.CreateArgument(function.DISubProgram
                                                                           , arg.Name
                                                                           , diFile
                                                                           , line
                                                                           , DoubleType
                                                                           , true
                                                                           , DebugInfoFlags.None
                                                                           , checked (( ushort )(arg.Index + 1)) // Debug index starts at 1!
                                                                           );
                Module.DIBuilder.InsertDeclare(argSlot
                                               , debugVar
                                               , new DILocation(Context, line, col, function.DISubProgram)
                                               , InstructionBuilder.InsertBlock
                                               );

                InstructionBuilder.Store(arg, argSlot);
                NamedValues[arg.Name] = argSlot;
            }

            var funcReturn = body.Accept(this);

            if (funcReturn == null)
            {
                function.EraseFromParent( );
                LexicalBlocks.Pop( );
                return(null);
            }

            InstructionBuilder.Return(funcReturn);
            LexicalBlocks.Pop( );
            Module.DIBuilder.Finish(function.DISubProgram);
            function.Verify( );
            Trace.TraceInformation(function.ToString( ));

            return(function);
        }
        public override Value Visit(ForInExpression forInExpression)
        {
            var    function  = InstructionBuilder.InsertBlock.ContainingFunction;
            string varName   = forInExpression.LoopVariable.Name;
            Alloca allocaVar = LookupVariable(varName);

            // Emit the start code first, without 'variable' in scope.
            Value startVal;

            if (forInExpression.LoopVariable.Initializer != null)
            {
                startVal = forInExpression.LoopVariable.Initializer.Accept(this);
                if (startVal == null)
                {
                    return(null);
                }
            }
            else
            {
                startVal = Context.CreateConstant(0.0);
            }

            // store the value into allocated location
            InstructionBuilder.Store(startVal, allocaVar);

            // Make the new basic block for the loop header.
            var loopBlock = function.AppendBasicBlock("loop");

            // Insert an explicit fall through from the current block to the loopBlock.
            InstructionBuilder.Branch(loopBlock);

            // Start insertion in loopBlock.
            InstructionBuilder.PositionAtEnd(loopBlock);

            // Within the loop, the variable is defined equal to the PHI node.
            // So, push a new scope for it and any values the body might set
            using (NamedValues.EnterScope( ))
            {
                EmitBranchToNewBlock("ForInScope");

                // Emit the body of the loop.  This, like any other expression, can change the
                // current BB.  Note that we ignore the value computed by the body, but don't
                // allow an error.
                if (forInExpression.Body.Accept(this) == null)
                {
                    return(null);
                }

                Value stepValue = forInExpression.Step.Accept(this);
                if (stepValue == null)
                {
                    return(null);
                }

                // Compute the end condition.
                Value endCondition = forInExpression.Condition.Accept(this);
                if (endCondition == null)
                {
                    return(null);
                }

                // since the Alloca is created as a non-opaque pointer it is OK to just use the
                // ElementType. If full opaque pointer support was used, then the Lookup map
                // would need to include the type of the value allocated.
                var curVar = InstructionBuilder.Load(allocaVar.ElementType, allocaVar)
                             .RegisterName(varName);
                var nextVar = InstructionBuilder.FAdd(curVar, stepValue)
                              .RegisterName("nextvar");
                InstructionBuilder.Store(nextVar, allocaVar);

                // Convert condition to a bool by comparing non-equal to 0.0.
                endCondition = InstructionBuilder.Compare(RealPredicate.OrderedAndNotEqual, endCondition, Context.CreateConstant(0.0))
                               .RegisterName("loopcond");

                // Create the "after loop" block and insert it.
                var afterBlock = function.AppendBasicBlock("afterloop");

                // Insert the conditional branch into the end of LoopEndBB.
                InstructionBuilder.Branch(endCondition, loopBlock, afterBlock);
                InstructionBuilder.PositionAtEnd(afterBlock);

                // for expression always returns 0.0 for consistency, there is no 'void'
                return(Context.DoubleType.GetNullValue( ));
            }
        }
Example #22
0
        //public static bool TryCreateDate(NamedValues<ZValue> values, out Date date, out DateType dateType, NamedValues<ZValue> param = null)
        public static bool TryCreateDate(NamedValues<ZValue> values, out Date date, out DateType dateType)
        {
            date = Date.MinValue;
            dateType = DateType.Unknow;
            DateValues dateValues = DateValues.GetDateValues(values);
            //if (!values.ContainsKey("day_near_current_date") && !values.ContainsKey("month") && !values.ContainsKey("month1") && !values.ContainsKey("month2") && !values.ContainsKey("year"))
            if (dateValues.dayNearCurrentDate == null && dateValues.month == null && dateValues.year == null)
            {
                //values.SetError("error creating Date unknow day_near_current_date and month (month1 or month2)");
                //Trace.WriteLine("error creating Date unknow day_near_current_date unknow month (month1 and month2) and unknow year (year1 and year2)");
                return false;
            }

            //if (values.ContainsKey("day_near_current_date"))
            if (dateValues.dayNearCurrentDate != null)
            {
                //return TryCreateDateFromDay(values, out date, out dateType, param);
                return TryCreateDateFromDay(dateValues, out date, out dateType);
            }
            else
            {
                //return TryCreateDateFromYearMonthDay(values, out date, out dateType, param);
                return TryCreateDateFromYearMonthDay(dateValues, out date, out dateType);
            }
        }
Example #23
0
        public static DateValues GetDateValues(NamedValues<ZValue> values)
        {
            DateValues dateValues = new DateValues();

            ZValue v;
            if (values.ContainsKey("day_near_current_date"))
            {
                v = values["day_near_current_date"];
                //if (v is ZStringArray)
                //    v = ((ZStringArray)v).SelectArrayValue();
                if (v is ZString)
                {
                    string s = (string)v;
                    s = s.Replace('o', '0');
                    s = s.Replace('O', '0');
                    int day;
                    if (int.TryParse(s, out day))
                        dateValues.dayNearCurrentDate = day;
                    else
                    {
                        //values.SetError("error creating Date day_near_current_date is'nt a number : \"{0}\"", v);
                        Trace.WriteLine("error creating Date day_near_current_date is'nt a number : \"{0}\"", v);
                        //return false;
                    }
                }
                else if (v is ZInt)
                    //day = (int)v;
                    dateValues.dayNearCurrentDate = (int)v;
                else
                {
                    //values.SetError("error creating Date day_near_current_date should be a string number or an int : {0}", v);
                    Trace.WriteLine("error creating Date day_near_current_date should be a string number or an int : {0}", v);
                    //return false;
                }
            }

            //string name = null;
            //if (values.ContainsKey("year"))
            //    name = "year";
            //else if (values.ContainsKey("year1"))
            //    name = "year1";
            //else if (values.ContainsKey("year2"))
            //    name = "year2";

            v = null;
            if (values.ContainsKey("year1"))
            {
                v = values["year1"];
                if (v is ZString && string.IsNullOrEmpty((string)v))
                    v = null;
            }
            if (v == null && values.ContainsKey("year2"))
            {
                v = values["year2"];
                if (v is ZString && string.IsNullOrEmpty((string)v))
                    v = null;
            }
            if (v == null && values.ContainsKey("year"))
            {
                v = values["year"];
                if (v is ZString && string.IsNullOrEmpty((string)v))
                    v = null;
            }

            if (v != null)
            {
                //if (v is ZStringArray)
                //    v = ((ZStringArray)v).SelectArrayValue();
                if (v is ZString)
                {
                    int year;
                    if (int.TryParse((string)v, out year))
                        dateValues.year = year;
                    else
                    {
                        //values.SetError("error creating Date year is'nt a number : \"{0}\"", v);
                        Trace.WriteLine("error creating Date year is'nt a number : \"{0}\"", v);
                        //return false;
                    }
                }
                else if (v is ZInt)
                    dateValues.year = (int)v;
                else if (v != null)
                {
                    //values.SetError("error creating Date year should be a string number or an int : {0}", v);
                    Trace.WriteLine("error creating Date year should be a string number or an int : {0}", v);
                    //return false;
                }
            }



            v = null;
            if (values.ContainsKey("month1"))
            {
                v = values["month1"];
                if (v is ZString && string.IsNullOrEmpty((string)v))
                    v = null;
            }
            if (v == null && values.ContainsKey("month2"))
            {
                v = values["month2"];
                if (v is ZString && string.IsNullOrEmpty((string)v))
                    v = null;
            }
            if (v == null && values.ContainsKey("month"))
            {
                v = values["month"];
                if (v is ZString && string.IsNullOrEmpty((string)v))
                    v = null;
            }

            if (v != null)
            {
                //if (v is ZStringArray)
                //    v = ((ZStringArray)v).SelectArrayValue();
                if (v is ZString)
                {
                    int month;
                    if (int.TryParse((string)v, out month))
                        dateValues.month = month;
                    else
                    {
                        month = zdate.GetMonthNumber((string)v);
                        if (month != 0)
                            dateValues.month = month;
                        else
                        {
                            //values.SetError("error creating Date invalid month : \"{0}\"", v);
                            Trace.WriteLine("error creating Date invalid month : \"{0}\"", v);
                            //return false;
                        }
                    }
                }
                else if (v is ZInt)
                    dateValues.month = (int)v;
                else if (v != null)
                {
                    //values.SetError("error creating Date month should be a string number or an int : {0}", v);
                    Trace.WriteLine("error creating Date month should be a string number or an int : {0}", v);
                    //return false;
                }
            }


            if (values.ContainsKey("day"))
            {
                v = values["day"];
                //if (v is ZStringArray)
                //    v = ((ZStringArray)v).SelectArrayValue();
                if (v is ZString)
                {
                    int day;
                    //if ((string)v == "1er")
                    if (string.Equals((string)v, "1er", StringComparison.InvariantCultureIgnoreCase))
                        dateValues.day = 1;
                    else if (int.TryParse((string)v, out day))
                        dateValues.day = day;
                    else
                    {
                        //values.SetError("error creating Date day is'nt a number : \"{0}\"", v);
                        Trace.WriteLine("error creating Date day is'nt a number : \"{0}\"", v);
                        //return false;
                    }
                }
                else if (v is ZInt)
                {
                    dateValues.day = (int)v;
                }
                else if (v != null)
                {
                    //values.SetError("error creating Date day should be a string number or an int : {0}", v);
                    //Trace.WriteLine("error creating Date day should be a string number or an int : value {0} type {1}", v != null ? v : "(null)", v != null ? v.GetType().zName() : "(null)");
                    Trace.WriteLine("error creating Date day should be a string number or an int : value {0} type {1}", v, v.GetType().zGetTypeName());
                    //return false;
                }
            }



            return dateValues;
        }
Example #24
0
        public void ExecuteMetadataRefresh(object state)
        {
            OnStatusMessage("Beginning metadata refresh...");

            try
            {
                base.RefreshMetadata();

                if (InputMeasurementKeys != null && InputMeasurementKeys.Any())
                {
                    IPIPoints2 pts2 = (IPIPoints2)m_server.PIPoints;
                    //NamedValues edits = new NamedValues();
                    //PIErrors errors = new PIErrors();
                    PointList piPoints;
                    DataTable dtMeasurements = DataSource.Tables["ActiveMeasurements"];
                    DataRow[] rows;
                    foreach (MeasurementKey key in InputMeasurementKeys)
                    {
                        rows = dtMeasurements.Select(string.Format("SIGNALID='{0}'", key.SignalID));

                        if (rows.Any())
                        {
                            string tagname = rows[0]["POINTTAG"].ToString();
                            if (!String.IsNullOrWhiteSpace(rows[0]["ALTERNATETAG"].ToString()))
                                tagname = rows[0]["ALTERNATETAG"].ToString();

                            piPoints = m_server.GetPoints(string.Format("EXDESC='{0}'", rows[0]["SIGNALID"].ToString()));

                            if (piPoints.Count == 0)
                            {
                                m_server.PIPoints.Add(rows[0]["POINTTAG"].ToString(), m_piPointClass, PointTypeConstants.pttypFloat32);
                            }
                            else if (piPoints[1].Name != rows[0]["POINTTAG"].ToString())
                            {
                                pts2.Rename(piPoints[1].Name, rows[0]["POINTTAG"].ToString());
                            }
                            else
                            {
                                foreach (PIPoint pt in piPoints)
                                {
                                    if (pt.Name != rows[0]["POINTTAG"].ToString())
                                        pts2.Rename(pt.Name, rows[0]["POINTTAG"].ToString());
                                }
                            }

                            PIErrors errors = new PIErrors();
                            NamedValues edits = new NamedValues();
                            NamedValues edit = new NamedValues();
                            edit.Add("pointsource", m_piPointSource);
                            edit.Add("Descriptor", rows[0]["SIGNALREFERENCE"].ToString());
                            edit.Add("exdesc", rows[0]["SIGNALID"].ToString());
                            edit.Add("sourcetag", rows[0]["POINTTAG"].ToString());

                            if (dtMeasurements.Columns.Contains("ENGINEERINGUNITS")) // engineering units is a new field for this view -- handle the case that its not there
                                edit.Add("engunits", rows[0]["ENGINEERINGUNITS"].ToString());

                            edits.Add(rows[0]["POINTTAG"].ToString(), edit);
                            pts2.EditTags(edits, out errors, null);

                            if (errors.Count > 0)
                                OnStatusMessage(errors[0].Description);
                        }
                    }
                }
                else
                {
                    OnStatusMessage("PI Historian is not configured with any input measurements. Therefore, metadata sync will not do work.");
                }
            }
            catch (ThreadAbortException)
            {
                throw;
            }
            catch (Exception ex)
            {
                OnProcessException(ex);
            }
            finally
            {
                m_metadataRefreshComplete.Set();
            }

            OnStatusMessage("Completed metadata refresh successfully.");
        }
Example #25
0
        /*
         * // Output for-loop as:
         * //   ...
         * //   start = startexpr
         * //   goto loop
         * // loop:
         * //   variable = phi [start, loopheader], [nextvariable, loopend]
         * //   ...
         * //   bodyexpr
         * //   ...
         * // loopend:
         * //   step = stepexpr
         * //   nextvariable = variable + step
         * //   endcond = endexpr
         * //   br endcond, loop, endloop
         * // outloop:
         */
        public override Value VisitForExpression([NotNull] ForExpressionContext context)
        {
            EmitLocation(context);
            var    function  = InstructionBuilder.InsertBlock.ContainingFunction;
            string varName   = context.Initializer.Name;
            var    allocaVar = CreateEntryBlockAlloca(function, varName);

            // Emit the start code first, without 'variable' in scope.
            Value startVal = null;

            if (context.Initializer.Value != null)
            {
                startVal = context.Initializer.Value.Accept(this);
                if (startVal == null)
                {
                    return(null);
                }
            }
            else
            {
                startVal = Context.CreateConstant(0.0);
            }

            // store the value into allocated location
            InstructionBuilder.Store(startVal, allocaVar);

            // Make the new basic block for the loop header, inserting after current
            // block.
            var preHeaderBlock = InstructionBuilder.InsertBlock;
            var loopBlock      = Context.CreateBasicBlock("loop", function);

            // Insert an explicit fall through from the current block to the loopBlock.
            InstructionBuilder.Branch(loopBlock);

            // Start insertion in loopBlock.
            InstructionBuilder.PositionAtEnd(loopBlock);

            // Start the PHI node with an entry for Start.
            var variable = InstructionBuilder.PhiNode(Context.DoubleType)
                           .RegisterName(varName);

            variable.AddIncoming(startVal, preHeaderBlock);

            // Within the loop, the variable is defined equal to the PHI node.  If it
            // shadows an existing variable, we have to restore it, so save it now.
            NamedValues.TryGetValue(varName, out Alloca oldValue);
            NamedValues[varName] = allocaVar;

            // Emit the body of the loop.  This, like any other expr, can change the
            // current BB.  Note that we ignore the value computed by the body, but don't
            // allow an error.
            if (context.BodyExpression.Accept(this) == null)
            {
                return(null);
            }

            Value stepValue = Context.CreateConstant(1.0);

            // DEBUG: How does ANTLR represent optional context (Null or IsEmpty == true)
            if (context.StepExpression != null)
            {
                stepValue = context.StepExpression.Accept(this);
                if (stepValue == null)
                {
                    return(null);
                }
            }

            // Compute the end condition.
            Value endCondition = context.EndExpression.Accept(this);

            if (endCondition == null)
            {
                return(null);
            }

            var curVar = InstructionBuilder.Load(allocaVar)
                         .RegisterName(varName);
            var nextVar = InstructionBuilder.FAdd(curVar, stepValue)
                          .RegisterName("nextvar");

            InstructionBuilder.Store(nextVar, allocaVar);

            // Convert condition to a bool by comparing non-equal to 0.0.
            endCondition = InstructionBuilder.Compare(RealPredicate.OrderedAndNotEqual, endCondition, Context.CreateConstant(1.0))
                           .RegisterName("loopcond");

            // Create the "after loop" block and insert it.
            var loopEndBlock = InstructionBuilder.InsertBlock;
            var afterBlock   = Context.CreateBasicBlock("afterloop", function);

            // Insert the conditional branch into the end of LoopEndBB.
            InstructionBuilder.Branch(endCondition, loopBlock, afterBlock);
            InstructionBuilder.PositionAtEnd(afterBlock);

            // Add a new entry to the PHI node for the backedge.
            variable.AddIncoming(nextVar, loopEndBlock);

            // Restore the unshadowed variable.
            if (oldValue != null)
            {
                NamedValues[varName] = oldValue;
            }
            else
            {
                NamedValues.Remove(varName);
            }

            // for expr always returns 0.0 for consistency, there is no 'void'
            return(Context.DoubleType.GetNullValue( ));
        }
Example #26
0
 public Vosbooks_PostDetail_v1()
 {
     Infos = new NamedValues <ZValue>(useLowercaseKey: true);
 }
Example #27
0
        //public RegexValues NormalizedFilename { get { return _normalizedFilename; } }
        //public RegexValues NormalizedSpecialFilename { get { return _normalizedSpecialFilename; } }

        //public string GetName() { return _name; }

        //public virtual bool IsMatchFilename(string filename)
        //{
        //    if (_regexPrint == null)
        //        return false;
        //    return _regexPrint.IsMatch(filename);
        //}

        //public virtual Match MatchFilename(string filename)
        //{
        //    if (_regexPrint == null)
        //        return null;
        //    return _regexPrint.Match(filename);
        //}

        public virtual void NewIssue()
        {
            //NamedValues1
            _printValues = new NamedValues<ZValue>();
            _date = null;
            _printNumber = 0;
            _special = false;
            _specialMonth = false;
            _label = null;
            _index = 0;
        }
 public MagazinesGratuits_PostDetail_v1()
 {
     Infos = new NamedValues <ZValue>(useLowercaseKey: true);
 }
Example #29
0
        //NamedValues1
        public virtual bool TrySetValues(NamedValues<ZValue> values)
        {
            //_special
            //NewIssue();
            //if (values.ContainsKey("special_month"))
            //{
            //    _special_month = true;
            //    _date = date.CreateDate(values);
            //    _printNumber = GetPrintNumber(values);
            //}
            //else
            //{
            //    if (values.ContainsKey("day_near_current_date") || values.ContainsKey("year") || values.ContainsKey("month") || values.ContainsKey("day"))
            //        _date = date.CreateDate(values);
            //    if (values.ContainsKey("number"))
            //    {
            //        _printNumber = GetPrintNumber(values);
            //    }
            //}
            //_printValues = values;
            if (values.ContainsKey("special"))
                _special = true;
            if (values.ContainsKey("special_month"))
                _specialMonth = true;
            //bool setDate = false;
            //if (values.ContainsKey("day_near_current_date") || values.ContainsKey("year") || values.ContainsKey("month") || values.ContainsKey("day"))
            if (values.ContainsKey("day_near_current_date") || values.ContainsKey("month"))
            {
                //_date = date.CreateDate(values);
                //setDate = true;
                Date date;
                DateType dateType;
                if (!zdate.TryCreateDate(values, out date, out dateType))
                    return false;
                _date = date;
            }
            if (values.ContainsKey("number"))
            {
                //if (!setDate || _noDateAndNumberCalculate)
                //_printNumber = GetPrintNumber(values);
                if (!TryGetPrintNumber(values, out _printNumber))
                    return false;
            }
            if (_date != null && _printNumber != 0 && !_noDateAndNumberCalculate && !_special && !_specialMonth)
            {
                if (_frequency == PrintFrequency.Daily)
                    _printNumber = 0;
                else
                    _date = null;
            }

            if (values.ContainsKey("label"))
                _label = (string)values["label"];
            if (values.ContainsKey("index"))
            {
                //_index = GetIndex(values);
                if (!TryGetIndex(values, out _index))
                    return false;
            }
            _printValues.SetValues(values);
            return true;
        }
Example #30
0
 //NamedValues1
 protected virtual bool TryGetPrintNumber(NamedValues<ZValue> values, out int number)
 {
     number = 0;
     if (!values.ContainsKey("number"))
     {
         //throw new PBException("error print number not found");
         values.SetError("error print number not found");
         return false;
     }
     int number2;
     if (!int.TryParse((string)values["number"], out number2))
     {
         //throw new PBException("error invalid print number \"{0}\"", values["number"]);
         values.SetError("error invalid print number \"{0}\"", values["number"]);
         return false;
     }
     //return printNumber;
     number = number2;
     return true;
 }
 public MagazinesGratuits_PostDetail_v2()
 {
     Infos = new NamedValues<ZValue>(useLowercaseKey: true);
 }
Example #32
0
 //NamedValues1
 protected virtual bool TryGetIndex(NamedValues<ZValue> values, out int index)
 {
     index = 0;
     if (!values.ContainsKey("index"))
     {
         //throw new PBException("error index not found");
         values.SetError("error index not found");
         return false;
     }
     string s = (string)values["index"];
     if (s == null)
         //return 0;
         return true;
     int index2;
     if (!int.TryParse(s, out index2))
     {
         //throw new PBException("error invalid index \"{0}\"", s);
         values.SetError("error invalid index \"{0}\"", s);
         return false;
     }
     //return index;
     index = index2;
     return true;
 }
Example #33
0
 //public static Date CreateDate(NamedValues<ZValue> values, NamedValues<ZValue> param = null)
 public static Date CreateDate(NamedValues<ZValue> values)
 {
     Date date;
     DateType dateType;
     //if (TryCreateDate(values, out date, out dateType, param))
     if (TryCreateDate(values, out date, out dateType))
         return date;
     else
         throw new PBException(values.Error);
 }
Example #34
0
 public Vosbooks_PostDetail_v2()
 {
     Infos = new NamedValues<ZValue>(useLowercaseKey: true);
 }
Example #35
0
        //public static bool TryCreateDateFromDay(NamedValues<ZValue> values, out Date date, out DateType dateType, NamedValues<ZValue> param = null)
        public static bool TryCreateDateFromDay(DateValues dateValues, out Date date, out DateType dateType, NamedValues<ZValue> param = null)
        {
            date = Date.MinValue;
            dateType = DateType.Unknow;
            //int day;
            //ZValue v = values["day_near_current_date"];
            //if (v is ZString)
            //{
            //    string s = (string)v;
            //    s = s.Replace('o', '0');
            //    s = s.Replace('O', '0');
            //    if (!int.TryParse(s, out day))
            //    {
            //        //throw new PBException("error creating Date day_near_current_date is'nt a number : \"{0}\"", o);
            //        values.SetError("error creating Date day_near_current_date is'nt a number : \"{0}\"", v);
            //        return false;
            //    }
            //}
            //else if (v is ZInt)
            //    day = (int)v;
            //else
            //{
            //    //throw new PBException("error creating Date day_near_current_date should be a string number or an int : {0}", o);
            //    values.SetError("error creating Date day_near_current_date should be a string number or an int : {0}", v);
            //    return false;
            //}

            //if (!TryGetDateFromDay(day, out date))
            if (!TryGetDateFromDay((int)dateValues.dayNearCurrentDate, out date))
            {
                //throw new PBException("error creating Date bad day_near_current_date : {0}", day);
                //values.SetError("error creating Date bad day_near_current_date : {0}", day);
                Trace.WriteLine("error creating Date bad day_near_current_date : {0}", dateValues.dayNearCurrentDate);
                return false;
            }
            dateType = DateType.Day;
            return true;
        }
Example #36
0
        //NamedValues1
        public virtual bool TrySetValues(NamedValues <ZValue> values)
        {
            //_special
            //NewIssue();
            //if (values.ContainsKey("special_month"))
            //{
            //    _special_month = true;
            //    _date = date.CreateDate(values);
            //    _printNumber = GetPrintNumber(values);
            //}
            //else
            //{
            //    if (values.ContainsKey("day_near_current_date") || values.ContainsKey("year") || values.ContainsKey("month") || values.ContainsKey("day"))
            //        _date = date.CreateDate(values);
            //    if (values.ContainsKey("number"))
            //    {
            //        _printNumber = GetPrintNumber(values);
            //    }
            //}
            //_printValues = values;
            if (values.ContainsKey("special"))
            {
                _special = true;
            }
            if (values.ContainsKey("special_month"))
            {
                _specialMonth = true;
            }
            //bool setDate = false;
            //if (values.ContainsKey("day_near_current_date") || values.ContainsKey("year") || values.ContainsKey("month") || values.ContainsKey("day"))
            if (values.ContainsKey("day_near_current_date") || values.ContainsKey("month"))
            {
                //_date = date.CreateDate(values);
                //setDate = true;
                Date     date;
                DateType dateType;
                if (!zdate.TryCreateDate(values, out date, out dateType))
                {
                    return(false);
                }
                _date = date;
            }
            if (values.ContainsKey("number"))
            {
                //if (!setDate || _noDateAndNumberCalculate)
                //_printNumber = GetPrintNumber(values);
                if (!TryGetPrintNumber(values, out _printNumber))
                {
                    return(false);
                }
            }
            if (_date != null && _printNumber != 0 && !_noDateAndNumberCalculate && !_special && !_specialMonth)
            {
                if (_frequency == PrintFrequency.Daily)
                {
                    _printNumber = 0;
                }
                else
                {
                    _date = null;
                }
            }

            if (values.ContainsKey("label"))
            {
                _label = (string)values["label"];
            }
            if (values.ContainsKey("index"))
            {
                //_index = GetIndex(values);
                if (!TryGetIndex(values, out _index))
                {
                    return(false);
                }
            }
            _printValues.SetValues(values);
            return(true);
        }