Example #1
0
        private void ExecuteWriteWinCCMachineTag(int nSample_ID, DataRow drActiveSample, DataRow drCommandsToExecute, string strRoutingPositionEntryLogString)
        {
            int nMachinePosition_ID = Int32.Parse(drActiveSample["ActualSamplePosition_ID"].ToString());
            string strValue = null;
            string strTagName = null;
            int nValueName_ID = -1;
            int nRouting_Commands_ID = Int32.Parse(drCommandsToExecute["idrouting_commands"].ToString());

            if (nSample_ID > 0)
            {
                strTagName = drCommandsToExecute["CommandValue2"].ToString();
                strValue = drCommandsToExecute["CommandValue3"].ToString();
                if (strValue.IndexOf('<') != -1)
                { // if something in the string to translate open a new Translater and replace the values
                    LabManager.TranslateString translater = new LabManager.TranslateString();
                    strValue = translater.TranslateValueString(strValue, nSample_ID);
                }
                nValueName_ID = myHC.GetIDFromName((int)Definition.SQLTables.MACHINE_TAGS, strTagName);
                int nType = myHC.GetWinCCTypeFromTagID((int)Definition.SQLTables.MACHINE_TAGS, nValueName_ID);
                if (nType == 1) // bit
                {
                    strValue = strValue.ToLower();
                }
                if (nType == 8 || nType == 9)  //DM_VARTYPE_FLOAT       /* Gleitkommazahl 32-Bit IEEE
                {
                    strValue = strValue.Replace(',', '.');
                }
                WriteLoggEntry((int)Definition.ThorLogWindows.ROUTING, strRoutingPositionEntryLogString + @"command:: writing WinCC machine tag `" + strTagName + "`(id:" + nValueName_ID + ")" +
                    " with value: `" + strValue + "`" +
                    " from sample:  `" + myHC.GetNameFromID((int)Definition.SQLTables.SAMPLE_ACTIVE, nSample_ID) + "`(id:" + nSample_ID + ")" +
                    " from position: `" + myHC.GetNameFromID((int)Definition.SQLTables.MACHINE_POSITIONS, nMachinePosition_ID) + "`(id:" + nMachinePosition_ID + ")");

                myRoutingData.WriteWinCCTagFromSampleValuesByValueName(strTagName, strValue, nType);
            }
        }
Example #2
0
        private void ExecuteShiftSample(int nSample_ID, DataRow drActiveSample, DataRow drCommandsToExecute, string strRoutingPositionEntryLogString)
        {
            int nMachinePosition_ID = -1;

            if (Int32.TryParse(drActiveSample["ActualSamplePosition_ID"].ToString(), out nMachinePosition_ID))
            {
                string Value = null;

                if (nSample_ID > 0)
                {
                    Value = drCommandsToExecute["CommandValue0"].ToString();
                    if (Value.IndexOf('<') != -1)
                    { // if something in the string to translate open a new Translater and replace the values
                        LabManager.TranslateString translater = new LabManager.TranslateString();
                        Value = translater.TranslateValueString(Value, nSample_ID);
                    }

                    WriteLoggEntry((int)Definition.ThorLogWindows.ROUTING, strRoutingPositionEntryLogString + @"command:: shifting sample" +
                        " :`" + myHC.GetNameFromID((int)Definition.SQLTables.SAMPLE_ACTIVE, nSample_ID) + "`(id:" + nSample_ID + ")" +
                        " to position:  `" + myHC.GetNameFromID((int)Definition.SQLTables.MACHINE_POSITIONS, Int32.Parse(Value)) + "`(id:" + Value + ")" +
                        " from position: `" + myHC.GetNameFromID((int)Definition.SQLTables.MACHINE_POSITIONS, nMachinePosition_ID) + "`(id:" + nMachinePosition_ID + ")");

                    myRoutingData.ShiftSampleToPositionXBySample_ID(nSample_ID, Value);
                    // myRoutingData.SetCommandActiveOnRoutingCommandsByRoutingCommands_ID(nRouting_Commands_ID, 1);

                }
                else
                {
                    int nRouting_Commands_ID = -1;
                    Int32.TryParse(drCommandsToExecute["idrouting_commands"].ToString(), out nRouting_Commands_ID);
                    WriteLoggEntry((int)Definition.ThorLogWindows.ERROR, strRoutingPositionEntryLogString + "command:: Execute ShiftSample: no Sample_ID found for nRouting_Command_ID:" + nRouting_Commands_ID + "  ", (int)Definition.Message.D_ALARM);
                }

            }
            else
            {
                WriteLoggEntry((int)Definition.ThorLogWindows.ERROR, strRoutingPositionEntryLogString + "command:: Execute ShiftSample: no ActualSamplePosition_ID:" + nMachinePosition_ID + " found ", (int)Definition.Message.D_ALARM);

            }
        }
