Exemple #1
0
        private void ControlMode(ref DataTable dttPointsValue, DataTable dttPoints, byte[] bReceive, string sIP, int iPort, int iAddress, string sPointID)
        {
            EM3001.EM3001 objEM3001 = new EM3001.EM3001();
            try
            {
                byte bControlMode = bReceive[9];

                DataRow[] dtwPoint = SelectPoints(dttPoints, sIP, iPort, iAddress, sPointID);
                if (dtwPoint.Length == 0)
                {
                    g_oLogger.Trace(string.Format("請確認點位資料- {0}:{1}:{2}", sIP, iPort, iAddress));
                    return;
                }
                foreach (DataRow dtwData in dtwPoint)
                {
                    DataRow dtwPointsValue = null;
                    switch (bControlMode)
                    {

                        case 1:
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = "ManualOpen";
                            break;
                        case 2:
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = "ManualStop";
                            break;
                        case 4:
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = "Automatic";
                            break;
                        default:
                            break;
                    }
                    dtwPointsValue["RecTime"] = DateTime.Now;
                    dttPointsValue.Rows.Add(dtwPointsValue);
                }
            }
            catch (Exception ex)
            {
                g_oLogger.ErrorException("ModbusTCP.ControlMode", ex);
                throw ex;
            }
        }
Exemple #2
0
        private void Catalog2_1(ref DataTable dttPointsValue, DataTable dttPoints, byte[] bReceive, string sIP, int iPort, int iAddress, string sPointID)
        {
            EM3001.EM3001 objEM3001 = new EM3001.EM3001();
            try
            {
                string sTemperatureControlMode = objEM3001.TemperatureControlMode(bReceive[9]);
                float fHHTempereture = BitConverter.ToSingle(bReceive, 13);
                float fHTempereture = BitConverter.ToSingle(bReceive, 17);
                float fLTempereture = BitConverter.ToSingle(bReceive, 21);
                float fLLTempereture = BitConverter.ToSingle(bReceive, 25);
                float fDiffTempereture = BitConverter.ToSingle(bReceive, 29);
                float fInsideOffsetTempereture = BitConverter.ToSingle(bReceive, 33);
                float fOutsideOffsetTempereture = BitConverter.ToSingle(bReceive, 37);
                byte bCoworkerModeDay = bReceive[41];
                byte bAirConditionerModeDay = bReceive[42];
                byte bAirFanerMinTime = bReceive[43];
                byte bAirConditionerMinTime = bReceive[44];
                string sAirConditionerSwapDuty = objEM3001.AirConditionerSwapDuty(bReceive[45]);
                DateTime dtSystem = new DateTime(2000 + bReceive[47], bReceive[48], bReceive[49]
                    , bReceive[50], bReceive[51], bReceive[52]);
                float fHighVoltage = BitConverter.ToSingle(bReceive, 53);
                float fLowVoltage = BitConverter.ToSingle(bReceive, 57);
                float fStopVoltage = BitConverter.ToSingle(bReceive, 61);

                DataRow[] dtwPoint = SelectPoints(dttPoints, sIP, iPort, iAddress, sPointID);
                if (dtwPoint.Length == 0)
                {
                    g_oLogger.Trace(string.Format("請確認點位資料- {0}:{1}:{2}", sIP, iPort, iAddress));
                    return;
                }
                foreach (DataRow dtwData in dtwPoint)
                {
                    DataRow dtwPointsValue = null;
                    switch (dtwData["PointID"].ToString().Split('.')[dtwData["PointID"].ToString().Split('.').Length-1].ToLower())
                    {

                        case "temperaturecontrolmode":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = sTemperatureControlMode;
                            break;
                        case "hhtempereture":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = fHHTempereture.ToString("0.00");
                            break;
                        case "htempereture":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = fHTempereture.ToString("0.00");
                            break;
                        case "ltempereture":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = fLTempereture.ToString("0.00");
                            break;
                        case "lltempereture":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = fLLTempereture.ToString("0.00");
                            break;
                        case "difftempereture":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = fDiffTempereture.ToString("0.00");
                            break;
                        case "insideoffsettempereture":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = fInsideOffsetTempereture.ToString("0.00");
                            break;
                        case "outsideoffsettempereture":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = fOutsideOffsetTempereture.ToString("0.00");
                            break;
                        case "coworkermodeday":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = bCoworkerModeDay;
                            break;
                        case "airconditionermodeday":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = bAirConditionerModeDay;
                            break;
                        case "airfanermintime":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = bAirFanerMinTime;
                            break;
                        case "airconditionermintime":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = bAirConditionerMinTime;
                            break;
                        case "airconditionerswapduty":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = sAirConditionerSwapDuty;
                            break;
                        case "systemtime":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = dtSystem.ToString("yyyy-MM-dd HH:mm:ss.fff");
                            break;
                        case "highvoltage":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = fHighVoltage.ToString("0.00"); ;
                            break;
                        case "lowvoltage":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = fLowVoltage.ToString("0.00"); ;
                            break;
                        case "stopvoltage":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = fStopVoltage.ToString("0.00"); ;
                            break;
                        default:
                            g_oLogger.Error("請確認PointID之內容、格式是否正確");
                            break;
                    }
                    dtwPointsValue["RecTime"] = DateTime.Now;
                    dttPointsValue.Rows.Add(dtwPointsValue);
                }
            }
            catch (Exception ex)
            {
                g_oLogger.ErrorException("ModbusTCP.Catalog2_1", ex);
                throw ex;
            }
        }
