Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="d"></param>
        /// <returns></returns>
        private static string GetExtend(LYR001Device d)
        {
            StringStringDictionary ssDict = new StringStringDictionary();

            ssDict["HtmMode"] = d.HtmMode.ModeValue.ToString();

            string extend = StringStringDictionaryConverter.ToString(ssDict);

            return(extend);
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        private bool HasPowerAlaramInStatus(LYR001Device LYR001)
        {
            bool b = LYR001.StatusAndAlarmDictionary.ContainsKey(LYR001Device.StatusAndAlarmEnum.AlaramPower);

            if (b)
            {
                return(LYR001.StatusAndAlarmDictionary[LYR001Device.StatusAndAlarmEnum.AlaramPower]);
            }
            return(false);
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="task"></param>
        /// <param name="pr"></param>
        private void ProcessReadStatus(ITask task, IParseResult pr)
        {
            byte[]           bs         = (byte[])pr.Results["Status"];
            LYR001StatusData statusData = LYR001StatusDataParser.Parse(bs);


            LYR001Device    d     = (LYR001Device)task.Device;
            LYR001DataCache cache = d.DataCacheManager.GetDataCache();

            cache.StatusData = statusData;

            ProcessDataCache(d, cache);
        }
Esempio n. 4
0
        private void ProcessDataCache(LYR001Device d, LYR001DataCache dataCache)
        {
            if (dataCache.IsComplete())
            {
                GRData grdata = dataCache.ToGRData();
                d.DeviceDataManager.Last = grdata;

                // save
                //
                int id = GuidHelper.ConvertToInt32(d.Guid);
                DBI.Instance.InsertGRData(id, grdata);
            }
        }
Esempio n. 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="device"></param>
        protected override void OnAdd(IDevice device)
        {
            LYR001Device d = (LYR001Device)device;

            string s = string.Format(
                "insert into tblDevice(DeviceAddress, deviceType, stationID, DeviceExtend, DeviceName) values({0}, '{1}', {2}, '{3}', '{4}')",
                d.Address,
                d.DeviceType.Type.Name,
                GuidHelper.ConvertToInt32(d.Station.Guid),
                GetExtend(d),
                d.Name
                );

            DBI.Instance.ExecuteScalar(s);
            d.Guid = GuidHelper.Create(GetMaxDeviceID(DBI.Instance));
        }
Esempio n. 6
0
        //#region ProcessReadStatus
        ///// <summary>
        /////
        ///// </summary>
        ///// <param name="task"></param>
        ///// <param name="parseResult"></param>
        //private void ProcessReadStatus(ITask task, IParseResult pr)
        //{
        //    LYR001Device d = (LYR001Device ) task.Device;

        //    byte[] bsStatus = (byte[])pr.Results["data"];
        //    Debug.Assert(bsStatus.Length == 4);
        //    byte b = bsStatus[3];
        //    bool hasPowerAlarm = (b & (byte)Math.Pow(2, 7)) > 0;
        //    d.StatusAndAlarmDictionary[LYR001Device.StatusAndAlarmEnum.AlaramPower] = hasPowerAlarm;
        //}
        //#endregion //ProcessReadStatus

        #region ProcessReadReal
        /// <summary>
        ///
        /// </summary>
        /// <param name="d"></param>
        /// <param name="parseResult"></param>
        private void ProcessReadReal(ITask task, IParseResult pr)
        {
            //GRData data = new GRData();
            LYR001AnalogData data = new LYR001AnalogData();

            //data.DT = DateTime.Now;

            data.GT1 = Convert.ToSingle(pr.Results["GT1"]);
            data.BT1 = Convert.ToSingle(pr.Results["BT1"]);
            data.GT2 = Convert.ToSingle(pr.Results["GT2"]);
            data.BT2 = Convert.ToSingle(pr.Results["BT2"]);
            data.OT  = Convert.ToSingle(pr.Results["OT"]);
            //data.GTBase2 = Convert.ToSingle(pr.Results["GTBase2"]);
            data.GP1 = Convert.ToSingle(pr.Results["GP1"]);
            data.BP1 = Convert.ToSingle(pr.Results["BP1"]);
            data.WL  = Convert.ToSingle(pr.Results["WL"]);
            data.GP2 = Convert.ToSingle(pr.Results["GP2"]);
            data.BP2 = Convert.ToSingle(pr.Results["BP2"]);
            data.I1  = Convert.ToSingle(pr.Results["I1"]);
            data.IR  = Convert.ToSingle(pr.Results["IR"]);
            //data.I2 = Convert.ToSingle(pr.Results["I2"]);
            //data.S2 = Convert.ToInt32(pr.Results["S2"]);
            data.S1 = Convert.ToInt32(pr.Results["S1"]);
            data.SR = Convert.ToInt32(pr.Results["SR"]);
            data.OD = Convert.ToInt32(pr.Results["OD"]);
            //data.IH1 = Convert.ToDouble (parseResult.Results ["IH1"]);
            //data.SH1 = Convert.ToDouble (parseResult.Results ["SH1"]);
            //data.IH1 = 0d;
            //data.SH1 = 0d;


            LYR001Device    d         = (LYR001Device)task.Device;
            LYR001DataCache dataCache = d.DataCacheManager.GetDataCache();

            dataCache.AnalogData = data;
            // TODO: process lyr001 data cache
            //
            //d.DeviceDataManager.Last = data;


            //// save
            ////
            //int id = GuidHelper.ConvertToInt32(d.Guid);
            //DBI.Instance.InsertGRData(id, data);

            ProcessDataCache(d, dataCache);
        }
Esempio n. 7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="deviceSource"></param>
        /// <returns></returns>
        public override IDevice OnCreate(IDeviceSource deviceSource)
        {
            LYR001DeviceSource source = (LYR001DeviceSource)deviceSource;
            LYR001Device       d      = new LYR001Device();

            d.Address      = source.Address;
            d.Name         = source.DeviceName;
            d.DeviceSource = source;
            d.DeviceType   = this.Dpu.DeviceType;
            d.Dpu          = this.Dpu;
            d.Guid         = source.Guid;
            d.StationGuid  = source.StationGuid;
            d.HtmMode      = HeatTransferMode.Parse(source.HtmModeValue);
            d.Pickers      = Dpu.OperaFactory.CreatePickers(this.Dpu.DeviceType.Type.Name);

            //d.DeviceDataManager.Last = new LYR001Data();
            return(d);
        }
Esempio n. 8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void _mnuTemperatureLine_Click(object sender, EventArgs e)
        {
            LYR001Device d = SoftManager.GetSoft().SelectedHardwareItem as LYR001Device;

            if (d != null)
            {
                string stationName = d.Station.Name;

                int             deviceID           = GuidHelper.ConvertToInt32(d.Guid);
                LocalController c                  = new LocalController();
                frmXD100ModbusTemperatureControl f =
                    new frmXD100ModbusTemperatureControl(stationName, deviceID, c);
                f.ShowDialog();
            }
            else
            {
                NUnit.UiKit.UserMessage.Display("selecte LYR001 device first");
            }
        }
Esempio n. 9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void parentMenuItem_DropDownOpening(object sender, EventArgs e)
        {
            LYR001Device d = SoftManager.GetSoft().SelectedHardwareItem as LYR001Device;

            this._mnuTemperatureLine.Visible = d != null;
        }