Example #3
0
        private void ExecuteInsertWSEntry(int nSample_ID, DataRow drActiveSample, DataRow drCommandsToExecute, string strRoutingPositionEntryLogString)
        {
            int nMachinePosition_ID = Int32.Parse(drActiveSample["ActualSamplePosition_ID"].ToString());
            string ValueName = null;
            string Value = null;
            string strSampleID = null;
            int nLocationType = -1;
            bool bHiddenFlag = false;

            int nRouting_Commands_ID = Int32.Parse(drCommandsToExecute["idrouting_commands"].ToString());

            strSampleID = drActiveSample["SampleID"].ToString();

            if (nSample_ID > 0 && strSampleID.Length > 1)
            {
                ValueName = drCommandsToExecute["CommandValue2"].ToString();
                Value = drCommandsToExecute["CommandValue3"].ToString();
                Int32.TryParse(drCommandsToExecute["CommandValue0"].ToString(), out nLocationType);

                if (Value.Length > 0 && ValueName.Length > 0)
                {
                    if (Value.IndexOf('<') != -1)
                    { // if something in the string to translate, open a new Translater and replace the values
                        LabManager.TranslateString translater = new LabManager.TranslateString();
                        Value = translater.TranslateValueString(Value, nSample_ID);
                    }
                    if (nLocationType == (int)Definition.WSInsertLocation.OWNPOSHIDDEN ||
                        nLocationType == (int)Definition.WSInsertLocation.SAMPLEONPOSHIDDEN ||
                        nLocationType == (int)Definition.WSInsertLocation.WRITETOPARENTHIDDEN)
                    { bHiddenFlag = true; }

                    if (nLocationType == (int)Definition.WSInsertLocation.SAMPLEONPOS)
                    {
                        int nPosition = -1;
                        Int32.TryParse(drCommandsToExecute["CommandValue1"].ToString(), out nPosition);
                        string strSampleIDonPos = null;
                        nSample_ID = myHC.GetSampleActive_IDIfOnMachinePosition(nPosition);
                        if (nSample_ID > 0)
                        {
                            strSampleIDonPos = myHC.GetNameFromID((int)Definition.SQLTables.SAMPLE_ACTIVE, nSample_ID);
                            if (strSampleIDonPos != null)
                            {
                                strSampleID = strSampleIDonPos;
                            }
                            else
                            {
                                WriteLoggEntry((int)Definition.ThorLogWindows.ERROR, strRoutingPositionEntryLogString + @"ExecuteInsertWSEntry:: no name found for sample with id '" + nSample_ID + "");
                            }
                        }
                        else
                        {
                            WriteLoggEntry((int)Definition.ThorLogWindows.ERROR, strRoutingPositionEntryLogString + @"ExecuteInsertWSEntry:: no sample id found on position: '" + nPosition + "");

                        }
                    }

                    if (nLocationType == (int)Definition.WSInsertLocation.WRITETOPARENT)
                    {
                        string strSampleIDParent = null;
                        strSampleIDParent = myHC.GetSampleValueFromSampleValuesByValueName( "Parent_ID",  strSampleID);
                        if (strSampleID.Length > 0)
                        {
                            nSample_ID = myHC.GetIDFromName((int)Definition.SQLTables.SAMPLE_ACTIVE, strSampleIDParent);
                            if (nSample_ID > 0)
                            {
                                strSampleID = strSampleIDParent;
                            }
                            else
                            {
                                WriteLoggEntry((int)Definition.ThorLogWindows.ERROR, strRoutingPositionEntryLogString + @"ExecuteInsertWSEntry:: no id found for sample with name '" + strSampleID + "");
                            }
                        }
                        else
                        {
                            WriteLoggEntry((int)Definition.ThorLogWindows.ERROR, strRoutingPositionEntryLogString + @"ExecuteInsertWSEntry:: no Parent_ID found");

                        }
                    }

                    if (Value.Length > 0) // look if value after translate is still > 0
                    {
                        //myHC.GetNameFromID((int)Definition.SQLTables.SAMPLE_ACTIVE, nSample_ID)
                        WriteLoggEntry((int)Definition.ThorLogWindows.ROUTING, strRoutingPositionEntryLogString + @"command:: inserting worksheet entry `" + ValueName + "`" +
                            " with value: `" + Value + "`" +
                            " into sample:  `" + strSampleID + "`(id:" + nSample_ID + ")" +
                            " from Routing position:  `" + myHC.GetNameFromID((int)Definition.SQLTables.MACHINE_POSITIONS, nMachinePosition_ID) + "`(id:" + nMachinePosition_ID + ")");

                        switch (ValueName)
                        {
                            case "SampleID":
                            case "sampleid":
                            case "Sampleid":
                            case "SAMPLEID":
                                {
                                    if (Value.Length > 2)
                                    {
                                        myRoutingData.ChangeSampleIDBySample_ID(nSample_ID, Value);
                                        myRoutingData.InsertWSEntryFromSampleValuesBySample_IDAndValueName(nSample_ID, "OriginalSampleID", strSampleID, Value, bHiddenFlag);
                                    }
                                    else {
                                        WriteLoggEntry((int)Definition.ThorLogWindows.ERROR, strRoutingPositionEntryLogString + "command:: ExecuteInsertWSEntry for Sample `" + strSampleID + "` with ID: " + nSample_ID + " failed -  value for SampleID empty or to short (Value: " + Value.ToString() + ")", (int)Definition.Message.D_ALARM);
                                    }
                                }
                                break;

                            default:    // insert into the table "sample_values"
                                myRoutingData.InsertWSEntryFromSampleValuesBySample_IDAndValueName(nSample_ID, ValueName, Value, myHC.GetNameFromID((int)Definition.SQLTables.SAMPLE_ACTIVE, nSample_ID), bHiddenFlag);
                                break;
                        }

                    }
                    else
                    {
                        WriteLoggEntry((int)Definition.ThorLogWindows.ERROR, strRoutingPositionEntryLogString + "command:: ExecuteInsertWSEntry for Sample `" + strSampleID + "` with ID: " + nSample_ID + " failed - value after translate function is null (Value: " + Value.ToString() + ")", (int)Definition.Message.D_ALARM);
                    }
                }
                else
                {
                    WriteLoggEntry((int)Definition.ThorLogWindows.ERROR, strRoutingPositionEntryLogString + "command:: ExecuteInsertWSEntry for Sample  `" + strSampleID + "` with ID: " + nSample_ID + " failed - no Value or ValueName given (Value: " + Value + "; Valuename: " + ValueName + ")", (int)Definition.Message.D_ALARM);
                }
            }
            else
            {
                WriteLoggEntry((int)Definition.ThorLogWindows.ERROR, strRoutingPositionEntryLogString + "command:: ExecuteInsertWSEntry for Sample `" + strSampleID + "` with ID: " + nSample_ID + " failed - no SampleName: " + strSampleID, (int)Definition.Message.D_ALARM);
            }
        }
