public static void UpdateOperatinHistoryMacroLocation(string ipAddress, ushort portNo, short macroLocation, int value)
        {
            short  ret            = -20;
            ushort focasLibHandle = 0;

            ret = FocasLib.cnc_allclibhndl3(ipAddress, portNo, 10, out focasLibHandle);
            if (ret != 0)
            {
                Logger.WriteErrorLog("cnc_allclibhndl3() failed. return value is = " + ret);
                return;
            }
            FocasData.WriteMacro(focasLibHandle, macroLocation, value);
            FocasLib.cnc_freelibhndl(focasLibHandle);
        }
        public static int ReadOperatinHistoryDPrintLocation(string ipAddress, ushort portNo, short macroLocation)
        {
            short  ret            = -20;
            ushort focasLibHandle = 0;
            int    dprintValue    = 0;

            ret = FocasLib.cnc_allclibhndl3(ipAddress, portNo, 10, out focasLibHandle);
            if (ret != 0)
            {
                Logger.WriteErrorLog("cnc_allclibhndl3() failed. return value is = " + ret);
                return(dprintValue);
            }
            dprintValue = FocasData.ReadMacro(focasLibHandle, macroLocation);
            FocasLib.cnc_freelibhndl(focasLibHandle);
            return(dprintValue);
        }