Exemple #3
0
        private void Catalog2_2(ref DataTable dttPointsValue, DataTable dttPoints, byte[] bReceive, string sIP, int iPort, int iAddress, string sPointID)
        {
            EM3001.EM3001 objEM3001 = new EM3001.EM3001();
            try
            {
                byte bContinousNoTurnOnDay = bReceive[9];
                byte bForceTurnOnTime = bReceive[10];

                DataRow[] dtwPoint = SelectPoints(dttPoints, sIP, iPort, iAddress, sPointID);
                if (dtwPoint.Length == 0)
                {
                    g_oLogger.Trace(string.Format("請確認點位資料- {0}:{1}:{2}", sIP, iPort, iAddress));
                    return;
                }
                foreach (DataRow dtwData in dtwPoint)
                {
                    DataRow dtwPointsValue = null;
                    switch (dtwData["PointID"].ToString().Split('.')[dtwData["PointID"].ToString().Split('.').Length-1].ToLower())
                    {
                        case "continousnoturnonday":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = bContinousNoTurnOnDay;
                            break;
                        case "forceturnontime":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = bForceTurnOnTime;
                            break;
                        default:
                            g_oLogger.Error("請確認PointID之內容、格式是否正確");
                            break;
                    }
                    dtwPointsValue["RecTime"] = DateTime.Now;
                    dttPointsValue.Rows.Add(dtwPointsValue);
                }
            }
            catch (Exception ex)
            {
                g_oLogger.ErrorException("ModbusTCP.Catalog2_2", ex);
                throw ex;
            }
        }
