Example #1
0
        internal void Initialize()
        {
            // 個々のInitialize
            RawTriggers.ForEach(f => f.Initialize());
            RawTargets.ForEach(f => f.ForEach(cf => cf.Initialize()));

            // Trigger は単純に全ての 稼働条件を、Constantの是非で集約して、IsExecutable()で利用出来るようにするだけ。
            var bitOptimized = RawTriggers
                               .Where(w => w.IsEnable && (w.AccessSize == AccessSize.BIT) && (w.ConstantValue == null))
                               .GroupBy(g => new { readOffset = g.ReadOffset, accessSize = g.AccessSize, triggerValue = g.TriggerValue, triggerType = g.TriggerType })
                               .Select(s => new PlcMemoryInfoTrigger(s.Key.triggerValue, s.Key.triggerType, "optimizedBit", "optimizedBit", s.First().MemoryType, s.Key.readOffset, s.Key.accessSize, s.Select(v => v.BitPlace).Aggregate(BitPlace.NOBIT, (x, y) => x | y), true));
            var byteOptimized = RawTriggers
                                .Where(w => w.IsEnable && (w.AccessSize != AccessSize.BIT) && (w.ConstantValue == null));

            OptimizedTriggers = bitOptimized.Union(byteOptimized);

            // constant をここで事前処理 with IsExecutableWithoutTrigger
            IsExecutableAsConstants = RawTriggers
                                      .Where(w => w.IsEnable && (w.AccessSize == AccessSize.BIT) && (w.ConstantValue != null))
                                      .Select(s => new PlcMemoryValue(s, s.ConstantValue))
                                      .Aggregate(IsExecutableWithoutTrigger, (x, y) => x | ((bool)y.Value));

            OptimizedTargets = RawTargets.Select(ps => ps.Where(w => w.IsEnable));

            CachedTargets = new PlcMemoryCaches(OptimizedTargets.SelectMany(sm => sm));
        }
Example #2
0
        internal void Initialize(string lineName)
        {
            // 個々のInitialize
            InfoGroups.ForEach(f => f.Initialize());
            CachesBySettings = new PlcMemoryCaches(InfoGroups.Select(s => s.OptimizedTriggers).SelectMany(sm => sm));
            InfoGroups.ForEach(f => f.PostInitialize(CachesBySettings));

            // 速度向上用
            if (AsUpdateSQL)
            {
                //SqlCommand = DbConsumer.GetSqlCommandAsUpdateOrInsert(TableName, lineName, InsertTargets);
                SqlCommand = DbConsumer.GetSqlCommandAsUpdate(TableName, lineName, InsertTargets);  // MergeだとLockの可能性があるのでUpdateOnlyとした
            }
            else
            {
                SqlCommand = DbConsumer.GetSqlCommandAsInsert(TableName, lineName, InsertTargets);
            }
        }
Example #3
0
 internal void PostInitialize(PlcMemoryCaches cachesBySettings)
 {
     CachedTriggers = cachesBySettings;
 }