Exemplo n.º 1
0
        public static TmServerFeatures GetTmServerFeatures(int tmCid)
        {
            var capabilitiesBuf = new byte[16];

            if (Native.TmcGetServerCaps(tmCid, ref capabilitiesBuf) == 0)
            {
                return(TmServerFeatures.Empty);
            }

            return(new TmServerFeatures(IsCapabilityEnabled(capabilitiesBuf, TmNativeDefs.ServerCap.Comtrade),
                                        IsCapabilityEnabled(capabilitiesBuf, TmNativeDefs.ServerCap.MicroSeries),
                                        IsImpulseArchiveEnabled(),
                                        AreTechObjectsEnabled()));

            bool IsCapabilityEnabled(byte[] capabilities, TmNativeDefs.ServerCap capability)
            {
                var capabilityByte = (byte)capability;

                return(((capabilities[capabilityByte / 8] >> (capabilityByte % 8)) & 1) > 0);
            }

            bool IsImpulseArchiveEnabled()
            {
                var stats = new TmNativeDefs.TM_AAN_STATS();

                return(Native.TmcAanGetStats(tmCid, ref stats, 0));
            }

            bool AreTechObjectsEnabled()
            {
                return(true);

                var tobPtr = Native.TmcTechObjEnumValues(tmCid, uint.MaxValue, uint.MaxValue, IntPtr.Zero, out var count);

                if (tobPtr == IntPtr.Zero)
                {
                    return(false);
                }
                Native.TmcFreeMemory(tobPtr);
                return(count > 0);
            }
        }
 public static extern Boolean tmcAanGetStats(Int32 cid,
                                             ref TmNativeDefs.TM_AAN_STATS stats,
                                             UInt32 cbStats);
Exemplo n.º 3
0
 public Boolean TmcAanGetStats(Int32 cid,
                               ref TmNativeDefs.TM_AAN_STATS stats,
                               UInt32 cbStats)
 {
     return(tmcAanGetStats(cid, ref stats, cbStats));
 }