Example #4
0
        private void ExecuteCreateSample(int nSample_ID, DataRow drActiveSample, DataRow drCommandsToExecute, string strRoutingPositionEntryLogString)
        {
            int nMachinePosition_ID = Int32.Parse(drActiveSample["ActualSamplePosition_ID"].ToString());
            string strSampleName = null;
            int nPriority = -1;
            int nProgramType_ID = -1;
            int nPosition_ID = -1;
            LabManager.TranslateString translater = new LabManager.TranslateString();

            nProgramType_ID = Int32.Parse(drCommandsToExecute["CommandValue1"].ToString());
               // strSampleName = translater.TranslateSampleRegistrationString(drCommandsToExecute["CommandValue2"].ToString());
            strSampleName = translater.TranslateValueString(drCommandsToExecute["CommandValue2"].ToString(), nSample_ID);
            nPriority = Int32.Parse(drCommandsToExecute["CommandValue3"].ToString());
            nPosition_ID = Int32.Parse(drCommandsToExecute["CommandValue0"].ToString());

            int nRouting_Commands_ID = Int32.Parse(drCommandsToExecute["idrouting_commands"].ToString());
               //  if
                {

                    WriteLoggEntry((int)Definition.ThorLogWindows.ROUTING, strRoutingPositionEntryLogString + @"command:: create sample" +
                           ": `" + strSampleName +
                           "` with program: `" + myHC.GetNameFromID((int)Definition.SQLTables.SAMPLE_PROGRAM, nProgramType_ID) + "`(id:" + nProgramType_ID + ")" +
                           " with priority: `" + nPriority + "`" +
                           " on position: `" + myHC.GetNameFromID((int)Definition.SQLTables.MACHINE_POSITIONS, nPosition_ID) + "`(id:" + nPosition_ID + ")" +
                           " from position: `" + myHC.GetNameFromID((int)Definition.SQLTables.MACHINE_POSITIONS, nMachinePosition_ID) + "`(id:" + nMachinePosition_ID + ")");

                    myRoutingData.InsertSampleInSample_ActiveBySampleProgrammType_IDAndSampleIDAndPriority(nProgramType_ID, strSampleName, nPriority, nPosition_ID);
                   // myRoutingData.SetCommandActiveOnRoutingCommandsByRoutingCommands_ID(nRouting_Commands_ID, 1);

                }
        }
