Пример #1
0
        public DataSet GetDiff(string oldLogName, string newLogName)
        {
            Output = CompareLogs(oldLogName, newLogName);
            if (!Output.Succeeded)
            {
                DataTable errors  = new DataTable(),
                          solPath = new DataTable();
                var log           = new DataSet();

                DataTableUtils.CreatePvsDataTable(errors, solPath, errors.DefaultView);

                MergeMessages(Output, errors);

                //FIXME: Compare old and new solPath's.
                //FIXME: Find cleaner way to get it.
                log.ReadXml(newLogName);
                int tblIdx = 1;

                log.Tables.RemoveAt(tblIdx);

                log.Tables.Add(errors);
                return(log);
            }

            return(null);
        }
Пример #2
0
        private ComparisonOutput CompareLogs(string oldlog, string newlog)
        {
            var result = new ComparisonOutput {
                Succeeded = true
            };

            DataSet oldTable = new DataSet(), newTable = new DataSet();

            oldTable.ReadXml(oldlog);
            newTable.ReadXml(newlog);

            const int tableIndex = 1;

            var newTableExtendedKeys = PluginDiffUtilities.PvsExtendedPrimaryKeysPvsMode;
            var oldTableExtendedKey  = PluginDiffUtilities.PvsExtendedPrimaryKeysPvsMode;

            PluginDiffUtilities.SetNewPk(newTable.Tables[tableIndex], newTableExtendedKeys);
            PluginDiffUtilities.SetNewPk(oldTable.Tables[1], oldTableExtendedKey);

            var missings  = GetComparisionList(oldTable, newTable, MissingMark);
            var additions = GetComparisionList(newTable, oldTable, AdditionsMark);
            var modifies  = MergeDoubleMessagesInList(missings, additions);

            result.Modifies    = modifies;
            result.Missings    = missings;
            result.Additionals = additions;

            if (result.Additionals.Rows.Count > 0 || result.Missings.Rows.Count > 0 || result.Modifies.Rows.Count > 0)
            {
                result.Succeeded = false;
            }

            return(result);
        }
Пример #3
0
 internal MultiValueComparisonConfig(bool isSigned, byte input, Comparison op, ComparisonOutput mode, byte[] references) : base()
 {
     this.isSigned   = isSigned;
     this.input      = input;
     this.op         = op;
     this.mode       = mode;
     this.references = references;
 }
Пример #4
0
            internal MultiValueComparisonConfig(byte[] config) : base()
            {
                isSigned = (config[1] & 0x1) == 0x1;
                input    = (byte)(((input >> 1) & 0x3) + 1);
                op       = (Comparison)((config[1] >> 3) & 0x7);
                mode     = (ComparisonOutput)((config[1] >> 6) & 0x3);

                references = new byte[config.Length - 2];
                Array.Copy(config, 2, references, 0, references.Length);
            }