Exemple #4
0
        private void Catalog1(ref DataTable dttPointsValue, DataTable dttPoints, byte[] bReceive, string sIP, int iPort, int iAddress, string sPointID)
        {
            EM3001.EM3001 objEM3001 = new EM3001.EM3001();
            try
            {
                float fInsideTemperature = BitConverter.ToSingle(bReceive, 9);
                float fOutsideTemperature = BitConverter.ToSingle(bReceive, 13);
                float fInsideWet = BitConverter.ToSingle(bReceive, 17);
                float fOutsideWet = BitConverter.ToSingle(bReceive, 21);
                float fAirAmpere = BitConverter.ToSingle(bReceive, 25);
                float fVoltage48 = BitConverter.ToSingle(bReceive, 29);
                string sFireAlarm = objEM3001.ConvertToBinary(bReceive[33])[3];
                string sHeatExchangerAlarm = objEM3001.ConvertToBinary(bReceive[33])[2];
                string sAirAlarm = objEM3001.ConvertToBinary(bReceive[33])[1];
                string sStifledAlarm = objEM3001.ConvertToBinary(bReceive[33])[0];
                string sFanSwitch = objEM3001.ConvertToBinary(bReceive[37])[3];
                string sAlarmSwitch = objEM3001.ConvertToBinary(bReceive[37])[2];
                string sAirASwitch = objEM3001.ConvertToBinary(bReceive[37])[1];
                string sAirBSwitch = objEM3001.ConvertToBinary(bReceive[37])[0];
                string sAO = objEM3001.AnalogOutput(bReceive[41]);
                byte bControlMode = bReceive[45];
                UInt32 uiSystemWorkingHour = BitConverter.ToUInt32(bReceive, 49);
                UInt32 uiAirFanerWorkingHour = BitConverter.ToUInt32(bReceive, 53);
                UInt32 uiAirConditionerAWorkingHour = BitConverter.ToUInt32(bReceive, 57);
                UInt32 uiAirConditionerBWorkingHour = BitConverter.ToUInt32(bReceive, 61);

                DataRow[] dtwPoint = SelectPoints(dttPoints, sIP, iPort, iAddress, sPointID);
                if (dtwPoint.Length == 0)
                {
                    g_oLogger.Trace(string.Format("請確認點位資料- {0}:{1}:{2}", sIP, iPort, iAddress));
                    return;
                }
                foreach (DataRow dtwData in dtwPoint)
                {
                    DataRow dtwPointsValue = null;
                    switch (dtwData["PointID"].ToString().Split('.')[dtwData["PointID"].ToString().Split('.').Length -1].ToLower())
                    {

                        case "insidetemperature":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = fInsideTemperature.ToString("0.00");
                            break;
                        case "outsidetemperature":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = fOutsideTemperature.ToString("0.00");
                            break;
                        case "insidewet":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = fInsideWet.ToString("0.00");
                            break;
                        case "outsidewet":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = fOutsideWet.ToString("0.00");
                            break;
                        case "airampere":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = fAirAmpere.ToString("0.00");
                            break;
                        case "voltage48":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = fVoltage48.ToString("0.00");
                            break;
                        case "firealarm":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = sFireAlarm;
                            break;
                        case "heatexchangeralarm":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = sHeatExchangerAlarm;
                            break;
                        case "airalarm":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = sAirAlarm;
                            break;
                        case "stifledalarm":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = sStifledAlarm;
                            break;
                        case "fanswitch":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = sFanSwitch;
                            break;
                        case "alarmswitch":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = sAlarmSwitch;
                            break;
                        case "airaswitch":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = sAirASwitch;
                            break;
                        case "airbswitch":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = sAirBSwitch;
                            break;
                        case "analogoutput":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = sAO;
                            break;
                        case "controlmode":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = objEM3001.ControlMode(bControlMode);
                            break;
                        case "systemworkinghour":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = uiSystemWorkingHour;
                            break;
                        case "airfanerworkinghour":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = uiAirFanerWorkingHour;
                            break;
                        case "airconditioneraworkinghour":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = uiAirConditionerAWorkingHour;
                            break;
                        case "airconditionerbworkinghour":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = uiAirConditionerBWorkingHour;
                            break;
                        default:
                            g_oLogger.Error("請確認PointID之內容、格式是否正確");
                            break;
                    }
                    dtwPointsValue["RecTime"] = DateTime.Now;
                    dttPointsValue.Rows.Add(dtwPointsValue);
                }
            }
            catch (Exception ex)
            {
                g_oLogger.ErrorException("ModbusTCP.Catalog1", ex);
                throw ex;
            }
        }
Exemple #5
0
        private void CabinTempSetting(ref DataTable dttPointsValue, DataTable dttPoints, byte[] bReceive, string sIP, int iPort, int iAddress, string sPointID)
        {
            EM3001.EM3001 objEM3001 = new EM3001.EM3001();
            try
            {
                float fHHTempereture = BitConverter.ToSingle(bReceive, 9);
                float fHTempereture = BitConverter.ToSingle(bReceive, 13);
                float fLTempereture = BitConverter.ToSingle(bReceive, 17);
                float fLLTempereture = BitConverter.ToSingle(bReceive, 20);
                float fDiffTempereture = BitConverter.ToSingle(bReceive, 24);
                float fInsideOffsetTempereture = BitConverter.ToSingle(bReceive, 28);

                DataRow[] dtwPoint = SelectPoints(dttPoints, sIP, iPort, iAddress, sPointID);
                if (dtwPoint.Length == 0)
                {
                    g_oLogger.Trace(string.Format("請確認點位資料- {0}:{1}:{2}", sIP, iPort, iAddress));
                    return;
                }
                foreach (DataRow dtwData in dtwPoint)
                {
                    DataRow dtwPointsValue = null;
                    switch (dtwData["PointID"].ToString().Split('.')[2].ToLower())
                    {

                        case "hhtempereture":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = fHHTempereture.ToString("0.00");
                            break;
                        case "htempereture":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = fHTempereture.ToString("0.00");
                            break;
                        case "ltempereture":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = fLTempereture.ToString("0.00");
                            break;
                        case "lltempereture":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = fLLTempereture.ToString("0.00");
                            break;
                        case "difftempereture":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = fDiffTempereture.ToString("0.00");
                            break;
                        case "offsettempereture":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = fInsideOffsetTempereture.ToString("0.00");
                            break;
                        default:
                            g_oLogger.Error("請確認PointID之內容、格式是否正確");
                            break;
                    }
                    dtwPointsValue["RecTime"] = DateTime.Now;
                    dttPointsValue.Rows.Add(dtwPointsValue);
                }
            }
            catch (Exception ex)
            {
                g_oLogger.ErrorException("ModbusTCP.CabinTempSetting", ex);
                throw ex;
            }
        }