Example #5
0
        private void ExecuteCommandForMachine(int nSample_ID, int nSampleType, int nSampleProgram_ID, DataRow drActiveSample, DataRow drCommandsToExecute, string strRoutingPositionEntryLogString)
        {
            int nCommand = -1;
            int nMachine_ID = -1;
            int nMachinePosition_ID = Int32.Parse(drActiveSample["ActualSamplePosition_ID"].ToString());
            nCommand = Int32.Parse(drCommandsToExecute["CommandValue1"].ToString());
            nMachine_ID = Int32.Parse(drCommandsToExecute["CommandValue0"].ToString());

            int nRouting_Commands_ID = Int32.Parse(drCommandsToExecute["idrouting_commands"].ToString());

                if (nMachine_ID > 0)
                {

                    int nConnectionType = myRoutingData.GetConnectionType_IDFromConnectionListByMachine_ID(nMachine_ID);
                  //  WriteLoggEntry((int)Definition.ThorLogWindows.ROUTING, " #### nConnectionType:" + nConnectionType.ToString());
                    switch(nConnectionType)
                    {
                        //PLC
                        case (int)Definition.ConnectionTypes.PLC:
                        int nProgram_ID = -1;

                        int nMachine_List_ID = myHC.GetMachineList_IDFromMachinesByMachine_ID(nMachine_ID);

                        nProgram_ID = myRoutingData.GetProgram_IDFromSampleProgramsMachineProgramsByMachineList_IDSampleTypeSampleProgram_ID(nMachine_List_ID, nSampleType, nSampleProgram_ID);

                        WriteLoggEntry((int)Definition.ThorLogWindows.ROUTING, strRoutingPositionEntryLogString + @"command:: execute Command for Machine: `" +
                        myHC.GetNameFromID((int)Definition.SQLTables.MACHINES, nMachine_ID) + "` (id:" + nMachine_ID + ")" +
                                    " Command: `" + myHC.GetNameFromID((int)Definition.SQLTables.MACHINE_COMMANDS, nCommand) + "`(id:" + nCommand + ")" +
                                    " for Sample: `" + myHC.GetNameFromID((int)Definition.SQLTables.SAMPLE_ACTIVE, nSample_ID) + "`(id:" + nSample_ID + ")" +
                                    " with program: `" + myHC.GetNameFromID((int)Definition.SQLTables.MACHINE_PROGRAMS, nProgram_ID) + "`(id:" + nProgram_ID + ")" +
                                    " from position: `" + myHC.GetNameFromID((int)Definition.SQLTables.MACHINE_POSITIONS, nMachinePosition_ID) + "`(id:" + nMachinePosition_ID + ")");

                        myRoutingData.InsertCommandIntoCommandTable(nMachine_ID, nCommand, nSample_ID, nProgram_ID);
                        // myRoutingData.SetCommandActiveOnRoutingCommandsByRoutingCommands_ID(nRouting_Commands_ID, 1);
                        break;

                        // Magazine
                        case (int)Definition.ConnectionTypes.MAGAZINE:

                            int nNumber = myRoutingData.GetNumberFromMachineCommandsByMachineCommands_ID(nCommand);
                            int nPos = 1;
                           //Magazine_Driver myMagazine = LabManager.LabManager.
                            WriteLoggEntry((int)Definition.ThorLogWindows.ROUTING, strRoutingPositionEntryLogString + @"command:: execute Command for Magazine: `" +
                            myHC.GetNameFromID((int)Definition.SQLTables.MACHINES, nMachine_ID) + "` (id:" + nMachine_ID + ")" +
                                   " Command: `" + myHC.GetNameFromID((int)Definition.SQLTables.MACHINE_COMMANDS, nCommand) + "`(id:" + nCommand + ")" +
                                   " for Sample: `" + myHC.GetNameFromID((int)Definition.SQLTables.SAMPLE_ACTIVE, nSample_ID) + "`(id:" + nSample_ID + ")" +
                                   " from position: `" + myHC.GetNameFromID((int)Definition.SQLTables.MACHINE_POSITIONS, nMachinePosition_ID) + "`(id:" + nMachinePosition_ID + ")");
                            int nNewSampleID = -1;
                            if (drCommandsToExecute["CommandValue2"].ToString().Length > 0) // if sampleName is given, get the new id from Sample ID
                            {
                                string strTranslateString = drCommandsToExecute["CommandValue2"].ToString();
                                LabManager.TranslateString translater = new LabManager.TranslateString();
                                strTranslateString = translater.TranslateValueString(strTranslateString, nSample_ID);
                                nNewSampleID =  myHC.GetIDFromSampleID(strTranslateString);
                            }
                            else
                            {
                                nNewSampleID = nSample_ID;
                            }
                            nPos = myHC.GetMagazinePosBySampleIDFrimSampleValues(nNewSampleID);
                            Boolean bDone = _parent.SendCommadToMagazine_Driver((nMachine_ID - 1), nNumber, nNewSampleID, nPos, nMachine_ID);

                        break;

                        // TCP-IP
                        case (int)Definition.ConnectionTypes.TCPIP:

                          int nOrderNumber = myRoutingData.GetNumberFromMachineCommandsByMachineCommands_ID(nCommand);
                          string strTranslateStringTCPIP = null;

                          WriteLoggEntry((int)Definition.ThorLogWindows.ROUTING, strRoutingPositionEntryLogString + @"command:: for TCP/IP: `" +
                            myHC.GetNameFromID((int)Definition.SQLTables.MACHINES, nMachine_ID) + "` (id:" + nMachine_ID + ")" +
                                   " Command: `" + myHC.GetNameFromID((int)Definition.SQLTables.MACHINE_COMMANDS, nCommand) + "`(id:" + nCommand + ")" +
                                   " for Sample: `" + myHC.GetNameFromID((int)Definition.SQLTables.SAMPLE_ACTIVE, nSample_ID) + "`(id:" + nSample_ID + ")" +
                                   " from position: `" + myHC.GetNameFromID((int)Definition.SQLTables.MACHINE_POSITIONS, nMachinePosition_ID) + "`(id:" + nMachinePosition_ID + ")");

                            if (drCommandsToExecute["CommandValue2"].ToString().Length > 0) // if sampleName is given, get the new id from Sample ID
                            {
                                strTranslateStringTCPIP = drCommandsToExecute["CommandValue2"].ToString();
                                LabManager.TranslateString translater = new LabManager.TranslateString();
                                strTranslateStringTCPIP = translater.TranslateValueString(strTranslateStringTCPIP, nSample_ID);
                            }
                            else
                            {
                                WriteLoggEntry((int)Definition.ThorLogWindows.ERROR, strRoutingPositionEntryLogString + "RoutingCommand:: ExecuteCommandForMachine for Sample `" + myHC.GetNameFromID((int)Definition.SQLTables.SAMPLE_ACTIVE, nSample_ID) + "` with ID: " + nSample_ID + " failed - no Command found: " + drCommandsToExecute["CommandValue2"].ToString(), (int)Definition.Message.D_ALARM);
                            }

                            // SendCommadToTCPIP(int nNumber, int nSample_ID, string strCommand, int nMachine_ID)
                            _parent.SendCommadToTCPIP(nOrderNumber, nSample_ID, strTranslateStringTCPIP, nMachine_ID);

                        break;

                    }
                }
                else
                {
                    WriteLoggEntry((int)Definition.ThorLogWindows.ROUTING, strRoutingPositionEntryLogString + "RoutingCommand:: execute Command: " + nCommand + " for machine_ID:" + nMachine_ID + "  failed no machine_ID found!", (int)Definition.Message.D_ALARM);
                }
        }
