6 Replies Latest reply on Mar 21, 2018 4:21 PM by kbobeck

    Coresight Extensibility - Multistate Options

    patrick.mechenbier

      I'm developing a few symbols for Coresight (using 2016 R2) that are going to exclusively used as multistate symbols. After looking through the 2016 R2 extensibility guidelines and poking around in some of the JSON returned for saved displays, I have two questions:

      1. In the symbol definition, is there a way to turn on the multistate behavior by default when the symbol is initialized on a display?
      2. In the symbol definition, is there a way to specify colors to use for possible states?

       

      For the first question, since these symbols are going to be used exclusively as multistate symbols, I don't want to make the user right click on each symbol instance and click the "configure multi-state..." option to turn on the multistate behavior. There are going to be a fair amount of instances of these symbols on a display, so right clicking each new instance would be a tedious exercise. I noticed a MSDataSources property in a saved symbol's JSON definition - would adding the initial DataSource array value used to initialize the symbol to this array in the symbol's init function effectively accomplish this behavior (or would this be the recommended way)?

       

      For the second question, these symbols will be used to visualize a data point on a class of equipment that all have similar values for the same data point (some manufacturers use slightly different terms, but they're similar enough). Is there a way that I can configure the symbol to display a value (if it exists within the state set) as a certain color? I'm envisioning something like this:

       

      Symbol.Configuration.DefautMultistateValues: [
          {
              color: '#ff0000',
              values: ['closed', 'energized']
          },
          {
              color: '#00ff00',
              values: ['open', 'denergized']
          }
      ]
      
      

       

      So if the attribute/PI Point used to initialize the symbol on the display has a value of 'closed' or 'energized' in it's state set, the symbol would use red as the color for that state, without configuration from the user. This would save the user from having to configure each and every instance of the symbol dropped on the display. I took a look at the States array in a symbol's Configuration.Multistates object for clues, but there are some properties of each state that i didn't know how set (or if it would be supported).

       

      Let me know if you have any questions or if anything above is unclear (or find me at the 2017 UC to discuss!).

        • Re: Coresight Extensibility - Multistate Options
          Eugene Lee

          Hi Patrick,

           

          You can try adding this to your init function.

           

          function makedefaultstates() {
                      return {
                          States: [
                              {
                                  StateValues: ['orange', true],
                                  UpperValue: 100
                              },
                              {
                                  StateValues: ['purple', false],
                                  UpperValue: 200
                              },
                              {
                                  StateValues: ['blue', false],
                                  UpperValue: 300
                              },
                          ],
                          LowerValue: 1,
            StateVariables:[scope.def.StateVariables[0]]
                      };
                  }
          scope.symbol.MSDataSources = scope.symbol.DataSources;
          scope.symbol.Configuration.Multistates = [makedefaultstates()];
          

           

          I have tried this for CDT158 tag and it works. Take note that this might not be officially supported. Just for your testing.

          2 of 2 people found this helpful
            • Re: Coresight Extensibility - Multistate Options
              kbobeck

              Hi Eugene,

               

              Any suggestions on how to incorporate this into the graphics symbol? I tried to do so, but didn't get any results (the symbol was neither broken nor shown with default states).

               

              Essentially, we are trying to create a "style sheet" so all equipment (pumps, motors, valves, etc.) are consistently one color for on/open, another color for off/closed, and a third color for "bad data". This would go a long way in achieving that.

               

              Thanks,

              Kelsey

                • Re: Coresight Extensibility - Multistate Options
                  Eugene Lee

                  Hi Kelsey,

                   

                  The reason is because a graphics symbol doesn't have a datasource. You will have to manually specify one (otherwise, how would the graphic symbol know which data item to use?). Change this line

                   

                  scope.symbol.MSDataSources = scope.symbol.DataSources;

                   

                  to

                   

                  scope.symbol.MSDataSources = ["pi:\\\\<yourpidataarchivename>\\CDT158"];

                   

                  and you will see some results. <yourpidataarchivename> should be your PI Data Archive name. CDT158 is the PI point name.

                   

                  Let me know if it works for you.

                  1 of 1 people found this helpful
                    • Re: Coresight Extensibility - Multistate Options
                      kbobeck

                      Hi Eugene,

                       

                      Thanks for your quick response. I guess I was assuming it would know which data source to use when I did right-click > configure multi-state and then dragged and dropped an attribute or tag onto it. You modification did work for CDT158; however, when I tried to change out the CDT158 for SINUSOID, it reverted back to the true default settings. Unfortunately, hard-coding the tag would not be feasible for us, as the tag will vary.

                       

                      I did figure out how to set some default colors. Within PIVisualization.config-multistate-service.js, I changed the following:

                              var msColorConfig = {
                                  showSelector: false,
                                  top: 0,
                                  left: 0,
                                  stateValues: [],
                                  colors: [
                                      '#EEF2F9', 'orange', 'chartreuse', 'blue', '#B4B9C8', 'magenta',
                                      'yellow', 'black', 'lightgray', 'darkred', 'darkgreen', 'gray',
                                      'blueviolet', 'darkblue', 'olive', 'orangered', 'limegreen', 'red'
                                  ],
                      

                      and

                                  var config = {
                                      IsDigitalSet: defaultStates.IsDigitalSet,
                                      IsDynamicLimit: defaultStates.IsDynamicLimit,
                                      StateVariables: def.StateVariables,
                                      ErrorStateValues: ['#F504FF', false],
                                      DefaultStateValues: def.StateVariables && def.StateVariables.map(function (prop) {
                                          return prop.indexOf('Blink') > -1 ? 'False' : null;
                                      })
                                  };
                      

                      Which resulted in this:

                       

                      Unfortunately, I couldn't find a way to modify the default values/number of default multi-states. But it's a start.

                       

                      I appreciate your assistance!

                       

                      Kelsey

                        • Re: Coresight Extensibility - Multistate Options
                          Eugene Lee

                          Hi Kelsey,

                           

                          I found out where the default states are set. Find this part of the file:

                           

                          function onReceiveDefaultStates(symbol, def, newDataSource, response, oldConfig, newAttribute) {
                                      var defaultStates = response.data;
                                      var colors = msColorConfig.colors;
                                      var config = {
                          

                           

                          Change it to

                           

                          function onReceiveDefaultStates(symbol, def, newDataSource, response, oldConfig, newAttribute) {
                                      var defaultStates = {"LowerValue":3.0,"States":[{"Value":11.0},{"Value":22.0},{"Value":33.0},{"Value":44.0},{"Value":55.0}]}//response.data;
                                      var colors = msColorConfig.colors;
                                      var config = {
                          

                           

                          Now you will see that the default values become 11,22,33,44,55. Hope this helps!

                          2 of 2 people found this helpful