//This Parameter is saved as an Integer OP.SetParameter("My Age", 39); //This Parameter is saved as a double and belong to group 'Price Group' OP.SetParameter("Price Group","Current Oil Price", 40.0); //This Parameter is saved as a string OP.SetParameter("My Email", "info@Open-Plant.com"); //This Parameter is assigned based on FIC101.Value OP.SetParameter("Last Known Value", OP.Tag("FIC101.Value").Sample.Value); //These parameters are saved as a DateTime Object OP.SetParameter("Last Processed Time", OP.Tag("FIC101.Value").Sample.TSUTC); OP.SetParameter("Cut Off Date", "2020-11-27 00:00:00".ToDateTime());
try { OP.SetParameter("MyGroup","MyParam",DateTime.Now); } catch (UnauthorizedAccessException) { OP.Log("You are unauthorized to edit this parameter!"); }
int MyAge = OP.GetParameter("My Age"); double OilPrice = OP.GetParameter("Live Prices","Current Oil Price"); string MyEmail = OP.GetParameter("Email Group","My Email"); var LastKnownValue = OP.GetParameter("Last Known Value"); DateTime LastProcessedTime = OP.GetParameter("Last Processed Time"); DateTime CutOffDate = OP.GetParameter("Cut Off Date"); /* The following JSON Object has definition: { "employees":[ {"firstName":"John", "lastName":"Doe"}, {"firstName":"Anna", "lastName":"Smith"}, {"firstName":"Peter", "lastName":"Jones"} ] } */ var definition = new { employees = new[] { new { firstName = "", lastName = "" } }} var JsonObj = OP.GetParameter("Employees", definition); string Employee1_FirstName = JsonObj.employees[0].firstName; string Employee2_LastName = JsonObj.employees[1].lastName;
try { OP.SetParameter("MyGroup","MyParam",DateTime.Now); } catch (UnauthorizedAccessException) { OP.Log("You are unauthorized to edit this parameter!"); }
//This sets a Parameter from group "My Old Group" to "My New Group" OP.SetParameterGroup("My Old Group","MyParameter","My New Group"); //This sets a Parameter from the default group to a New Group OP.SetParameterGroup("MyParameter","My New Group"); //This sets a Parameter's group to the default group OP.SetParameterGroup("My Old Group",null); //This sets a Parameter's Minimum Read to 8 OP.SetParameterMinimumRead("MyParam",8); OP.SetParameterMinimumRead("MyGroup","MyParam",8); //This sets a Parameter's Minimum Edit to 8 OP.SetParameterMinimumEdit("MyParam",8); OP.SetParameterMinimumEdit("MyGroup","MyParam",8);
try { OP.SetParameter("MyGroup","MyParam",DateTime.Now); } catch (UnauthorizedAccessException) { OP.Log("You are unauthorized to edit this parameter!"); }
if (OP.ParameterExists("Cut Off Date")) OP.Log("Cut off Date = " + OP.GetParameter("Cut Off Date")); else OP.Log("Parameter does not exist!"); if (OP.ParameterExists("MyGroup","MyItem")) OP.Log("Cut off Date = " + OP.GetParameter("MyGroup","MyItem")); else OP.Log("Parameter does not exist!");
OP.DeleteParameter("MyGroup","Cut Off Date"); OP.DeleteParameter("Cut Off Date");
//This logs all the Parameter name and values to the console ListParameterNames = OP.ParameterNames("*"); foreach (string ParameterName in ParameterNames) { OP.Log(ParameterName + " = " + OP.GetParameter(ParameterName)); } //This logs all the Parameter name that ends with ".Value" in "My Group" List ParameterNames = OP.ParameterNames("My Group","*.Value"); foreach (string ParameterName in ParameterNames) { OP.Log(ParameterName + " = " + OP.GetParameter(ParameterName)); }
//This logs all parameter names OP.LogParameters("*"); //This logs the first 100 parameter names OP.LogParameters("*",100); //This logs all parameter names from "MyGroup" which ends with ".Val" OP.LogParameters("MyGroup","*.Val"); //This logs the first 90 parameter names from "MyGroup" which ends with ".Val" OP.LogParameters("MyGroup","*.Val",90);