Exemple #6
0
        private void WorkingHours(ref DataTable dttPointsValue, DataTable dttPoints, byte[] bReceive, string sIP, int iPort, int iAddress, string sPointID)
        {
            EM3001.EM3001 objEM3001 = new EM3001.EM3001();
            try
            {
                UInt32 uiSystemWorkingHour = BitConverter.ToUInt32(bReceive, 9);
                UInt32 uiAirFanerWorkingHour = BitConverter.ToUInt32(bReceive, 13);
                UInt32 uiAirConditionerAWorkingHour = BitConverter.ToUInt32(bReceive, 17);
                UInt32 uiAirConditionerBWorkingHour = BitConverter.ToUInt32(bReceive, 20);

                DataRow[] dtwPoint = SelectPoints(dttPoints, sIP, iPort, iAddress, sPointID);
                if (dtwPoint.Length == 0)
                {
                    g_oLogger.Trace(string.Format("請確認點位資料- {0}:{1}:{2}", sIP, iPort, iAddress));
                    return;
                }
                foreach (DataRow dtwData in dtwPoint)
                {
                    DataRow dtwPointsValue = null;
                    switch (dtwData["PointID"].ToString().Split('.')[2].ToLower())
                    {

                        case "systemworkinghour":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = uiSystemWorkingHour;
                            break;
                        case "airfanerworkinghour":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = uiAirFanerWorkingHour;
                            break;
                        case "airconditioneraworkinghour":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = uiAirConditionerAWorkingHour;
                            break;
                        case "airconditionerbworkinghour":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = uiAirConditionerBWorkingHour;
                            break;
                        default:
                            g_oLogger.Error("請確認PointID之內容、格式是否正確");
                            break;
                    }
                    dtwPointsValue["RecTime"] = DateTime.Now;
                    dttPointsValue.Rows.Add(dtwPointsValue);
                }
            }
            catch (Exception ex)
            {
                g_oLogger.ErrorException("ModbusTCP.WorkingHours", ex);
                throw ex;
            }
        }
Exemple #7
0
        private void SystemTime(ref DataTable dttPointsValue, DataTable dttPoints, byte[] bReceive, string sIP, int iPort, int iAddress, string sPointID)
        {
            EM3001.EM3001 objEM3001 = new EM3001.EM3001();
            try
            {
                DateTime dtSystem = new DateTime(2000 + bReceive[9], bReceive[10], bReceive[11]
                    , bReceive[12], bReceive[13], bReceive[14]);

                DataRow[] dtwPoint = SelectPoints(dttPoints, sIP, iPort, iAddress, sPointID);
                if (dtwPoint.Length == 0)
                {
                    g_oLogger.Trace(string.Format("請確認點位資料- {0}:{1}:{2}", sIP, iPort, iAddress));
                    return;
                }
                foreach (DataRow dtwData in dtwPoint)
                {
                    DataRow dtwPointsValue = null;
                    switch (dtwData["PointID"].ToString().Split('.')[2].ToLower())
                    {

                        case "systemtime":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = dtSystem.ToString("yyyy-MM-dd HH:mm:ss.fff");
                            break;
                        default:
                            g_oLogger.Error("請確認PointID之內容、格式是否正確");
                            break;
                    }
                    dtwPointsValue["RecTime"] = DateTime.Now;
                    dttPointsValue.Rows.Add(dtwPointsValue);
                }
            }
            catch (Exception ex)
            {
                g_oLogger.ErrorException("ModbusTCP.SystemTime", ex);
                throw ex;
            }
        }
