slimskism

MrPLC Member
  • Content count

    12
  • Joined

  • Last visited

Posts posted by slimskism


  1. Hi,

    Just found this, you can use the DspPopupMenu function.  You then need to use Cicode to do stuff with the menu options, but calling DspPopUpMenu(-1) will return which option was chosen.  Below is some example code taken from one of our projects.  The StrGetField function is not a built in function but it just returns an item from a comma separated list.

    FUNCTION DropdownTrendMenu(STRING sDisplayNames, STRING sPavNames)
    
    	INT i = 0;
    	INT iMenuOption = 0;
    	STRING sPav = "";
    	OBJECT hProcessAnalyst;
    	
    	DspPopupMenu(0, sDisplayNames)
    	iMenuOption = DspPopupMenu(-1);
    	
    	IF iMenuOption > 0 THEN
    		sPav = StrGetField(sPavNames, iMenuOption, ",");
    	
    		IF sPav <> "" THEN
    			IF FileExist(PathToStr("[Run]:" +"\Analyst Views\" + sPav + ".pav")) THEN
    			
    				PageDisplay("ProcessAnalyst");
    				
    				SleepMS(200);
    		
    				hProcessAnalyst = ObjectByName("AN206");
    				CSV_PA_LoadPavFile(hProcessAnalyst, sPav);
    				_ObjectCallMethod(hProcessAnalyst, "SynchroniseToNow");	
    		
    		    END
    		END
    	END
    END

     


  2. You probably need to post a bit more information here to get a reasonable answer to your question.  What PLC are you using?  Which communication protocol?  How is everything connected together?  #BAD and #COM means Citect cannot connect to the PLC.


  3. I assume this is Wonderware InTouch SCADA and Wonderware Historian?  Sounds like the issue is not being able to create the log file.  I would be looking for things like hard-drive space and read/write permissions to the log file location.  I don't have much experience with InTouch SCADA but is there an option to create all log files on startup?  Citect SCADA has something like this and would avoid these issues (or at least you would know about them on start up).


  4. We have had a similar issue with a remote HMI freezing.  We just connected the power supply through a relay and use the PLC to toggle it off and on again.  Not an elegant solution but beats three hours of driving every time we have to do it.


  5. Yeah the d and s are just part of our naming convention that has s for string, d for dateTime, i for Int etc.  All of those are just variable names for information we want to store.  In your case you could just use something like @tagval1 , @tagval2 etc. but it might help to name them something more descriptive if you have to line them up with a particular column in your SQL database.

    1 person likes this

  6. The gsPrimaryConnection is an SQL connection string, see example below, you will need to replace SERVERNAME etc with your details:

    STRING gsPrimaryConnection = "Driver={SQL Server};Server=SERVERNAME;UID=USERNAME;Pwd=PASSWORD;Persist Security Info=True;Database=SQLDATABASENAME";

    CSV_DB_Execute is a built in Cicode function (at least in 2015 SP1 that we are using).  There is some info for it here:  https://gcsresource.aveva.com/Citect/WebHelp/citect750sp1/default.htm#CSV_DB_Execute.html?Highlight=csv_db_execute

    qryInsertOperatorLog is the custom SQL script that I have shown above.

    1 person likes this

  7. Below is the important part of the Cicode file (I have taken part 3 and 4 out for the sake of brevity):

    // Connect to the database and log the action
    // The data is sent in 4 parts due to string size being greater then 255
    // The 4 parts are User info, Tag Info, Comments and Computer info
    
    //Part 1 User info, (Date and user name) 
    	sCmd = "qryInsertOperatorLog";
    	sCmd = sCmd + "('" + sDateTime + "', '" + sUser +"', '"+ sPCNode +"')";
       	hRecordSet = CSV_DB_Execute(sCmd, gsPrimaryConnection);
    	
    	TraceMsg("Executing " + sCmd);
    	
    	
    	IF hRecordSet = -1 THEN
    		//Message("ERROR", "There was a problem creating a new operator log entry in function 'WriteSQL()'.",48);
    		DBLogError("WriteSQL/SQLExec", hRecordSet, 0);
    		CSV_DB_Close(hRecordSet);
    		RETURN;
    	END
    	CSV_DB_Close(hRecordSet);
    
    //Part 2 Tag Info, (Action taken, tag name, new value)
    	sCmd = "qryUpdateOpLogTagInfo";
    	sCmd = sCmd + "('" + sDateTime + "', '" + sAction + "', '" + sTag + "', '" + sValue + "', '"+ sPCNode +"')";
       	hRecordSet = CSV_DB_Execute(sCmd, gsPrimaryConnection);
    	
    	TraceMsg("Executing " + sCmd);
    	
    	
    	IF hRecordSet = -1 THEN
    		//Message("ERROR", "There was a problem creating a new operator log entry in function 'WriteSQL()'.",48);
    		DBLogError("WriteSQL/SQLExec", hRecordSet, 0);
    		CSV_DB_Close(hRecordSet);
    		RETURN;
    	END
    	CSV_DB_Close(hRecordSet);

    This is the custom SQL scripts that exist on the server (insert, part1 and update, part2):

    ALTER PROCEDURE [dbo].[qryInsertOperatorLog]
    	(@dEventTime AS datetime, @sUser AS nvarchar(20), @sPCNode AS nvarchar(50) )
    AS
    BEGIN
    
    	SET NOCOUNT ON;
    
    	INSERT INTO [dbo].[OperatorLog]
               ([EventTime],[Operator],[PCNode])
         VALUES
    		(@dEventTime, @sUser, @sPCNode)	
    END
    ALTER PROCEDURE [dbo].[qryUpdateOpLogTagInfo]
    	(@dEventTime as datetime, @sAction nvarchar(30), @sTag nvarchar(79), @rValue real,@sPCNode AS nvarchar(50))
    AS
    BEGIN
    
    	SET NOCOUNT ON;
    
    	UPDATE [dbo].[OperatorLog]
    	SET [Action] = @sAction,
    		[Tag] = @sTag,
    		[Value] = @rValue	
    	WHERE ([EventTime] = @dEventTime) AND ([pcNODE] = @sPCNode)
    
    END
    

    Hope that helps, but let me know if you have any questions.

    1 person likes this

  8. Our system does something very similar to what you are doing.  I didn't the write the code to do it, but they got around the issue by writing some of the tags (and creating a new row in the SQL database), then updating that row with some more tags, on so on until all your tags are written.  It required a custom SQL script on the server for each time the tags were written.  I'll have a dig through the code and see if I can paste an example.

    1 person likes this

  9. Are you using Citect on all the connected PLCs?  If you are, you should be able to run them as clients and view the tag values that way.  If you just want to view a file with the tag values, I'm not sure of a way to do that, but hoping someone else can help as I would like to know too.