Пример #5
0
        private static void MergeMessages(ComparisonOutput comp,
                                          DataTable result)
        {
            result.Merge(comp.Missings);
            result.Merge(comp.Additionals);
            result.Merge(comp.Modifies);

            for (var i = 0; i < result.Rows.Count; ++i)
            {
                result.Rows[i][TableIndexes.Order] = i + 1;
            }
        }
        public IRouteComponent Filter(Comparison op, ComparisonOutput output, params string[] names)
        {
            RouteComponent next = Filter(op, output, 0) as RouteComponent;

            if (next != null)
            {
                foreach (string it in names)
                {
                    byte dest = (byte)(state.bridge.getFirmware().CompareTo(MULTI_COMPARISON_MIN_FIRMWARE) < 0 ? 5 : 3);
                    state.feedback.Add(Tuple.Create(it, next.source, dest, state.dataProcessors.Last.Value.Item2.config));
                }
            }

            return(next);
        }
        public IRouteComponent Filter(Comparison op, ComparisonOutput output, params float[] references)
        {
            if (source.attributes.length() > 4)
            {
                throw new IllegalRouteOperationException("Cannot compare data longer than 4 bytes");
            }

            if (source.attributes.length() <= 0)
            {
                throw new IllegalRouteOperationException("Cannot compare null data");
            }

            if (source.eventConfig[0] == (byte)SENSOR_FUSION)
            {
                throw new IllegalRouteOperationException("Cannot compare sensor sensor fusion data");
            }

            if (state.bridge.getFirmware().CompareTo(MULTI_COMPARISON_MIN_FIRMWARE) < 0)
            {
                float scaledReference      = references[0] * source.scale(state.bridge);
                DataProcessorConfig config = new DataProcessorConfig.SingleValueComparisonConfig(source.attributes.signed, op, (int)scaledReference);
                var next = source.transform(config);

                return(postCreate(next.Item2, new SingleValueComparatorEditor(config, next.Item1, state.bridge)));
            }

            bool anySigned = false;

            foreach (float it in references)
            {
                anySigned |= it < 0;
            }
            bool signed = source.attributes.signed || anySigned;

            {
                DataProcessorConfig config = new DataProcessorConfig.MultiValueComparisonConfig(signed, source.attributes.length(), op, output,
                                                                                                MultiValueComparatorEditor.fillReferences(source.scale(state.bridge), source, references));
                var next = source.transform(config);

                return(postCreate(next.Item2, new MultiValueComparatorEditor(config, next.Item1, state.bridge)));
            }
        }
        public IRouteComponent Filter(Comparison op, ComparisonOutput output, params float[] references)
        {
            if (source.attributes.length() > 4)
            {
                throw new IllegalRouteOperationException("Cannot compare data longer than 4 bytes");
            }

            if (source.attributes.length() <= 0)
            {
                throw new IllegalRouteOperationException("Cannot compare null data");
            }

            if (source.eventConfig[0] == (byte)SENSOR_FUSION)
            {
                throw new IllegalRouteOperationException("Cannot compare sensor sensor fusion data");
            }

            if (state.bridge.getFirmware().CompareTo(MULTI_COMPARISON_MIN_FIRMWARE) < 0)
            {
                float scaledReference = references[0] * source.scale(state.bridge);

                byte[] config = new byte[8];
                config[0] = 0x6;
                config[1] = (byte)(source.attributes.signed || references[0] < 0 ? 1 : 0);
                config[2] = (byte)op;
                config[3] = 0;
                Array.Copy(Util.intToBytesLe((int)(scaledReference)), 0, config, 4, 4);

                return(postCreate(null, new SingleValueComparatorEditor(config, source.dataProcessorCopy(source, source.attributes.dataProcessorCopy()), state.bridge)));
            }

            bool anySigned = false;

            foreach (float it in references)
            {
                anySigned |= it < 0;
            }
            bool signed = source.attributes.signed || anySigned;

            DataTypeBase processor;

            if (output == ComparisonOutput.PassFail || output == ComparisonOutput.Zone)
            {
                DataAttributes newAttrs = new DataAttributes(new byte[] { 1 }, 1, 0, false);
                processor = new IntegralDataType(source, DATA_PROCESSOR, DataProcessor.NOTIFY, newAttrs);
            }
            else
            {
                processor = source.dataProcessorCopy(source, source.attributes.dataProcessorCopy());
            }

            {
                //scope conflict with 'config' variable name
                byte[] config = new byte[2 + references.Length * source.attributes.length()];
                config[0] = 0x6;
                config[1] = (byte)((signed ? 1 : 0) | ((source.attributes.length() - 1) << 1) | ((int)op << 3) | ((int)output << 6));

                byte[] referenceValues = MultiValueComparatorEditor.fillReferences(source.scale(state.bridge), source, references);
                Array.Copy(referenceValues, 0, config, 2, referenceValues.Length);

                return(postCreate(null, new MultiValueComparatorEditor(config, processor, state.bridge)));
            }
        }