Example #6
0
        private void ExecuteChangeSampleType(int nSample_ID, DataRow drActiveSample, DataRow drCommandsToExecute, string strRoutingPositionEntryLogString)
        {
            int nMachinePosition_ID = Int32.Parse(drActiveSample["ActualSamplePosition_ID"].ToString());
            string Value = null;

            int nRouting_Commands_ID = Int32.Parse(drCommandsToExecute["idrouting_commands"].ToString());

                if (nSample_ID > 0)
                {
                    Value = drCommandsToExecute["CommandValue0"].ToString();
                    if (Value.IndexOf('<') != -1)
                    { // if something in the string to translate open a new Translater and replace the values
                        LabManager.TranslateString translater = new LabManager.TranslateString();
                        Value = translater.TranslateValueString(Value, nSample_ID);
                    }

                    WriteLoggEntry((int)Definition.ThorLogWindows.ROUTING, strRoutingPositionEntryLogString + @"command:: changing the SampleProgramType" +
                        " for sample: `" + myHC.GetNameFromID((int)Definition.SQLTables.SAMPLE_ACTIVE, nSample_ID) + "`(id:" + nSample_ID + ")" +
                        " to value: `" + myHC.GetNameFromID((int)Definition.SQLTables.SAMPLE_PROGRAM, Int32.Parse(Value)) + "`n(id:" + Value + ")" +
                        " from position: `" + myHC.GetNameFromID((int)Definition.SQLTables.MACHINE_POSITIONS, nMachinePosition_ID) + "`(id:" + nMachinePosition_ID + ")");

                    myRoutingData.ChangeSampleTypeInSampleBySample_ID(nSample_ID, Value);
                  //  myRoutingData.SetCommandActiveOnRoutingCommandsByRoutingCommands_ID(nRouting_Commands_ID, 1);

                }
        }