Пример #3
0
 private static void get_actual_axis_value(FocasLibBase.ODBAXDT odbaxdt, ref List <string> pos, short len, int types)
 {
     pos.Add(FocasData.get_ax_val2(odbaxdt.data1.data, odbaxdt.data1.dec).ToString());
     pos.Add(FocasData.get_ax_val2(odbaxdt.data2.data, odbaxdt.data2.dec).ToString());
     pos.Add(FocasData.get_ax_val2(odbaxdt.data3.data, odbaxdt.data3.dec).ToString());
     pos.Add(FocasData.get_ax_val2(odbaxdt.data4.data, odbaxdt.data4.dec).ToString());
     pos.Add(FocasData.get_ax_val2(odbaxdt.data5.data, odbaxdt.data5.dec).ToString());
     pos.Add(FocasData.get_ax_val2(odbaxdt.data6.data, odbaxdt.data6.dec).ToString());
     pos.Add(FocasData.get_ax_val2(odbaxdt.data7.data, odbaxdt.data7.dec).ToString());
     pos.Add(FocasData.get_ax_val2(odbaxdt.data8.data, odbaxdt.data8.dec).ToString());
     pos.Add(FocasData.get_ax_val2(odbaxdt.data9.data, odbaxdt.data9.dec).ToString());
     pos.Add(FocasData.get_ax_val2(odbaxdt.data10.data, odbaxdt.data10.dec).ToString());
     pos.Add(FocasData.get_ax_val2(odbaxdt.data11.data, odbaxdt.data11.dec).ToString());
     pos.Add(FocasData.get_ax_val2(odbaxdt.data12.data, odbaxdt.data12.dec).ToString());
     if (types == 3 && len == 4)
     {
         return;
     }
     pos.Add(FocasData.get_ax_val2(odbaxdt.data13.data, odbaxdt.data13.dec).ToString());
     pos.Add(FocasData.get_ax_val2(odbaxdt.data14.data, odbaxdt.data14.dec).ToString());
     pos.Add(FocasData.get_ax_val2(odbaxdt.data15.data, odbaxdt.data15.dec).ToString());
     if (types == 3 && len == 5)
     {
         return;
     }
     pos.Add(FocasData.get_ax_val2(odbaxdt.data16.data, odbaxdt.data16.dec).ToString());
     if (types == 4 && len == 4)
     {
         return;
     }
     pos.Add(FocasData.get_ax_val2(odbaxdt.data17.data, odbaxdt.data17.dec).ToString());
     pos.Add(FocasData.get_ax_val2(odbaxdt.data18.data, odbaxdt.data18.dec).ToString());
     pos.Add(FocasData.get_ax_val2(odbaxdt.data19.data, odbaxdt.data19.dec).ToString());
     pos.Add(FocasData.get_ax_val2(odbaxdt.data20.data, odbaxdt.data20.dec).ToString());
     if (types == 4 && len == 5)
     {
         return;
     }
     pos.Add(FocasData.get_ax_val2(odbaxdt.data21.data, odbaxdt.data21.dec).ToString());
     pos.Add(FocasData.get_ax_val2(odbaxdt.data22.data, odbaxdt.data22.dec).ToString());
     pos.Add(FocasData.get_ax_val2(odbaxdt.data23.data, odbaxdt.data23.dec).ToString());
     pos.Add(FocasData.get_ax_val2(odbaxdt.data24.data, odbaxdt.data24.dec).ToString());
     pos.Add(FocasData.get_ax_val2(odbaxdt.data25.data, odbaxdt.data25.dec).ToString());
 }
        /*(9) CNC parameter error CNC parameter '3112#2' must be 1. */
        public static List <OprMessageDTO> ReadExternalOperatorMessageHistory18i(string machineID, string ipAddress, ushort portNo)
        {
            int    ret            = 0;
            ushort focasLibHandle = 0;
            List <OprMessageDTO> oprMessagesObj = new List <OprMessageDTO>();

            try
            {
                ret = FocasLib.cnc_allclibhndl3(ipAddress, portNo, 10, out focasLibHandle);
                if (ret != 0)
                {
                    Logger.WriteErrorLog("cnc_allclibhndl3() failed. return value is = " + ret);
                    return(null);
                }

                ret = FocasLib.cnc_stopomhis(focasLibHandle);
                if (ret != 0)
                {
                    Logger.WriteErrorLog("cnc_stopomhis() failed. return value is = " + ret);
                    return(null);
                }
                FocasLibBase.ODBOMIF a = new FocasLibBase.ODBOMIF();
                ret = FocasLib.cnc_rdomhisinfo(focasLibHandle, a);
                if (ret != 0)
                {
                    Logger.WriteErrorLog("cnc_rdomhisinfo() failed. return value is = " + ret);
                    return(null);
                }
                if (a.om_max == 0)
                {
                    return(oprMessagesObj);
                }
                //TODO - check it?
                int totalMessages = a.om_max;
                //10 rows at a time
                ushort loop_count = (ushort)(totalMessages / 10);
                ushort remainder = (ushort)(totalMessages % 10);
                ushort i = 0, s_no = 0, e_no = 0;
                //ushort length = 4 + 512 * 10;

                for (i = 0; i <= loop_count; i++)
                {
                    if (i == loop_count)
                    {
                        if (remainder > 0)
                        {
                            s_no = (ushort)(i * 10 + 1);
                            e_no = (ushort)(s_no + (remainder - 1));
                            FocasLibBase.ODBOMHIS obj = new FocasLibBase.ODBOMHIS();
                            ushort length             = (ushort)Marshal.SizeOf(obj);
                            ret = FocasLib.cnc_rdomhistry(focasLibHandle, s_no, ref e_no, obj);
                            if (ret != 0)
                            {
                                Logger.WriteErrorLog("cnc_rdomhistry() failed. return value is = " + ret);
                                continue;
                            }
                            AddMessagesToList(obj, oprMessagesObj);
                            try
                            {
                                oprMessagesObj.RemoveRange(totalMessages, oprMessagesObj.Count - totalMessages);
                            }
                            catch (Exception exxx)
                            {
                                Logger.WriteErrorLog(exxx.ToString());
                            }
                        }
                    }
                    else
                    {
                        s_no = (ushort)(i * 10 + 1);
                        e_no = (ushort)(s_no + 9);
                        FocasLibBase.ODBOMHIS obj = new FocasLibBase.ODBOMHIS();
                        ushort length             = (ushort)Marshal.SizeOf(obj);
                        ret = FocasLib.cnc_rdomhistry(focasLibHandle, s_no, ref e_no, obj);
                        if (ret != 0)
                        {
                            Logger.WriteErrorLog("cnc_rdomhistry() failed. return value is = " + ret);
                            continue;
                        }
                        //TODO - add the message based on s_no and e_no
                        AddMessagesToList(obj, oprMessagesObj);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.WriteErrorLog(ex.ToString());
            }
            finally
            {
                if (focasLibHandle > 0)
                {
                    ret = FocasLib.cnc_startophis(focasLibHandle);
                    FocasData.cnc_freelibhndl(focasLibHandle);
                }
            }

            return(oprMessagesObj);
        }
Пример #5
0
        public static DataTable ReadAlarmHistory(string machineID, string ipAddress, ushort portNo)
        {
            int       ret            = 0;
            ushort    focasLibHandle = 0;
            DataTable alarms         = Utility.get_table();

            try
            {
                ret = FocasLib.cnc_allclibhndl3(ipAddress, portNo, 10, out focasLibHandle);
                if (ret == 0)
                {
                    ret = FocasLib.cnc_stopophis(focasLibHandle);
                    if (ret != 0)
                    {
                        Logger.WriteErrorLog("cnc_stopophis() failed. return value is = " + ret);
                    }
                    ushort totalAlarms = 0;
                    ret = FocasLib.cnc_rdalmhisno(focasLibHandle, out totalAlarms);
                    if (ret != 0)
                    {
                        Logger.WriteErrorLog("cnc_rdalmhisno() failed. return value is = " + ret);
                    }
                    if (totalAlarms == 0)
                    {
                        return(alarms);
                    }

                    //10 rows at a time
                    DataRow row = default(DataRow);
                    FocasLibBase.ODBAHIS5             obj            = new FocasLibBase.ODBAHIS5();
                    List <FocasLibBase.ALM_HIS5_data> focasAlarmsObj = new List <FocasLibBase.ALM_HIS5_data>();//almhisdata object list

                    ushort loop_count = (ushort)(totalAlarms / 10);
                    ushort remainder = (ushort)(totalAlarms % 10);
                    ushort i = 0, s_no = 0, e_no = 0;
                    //ushort length = 4 + 512 * 10;
                    ushort length = (ushort)Marshal.SizeOf(obj);
                    for (i = 0; i <= loop_count; i++)
                    {
                        if (i == loop_count)
                        {
                            if (remainder == 0)
                            {
                                continue;
                            }
                            s_no = (ushort)(i * 10 + 1);
                            e_no = (ushort)(s_no + (remainder - 1));
                            ret  = FocasLib.cnc_rdalmhistry5(focasLibHandle, s_no, e_no, length, obj);
                            if (ret != 0)
                            {
                                Logger.WriteErrorLog("cnc_rdalmhistry5() failed. return value is = " + ret);
                            }
                            focasAlarmsObj.Clear();
                            get_ahd_objects(ref focasAlarmsObj, obj);
                            for (int j = 0; j < remainder; j++)
                            {
                                row = alarms.NewRow();
                                Utility.get_datatable_row(focasAlarmsObj[j], ref row);
                                row["MachineID"] = machineID;
                                alarms.Rows.Add(row);
                            }
                        }
                        else
                        {
                            s_no = (ushort)(i * 10 + 1);
                            e_no = (ushort)(s_no + 9);
                            ret  = FocasLib.cnc_rdalmhistry5(focasLibHandle, s_no, e_no, length, obj);
                            if (ret != 0)
                            {
                                Logger.WriteErrorLog("cnc_rdalmhistry5() failed. return value is = " + ret);
                            }
                            focasAlarmsObj.Clear();
                            get_ahd_objects(ref focasAlarmsObj, obj);//
                            for (int j = 0; j < 10; j++)
                            {
                                row = alarms.NewRow();
                                Utility.get_datatable_row(focasAlarmsObj[j], ref row);
                                row["MachineID"] = machineID;
                                alarms.Rows.Add(row);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.WriteErrorLog(ex.ToString());
            }
            finally
            {
                if (focasLibHandle > 0)
                {
                    ret = FocasLib.cnc_startophis(focasLibHandle);
                    FocasData.cnc_freelibhndl(focasLibHandle);
                }
            }

            return(alarms);
        }
Пример #6
0
        //TODO - complte it with datatable and database insert
        public static DataTable ReadOperationhistory18i(string machineID, string ipAddress, ushort portNo)
        {
            DataTable table  = new DataTable();
            ushort    handle = ushort.MinValue;
            int       ret    = 0;

            try
            {
                ret = FocasLib.cnc_allclibhndl3(ipAddress, portNo, 10, out handle);
                if (ret == 0)
                {
                    ret = FocasLib.cnc_stopophis(handle);
                    if (ret != 0)
                    {
                        Logger.WriteErrorLog("cnc_stopophis() failed. return value is = " + ret);
                    }
                    ushort totalHistoryRecords = 0;
                    ret = FocasLib.cnc_rdophisno(handle, out totalHistoryRecords);
                    if (ret != 0)
                    {
                        Logger.WriteErrorLog("cnc_rdophisno() failed. return value is = " + ret);
                    }
                    Logger.WriteDebugLog("Total number of rows found in Operation History = " + totalHistoryRecords);
                    if (totalHistoryRecords == 0)
                    {
                        return(table);
                    }
                    ushort returnRecordnumber = 0;
                    FocasLibBase.ODBHIS obj   = new FocasLibBase.ODBHIS();
                    ushort objLength          = (ushort)Marshal.SizeOf(obj);

                    int length = totalHistoryRecords;
                    returnRecordnumber = 1;
                    for (ushort i = 1; i <= length; i++)
                    {
                        returnRecordnumber = i;
                        obj = new FocasLibBase.ODBHIS();
                        ret = FocasLib.cnc_rdophistry(handle, i, returnRecordnumber, objLength, obj);

                        /*
                         * rec_type  : Record type Description
                         *  0 : MDI key history
                         *  1 : Signal history
                         *  2 : Alarm history
                         *  3 : Date history
                         *  4 : Time history
                         *  5 : MDI key history for SUB (only Series 160/180/210, Power Mate i)
                         *  6 : Signal history for SUB (only Series 160/180/210, Power Mate i)
                         *  7 : Alarm history for SUB (only Series 160/180/210, Power Mate i)
                         *  10 : MDI key history for 3rd Path (only Series 160i)
                         *  11 : Signal history for 3rd Path (only Series 160i)
                         *  12 : Alarm history for 3rd Path (only Series 160i)
                         */


                        if (obj.data.data1.rec_type == 3) //3 : Date history
                        {
                            Debug.Print("YEAR = " + Convert.ToString(obj.data.data1.date_year.ToString()));
                            Debug.Print("MONTH = " + obj.data.data1.date_month.ToString());
                            Debug.Print("DAY = " + obj.data.data1.date_day.ToString());
                        }

                        if (obj.data.data1.rec_type == 4) //4 : Time history
                        {
                            Debug.Print("hh = " + Convert.ToString(obj.data.data1.time_hour));
                            Debug.Print("MM = " + obj.data.data1.time_minute.ToString());
                            Debug.Print("SS = " + obj.data.data1.time_second.ToString());
                        }

                        if (obj.data.data1.rec_type == 1) // 1 : Signal history
                        {
                            Debug.Print("sgn_sig_name = " + Convert.ToString(obj.data.data1.sgn_sig_name));
                            Debug.Print("sgn_sig_no = " + obj.data.data1.sgn_sig_no.ToString());
                            Debug.Print("nEW = " + obj.data.data1.sgn_sig_new.ToString());
                            Debug.Print("OLD " + obj.data.data1.sgn_sig_old.ToString());
                        }
                        if (obj.data.data1.rec_type == 2) // 2 : Alarm history
                        {
                            Debug.Print("alm_alm_no = " + Convert.ToString(obj.data.data1.alm_alm_no));
                            Debug.Print("alm_alm_grp = " + obj.data.data1.alm_alm_grp);
                            Debug.Print("alm_axis_no = " + obj.data.data1.alm_axis_no);
                            Debug.Print("alm_dummy " + obj.data.data1.alm_dummy);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.WriteErrorLog(ex.ToString());
            }
            finally
            {
                if (handle != ushort.MinValue)
                {
                    FocasLib.cnc_startophis(handle);
                    FocasData.cnc_freelibhndl(handle);
                }
            }
            return(table);
        }