Exemple #8
0
        private void StatusLog(ref DataTable dttPointsValue, DataTable dttPoints, byte[] bReceive, string sIP, int iPort, int iAddress, string sPointID)
        {
            EM3001.EM3001 objEM3001 = new EM3001.EM3001();
            try
            {
                byte bEventType = bReceive[9];
                DateTime dtRecTime = new DateTime(2000 + bReceive[11], bReceive[12], bReceive[13], bReceive[14], bReceive[15], bReceive[16]);
                int iOutsideTemperature = BitConverter.ToInt16(bReceive, 17) / 10;
                int iInsideTemperature = BitConverter.ToInt16(bReceive, 19) / 10;
                int iVoltage48 = BitConverter.ToInt16(bReceive, 27) / 10;
                string sFireAlarm = objEM3001.ConvertToBinary(bReceive[29])[3];
                string sHeatExchangerAlarm = objEM3001.ConvertToBinary(bReceive[29])[2];
                string sAirAlarm = objEM3001.ConvertToBinary(bReceive[29])[1];
                string sStifledAlarm = objEM3001.ConvertToBinary(bReceive[29])[0];
                string sFanSwitch = objEM3001.ConvertToBinary(bReceive[30])[3];
                string sAlarmSwitch = objEM3001.ConvertToBinary(bReceive[30])[2];
                string sAirASwitch = objEM3001.ConvertToBinary(bReceive[30])[1];
                string sAirBSwitch = objEM3001.ConvertToBinary(bReceive[30])[0];
                //string sAO = objEM3001.AnalogOutput(bReceive[31]);
                string sTemperatureControlMode = objEM3001.TemperatureControlMode(bReceive[32]);
                string sTemperatureControlDays = objEM3001.AssociateDays(bReceive[33]);
                string sAirAssociateDays = objEM3001.AirAssociateDays(bReceive[34]);
                string sSDState = objEM3001.SDState(bReceive[35]);

                DataRow[] dtwPoint = SelectPoints(dttPoints, sIP, iPort, iAddress, sPointID);
                if (dtwPoint.Length == 0)
                {
                    g_oLogger.Trace(string.Format("請確認點位資料- {0}:{1}", sIP, iPort));
                    return;
                }
                foreach (DataRow dtwData in dtwPoint)
                {
                    DataRow dtwPointsValue = null;
                    switch (dtwData["PointID"].ToString().Split('.')[dtwData["PointID"].ToString().Split('.').Length - 1].ToLower())
                    {
                        case "eventtype":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = objEM3001.EventType(bEventType);
                            break;
                        case "outsidetemperature":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = iOutsideTemperature.ToString("0.00");
                            break;
                        case "insidetemperature":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = iInsideTemperature.ToString("0.00");
                            break;
                        case "voltage48":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = iVoltage48.ToString("0.00");
                            break;
                        case "firealarm":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = sFireAlarm;
                            break;
                        case "heatexchangeralarm":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = sHeatExchangerAlarm;
                            break;
                        case "airalarm":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = sAirAlarm;
                            break;
                        case "stifledalarm":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = sStifledAlarm;
                            break;
                        case "fanswitch":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = sFanSwitch;
                            break;
                        case "alarmswitch":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = sAlarmSwitch;
                            break;
                        case "airaswitch":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = sAirASwitch;
                            break;
                        case "airbswitch":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = sAirBSwitch;
                            break;
                        case "temperaturecontrolmode":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = sTemperatureControlMode;
                            break;
                        case "temperaturecontroldays":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = sTemperatureControlDays;
                            break;
                        case "airassociatedays":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = sAirAssociateDays;
                            break;
                        case "sdstate":
                            dtwPointsValue = dttPointsValue.NewRow();
                            dtwPointsValue["EquipmentID"] = dtwData["EquipmentID"].ToString();
                            dtwPointsValue["PointID"] = dtwData["PointID"].ToString();
                            dtwPointsValue["PointValue"] = sSDState;
                            break;
                        default:
                            break;
                    }
                    dtwPointsValue["RecTime"] = dtRecTime;
                    dttPointsValue.Rows.Add(dtwPointsValue);
                }
            }
            catch (Exception ex)
            {
                g_oLogger.ErrorException("ModbusTCP.StatusLog", ex);
                throw ex;
            }
        }