private static void TestReadSyncTime() { ConnectionParameters para = new ConnectionParameters(); para.LinkAddress = 1; para.SizeOfCA = 2; LinkControlDown lc = new LinkControlDown(); lc.FCB = false; lc.FCV = true; lc.FuncCode = LinkFunctionCodeDown.UserData; T102Frame frame = new T102Frame(lc, para); ASDU asdu = new ASDU(CauseOfTransmission.SYNC_TIME, false, false, 1, RecordAddress.Default, false); SyncTime st = new SyncTime(new CP56Time2b(new DateTime(2007, 8, 18, 6, 21, 1, 520))); asdu.AddInformationObject(st); asdu.Encode(frame, para); frame.PrepareToSend(); byte[] aa = frame.GetBuffer(); int length = aa[1]; byte linkControl = aa[4]; int linkAddr = aa[5] + aa[6] * 0x100; //解析 ASDU na = new ASDU(para, aa, length + 4 + 2); InformationObject io = na.GetElement(0); }
protected void Page_Load(object sender, EventArgs e) { List <InformationObject> infoList = new List <InformationObject>(); if (CurrentUser == null) { infoList.Add(GetUnLoginInformation()); } if (string.IsNullOrEmpty(CurrentSessionKey) || string.IsNullOrEmpty(CurrentSellerNick)) { infoList.Add(GetUnAuthorizeInformation()); } if (!string.IsNullOrEmpty(Request["Nick"]) && !string.IsNullOrEmpty(Request["ErrorMsg"])) { string msg = "错误\"" + Request["Nick"] + "\" - " + CompressionHelper.Decompress(Request["ErrorMsg"]); InformationObject obj = new InformationObject(); obj.CssName = "ErrorMsg"; obj.Message = msg; infoList.Add(obj); DisplayInformations(infoList, InformationIcoType.Error); } else if (infoList.Count > 0) { DisplayInformations(infoList); } if (!IsPostBack && !string.IsNullOrEmpty(Request["Nick"])) { txtKey.Text = Request["Nick"]; txtKey.Focus(); } }
private static void TestCurrentTime() { ConnectionParameters para = new ConnectionParameters(); para.LinkAddress = 1; para.SizeOfCA = 2; LinkControlUp lc = new LinkControlUp(); lc.ACD = false; lc.DFC = false; lc.FuncCode = LinkFunctionCodeUp.UserData; T102Frame frame = new T102Frame(lc, para); ASDU asdu = new ASDU(CauseOfTransmission.REQUEST, false, false, 1, RecordAddress.Default, false); CurrentTime ct = new CurrentTime(new CP56Time2b(new DateTime(2007, 8, 18, 6, 21, 1, 520))); asdu.AddInformationObject(ct); asdu.Encode(frame, para); frame.PrepareToSend(); byte[] aa = frame.GetBuffer(); int length = aa[1]; byte linkControl = aa[4]; int linkAddr = aa[5] + aa[6] * 0x100; ASDU na = new ASDU(para, aa, length + 4 + 2); InformationObject io = na.GetElement(0); }
private TestSet buildTestSet(string testFileName, string url = "testUrl") { SetEnvironmentVariable(EnvVar.Browser, "chrome"); SetEnvironmentVariable(EnvVar.Environment, ""); SetEnvironmentVariable(EnvVar.TimeOutThreshold, "50"); SetEnvironmentVariable(EnvVar.WarningThreshold, "50"); SetEnvironmentVariable(EnvVar.URL, url); SetEnvironmentVariable(EnvVar.DataFile, $"{readFileLocation}{testFileName}"); SetEnvironmentVariable(EnvVar.CsvSaveFileLocation, saveFileLocation); SetEnvironmentVariable(EnvVar.LogSaveFileLocation, saveFileLocation); SetEnvironmentVariable(EnvVar.ReportSaveFileLocation, saveFileLocation); SetEnvironmentVariable(EnvVar.ScreenshotSaveLocation, saveFileLocation); SetEnvironmentVariable(EnvVar.TestAutomationDriver, "selenium"); SetEnvironmentVariable(EnvVar.TestSetDataType, "XML"); SetEnvironmentVariable(EnvVar.TestSetDataArgs, $"{readFileLocation}{testFileName}"); SetEnvironmentVariable(EnvVar.TestCaseDataType, GetEnvironmentVariable(EnvVar.TestSetDataType)); SetEnvironmentVariable(EnvVar.TestStepDataType, GetEnvironmentVariable(EnvVar.TestCaseDataType)); SetEnvironmentVariable(EnvVar.TestCaseDataArgs, GetEnvironmentVariable(EnvVar.TestSetDataArgs)); SetEnvironmentVariable(EnvVar.TestStepDataArgs, GetEnvironmentVariable(EnvVar.TestCaseDataArgs)); SetEnvironmentVariable(EnvVar.RespectRepeatFor, "true"); SetEnvironmentVariable(EnvVar.RespectRunAODAFlag, "true"); InformationObject.SetUp(); TestSetBuilder builder = new TestSetBuilder(); BuildAutomationDriver(); return(builder.Build()); }
void CreateComponent(InformationObject informationObject, PatternDetector patternDetector) { GameObject ARObjects = new GameObject(); ARObjects.name = "ARObjects"; ARObjects.SetActive(false); GameObject OBJMarkerSettings = new GameObject(); OBJMarkerSettings.name = "MarkerSettings"; MarkerDesign markerDesign = new MarkerDesign(); markerDesign.id = informationObject.IdMarker; MarkerSettings markerSettings = OBJMarkerSettings.AddComponent <MarkerSettings>(); markerSettings.PatternDetector = patternDetector; markerSettings.markerDesign = markerDesign; markerSettings.ARGameObject = ARObjects; GameObject objectAR = ImportResources.GetGameObject(informationObject.Name); GameObject objectCreated = Instantiate(objectAR); objectCreated.AddComponent <RectTransform>(); objectCreated.transform.position = Vector3.zero; objectCreated.transform.rotation = Quaternion.identity; objectCreated.layer = 8; objectCreated.transform.SetParent(ARObjects.transform); ARObjects.transform.SetParent(OBJMarkerSettings.transform); OBJMarkerSettings.transform.SetParent(markerList.transform); }
protected void Page_Load(object sender, EventArgs e) { List<InformationObject> infoList = new List<InformationObject>(); if (CurrentUser == null) { infoList.Add(GetUnLoginInformation()); } if (string.IsNullOrEmpty(CurrentSessionKey) || string.IsNullOrEmpty(CurrentSellerNick)) { infoList.Add(GetUnAuthorizeInformation()); } if (!string.IsNullOrEmpty(Request["Nick"]) && !string.IsNullOrEmpty(Request["ErrorMsg"])) { string msg = "错误\"" + Request["Nick"] + "\" - " + CompressionHelper.Decompress(Request["ErrorMsg"]); InformationObject obj = new InformationObject(); obj.CssName = "ErrorMsg"; obj.Message = msg; infoList.Add(obj); DisplayInformations(infoList, InformationIcoType.Error); } else if (infoList.Count > 0) { DisplayInformations(infoList); } if (!IsPostBack && !string.IsNullOrEmpty(Request["Nick"])) { txtKey.Text = Request["Nick"]; txtKey.Focus(); } }
protected void btnMultiMessageCustomerSperator_Click(object sender, EventArgs e) { divInformationBox.Attributes["class"] = "MultiMessageCustomerSperator"; List <InformationObject> list = new List <InformationObject>(); InformationObject obj1 = new InformationObject(); obj1.CssName = "BlueText"; obj1.Message = "简单的多条信息 - 第1条"; list.Add(obj1); InformationObject obj2 = new InformationObject(); obj2.CssName = "BlackText"; obj2.Message = "简单的多条信息 - 第2条"; list.Add(obj2); InformationObject obj3 = new InformationObject(); obj3.CssName = "RedText"; obj3.Message = "简单的多条信息 - 第3条"; list.Add(obj3); InformationObject obj4 = new InformationObject(); obj4.CssName = "BlueText"; obj4.Message = "简单的多条信息 - 第4条"; list.Add(obj4); InformationObject obj5 = new InformationObject(); obj5.CssName = "RedText"; obj5.Message = "简单的多条信息 - 第5条"; list.Add(obj5); ucInformationBox.SetInformationList(list); }
private static void TestManufacture() { ConnectionParameters para = new ConnectionParameters(); para.LinkAddress = 1; para.SizeOfCA = 2; LinkControlUp lc = new LinkControlUp(); lc.ACD = false; lc.DFC = false; lc.FuncCode = LinkFunctionCodeUp.UserData; T102Frame frame = new T102Frame(lc, para); ASDU asdu = new ASDU(CauseOfTransmission.INITIALIZED, false, false, 1, RecordAddress.Default, false); ManufacturerSpec ms = new ManufacturerSpec(0, 1, 0, 0x05040302); asdu.AddInformationObject(ms); asdu.Encode(frame, para); frame.PrepareToSend(); byte[] aa = frame.GetBuffer(); int length = aa[1]; byte linkControl = aa[4]; int linkAddr = aa[5] + aa[6] * 0x100; ASDU na = new ASDU(para, aa, length + 4 + 2); InformationObject io = na.GetElement(0); }
public InformationObject Add(string text) { var item = new InformationObject(text); SubItems.Add(item); return(item); }
public void CreateVisibleInformation(Information information, Vector3 position) { InformationObject informationObject = Instantiate(InformationPrefab, position, Quaternion.identity). GetComponent <InformationObject>(); informationObject.Information = information; informationObject.PropagationType = InformationPropagationType.Visual; }
public void CreateConversationInformation(Information information, Vector3 position, Agent sender) { InformationObject informationObject = Instantiate(InformationPrefab, position, Quaternion.identity). GetComponent <InformationObject>(); informationObject.Information = information; informationObject.PropagationType = InformationPropagationType.Conversation; informationObject.Sender = sender; }
public InformationObject GetUnLoginInformation() { InformationObject obj = new InformationObject(); obj.CssName = "Information"; obj.Message = "您目前没有登录系统,或者登录已经过期。"; obj.AddLink("点击这里登录系统", "~/Authorizes/UnLogin.aspx?ReturnUrl=" + Server.UrlEncode(Request.Url.AbsoluteUri)); return(obj); }
public void CreateArrivalInformation(WorldObject agent, Location location) { InformationObject informationObject = Instantiate(InformationPrefab, agent.transform.position, Quaternion.identity). GetComponent <InformationObject>(); informationObject.InformationEntry = new InformationEntry( agent, InformationVerb.At, null, 0, location, false); informationObject.PropagationType = InformationPropagationType.Visual; }
public void SetSuccessInformation(string message) { List <InformationObject> list = new List <InformationObject>(); InformationObject obj = new InformationObject(); obj.CssName = "Information"; obj.Message = message; list.Add(obj); DisplayInformations(list, InformationIcoType.Information); }
public void SynchronizeClocks(int commonAddress, IeTime56 time) { var io = new InformationObject(0, new[] { new InformationElement[] { time } }); InformationObject[] ios = { io }; var aSdu = new ASdu(TypeId.C_CS_NA_1, false, CauseOfTransmission.ACTIVATION, false, false, originatorAddress, commonAddress, ios); Send(aSdu); }
protected void btnOneMessage_Click(object sender, EventArgs e) { divInformationBox.Attributes["class"] = "OneMessage"; List <InformationObject> list = new List <InformationObject>(); InformationObject obj = new InformationObject(); obj.Message = "测试只有一条信息"; list.Add(obj); ucInformationBox.SetInformationList(list); }
public InformationObject GetUnAuthorizeInformation() { InformationObject obj = new InformationObject(); obj.CssName = "Information"; obj.Message = "我们没有接收到您对我们网站的淘宝网操作授权,或者授权码已经过期。"; obj.AddLink("点击这里获取淘宝授权", "~/Authorizes/UnAuthorize.aspx?ReturnUrl=" + Server.UrlEncode(Request.Url.AbsoluteUri)); string a = "<img src='" + GetRootURI() + "/Images/Icos/contacts.gif' title='什么是淘宝网授权码' />"; obj.AddLink(a, "~/Authorizes/UnLogin.aspx"); return(obj); }
// Start is called before the first frame update void Start() { _collider = GetComponent <SphereCollider>(); _informationObject = GetComponent <InformationObject>(); switch (_informationObject.PropagationType) { case InformationPropagationType.Visual: { _propagationSpeed = 2.0f; _timeToLife = 10.0f; _maxRadius = 20.0f; } break; case InformationPropagationType.Audio: { _propagationSpeed = 5.0f; _timeToLife = 5.0f; _maxRadius = 10.0f; } break; case InformationPropagationType.Instant: { _propagationSpeed = 1000.0f; _timeToLife = 2.0f; _maxRadius = 1000.0f; } break; case InformationPropagationType.Persistant: { _propagationSpeed = 10.0f; _timeToLife = -1.0f; _maxRadius = 2.0f; } break; case InformationPropagationType.Conversation: { _propagationSpeed = 50.0f; _timeToLife = .5f; _maxRadius = 1.0f; } break; case InformationPropagationType.None: default: throw new ArgumentOutOfRangeException(); } }
private static void TestReadSinglePointWithRange() { ConnectionParameters para = new ConnectionParameters(); para.LinkAddress = 1; para.SizeOfCA = 2; LinkControlDown lc = new LinkControlDown(); lc.FCB = false; lc.FCV = true; lc.FuncCode = LinkFunctionCodeDown.UserData; T102Frame frame = new T102Frame(lc, para); ASDU asdu = new ASDU(CauseOfTransmission.ACTIVATION, false, false, 1, RecordAddress.Period_Week_1, false); ReadSinglePointWithTimeRange sptr = new ReadSinglePointWithTimeRange( new CP40Time2b(new DateTime(2007, 9, 2, 1, 0, 0)), new CP40Time2b(new DateTime(2007, 9, 3, 1, 0, 0))); asdu.AddInformationObject(sptr); asdu.Encode(frame, para); frame.PrepareToSend(); //todo: 记录类型书上表的是0x31,这里测试结果是十进制31,根据国外标准,31应该是十进制。具体情况具体分析把。。 byte[] aa = frame.GetBuffer(); int length = aa[1]; byte linkControl = aa[4]; int linkAddr = aa[5] + aa[6] * 0x100; //解析 ASDU na = new ASDU(para, aa, length + 4 + 2); InformationObject sp = na.GetElement(0); //无数据 na.Cot = CauseOfTransmission.NO_RECORD; LinkControlUp lc2 = new LinkControlUp(); lc2.ACD = false; lc2.DFC = false; lc2.FuncCode = LinkFunctionCodeUp.NoData; T102Frame frame2 = new T102Frame(lc2, para); na.Encode(frame2, para); frame2.PrepareToSend(); //镜像报文 byte[] bb = frame2.GetBuffer(); }
private static void TestReadAccountingITWithTimeRangeAndAddressRange() { ConnectionParameters para = new ConnectionParameters(); para.LinkAddress = 1; para.SizeOfCA = 2; LinkControlDown lc = new LinkControlDown(); lc.FCB = false; lc.FCV = true; lc.FuncCode = LinkFunctionCodeDown.UserData; T102Frame frame = new T102Frame(lc, para); ASDU asdu = new ASDU(CauseOfTransmission.ACTIVATION, false, false, 1, RecordAddress.Default, false); ReadAccountingITWithTimeRangeAndAddressRange at = new ReadAccountingITWithTimeRangeAndAddressRange( 3, 7, new CP40Time2b(new DateTime(2007, 8, 18, 0, 0, 0)), new CP40Time2b(new DateTime(2007, 8, 19, 0, 0, 0))); asdu.AddInformationObject(at); asdu.Encode(frame, para); frame.PrepareToSend(); //todo 书上实例报文,记录地址是03,这个有点扯。。。 byte[] aa = frame.GetBuffer(); int length = aa[1]; byte linkControl = aa[4]; int linkAddr = aa[5] + aa[6] * 0x100; //解析 ASDU na = new ASDU(para, aa, length + 4 + 2); InformationObject sp = na.GetElement(0); //无数据 na.Cot = CauseOfTransmission.NO_RECORD; LinkControlUp lc2 = new LinkControlUp(); lc2.ACD = false; lc2.DFC = false; lc2.FuncCode = LinkFunctionCodeUp.NoData; T102Frame frame2 = new T102Frame(lc2, para); na.Encode(frame2, para); frame2.PrepareToSend(); //镜像报文 byte[] bb = frame2.GetBuffer(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { List <InformationObject> infoList = new List <InformationObject>(); if (CurrentUser == null) { infoList.Add(GetUnLoginInformation()); } if (string.IsNullOrEmpty(CurrentSessionKey) || string.IsNullOrEmpty(CurrentSellerNick)) { infoList.Add(GetUnAuthorizeInformation()); } if (infoList.Count > 0) { DisplayInformations(infoList); lbtnSave.Enabled = false; lbtnPreview.Enabled = false; } else { BindWaittingTemplateList(); BindTemplateList(); BindTemplateInfo(); int isSuccess = 0; if (!string.IsNullOrEmpty(Request["IsSuccess"])) { isSuccess = int.Parse(Request["IsSuccess"]); } if (isSuccess > 0) { InformationObject obj = new InformationObject(); obj.Message = Request["Message"]; infoList.Add(obj); DisplayInformations(infoList, InformationIcoType.Information); } else if (isSuccess < 0) { InformationObject obj = new InformationObject(); obj.Message = Request["Message"]; infoList.Add(obj); DisplayInformations(infoList, InformationIcoType.Error); } } } }
protected void Page_Load(object sender, EventArgs e) { //QueryResult resultPage = Context.Handler as QueryResult; //if (resultPage != null) //{ // Response.Write(resultPage.DataSource_Shop.Title); //} List <InformationObject> list = new List <InformationObject>(); InformationObject obj = new InformationObject(); obj.Message = "您尚未登录,不能执行整店导入的操作。"; obj.CssName = "Information"; obj.AddLink("<span>登录帐号</span>", "~/Login.aspx"); list.Add(obj); ucInformationBox_Tip.SetInformationList(list); }
private void SetInformationObject() { InformationObject informationObject; MarkerIdObject markerIdObject = MarkerIdObject.GetInstance(); foreach (GameObject objectSelect in listObjectSelecionado) { informationObject = new InformationObject(); informationObject.Name = objectSelect.name; informationObject.ImagePathMarkerLess = PropertiesModel.PathObjectDrawing; informationObject.IdMarker = markerIdObject.getIdMarker(objectSelect.name); informationObject.Position = objectSelect.transform.position; informationObject.Rotation = objectSelect.transform.rotation; informationObject.Scale = objectSelect.transform.localScale; informationObjectList.ListInformationObject.Add(informationObject); } }
private static void TestIntegrate() { ConnectionParameters para = new ConnectionParameters(); para.LinkAddress = 1; para.SizeOfCA = 2; LinkControlUp lc = new LinkControlUp(); lc.ACD = false; lc.DFC = false; lc.FuncCode = LinkFunctionCodeUp.UserData; T102Frame frame = new T102Frame(lc, para); ASDU asdu = new ASDU(CauseOfTransmission.REQUEST, false, false, 1, RecordAddress.Total, false); CP40Time2b t = new CP40Time2b(new DateTime(2007, 8, 18, 6, 21, 0)); OperationalITWith3Byte oit = new OperationalITWith3Byte(6, 0x030201, false, false, false, 0x12); asdu.AddInformationObject(oit); asdu.Encode(frame, para); //最后编码个时间进去 frame.AppendBytes(t.GetEncodedValue()); frame.PrepareToSend(); byte[] aa = frame.GetBuffer(); int length = aa[1]; byte linkControl = aa[4]; int linkAddr = aa[5] + aa[6] * 0x100; ASDU na = new ASDU(para, aa, length + 4 + 2); InformationObject io = na.GetElement(0); //todo: 没有对最后时间报文的解析内容,还没想到怎么样一个结构去解析之后考虑下。。。 }
private static void TestSinglePoint() { ConnectionParameters para = new ConnectionParameters(); para.LinkAddress = 1; para.SizeOfCA = 2; LinkControlUp lc = new LinkControlUp(); lc.ACD = true; lc.DFC = false; lc.FuncCode = LinkFunctionCodeUp.UserData; T102Frame frame = new T102Frame(lc, para); ASDU asdu = new ASDU(TypeID.M_SP_TA_2, CauseOfTransmission.SPONTANEOUS, false, false, 1, RecordAddress.Total, false); CP56Time2b tt = new CP56Time2b(new DateTime(2007, 8, 18, 6, 21, 1, 520)); SinglePointInformation sp = new SinglePointInformation(0, true, 0, tt); asdu.AddInformationObject(sp); asdu.Encode(frame, para); frame.PrepareToSend(); byte[] aa = frame.GetBuffer(); int length = aa[1]; byte linkControl = aa[4]; int linkAddr = aa[5] + aa[6] * 0x100; ASDU na = new ASDU(para, aa, length + 4 + 2); InformationObject io = na.GetElement(0); }
public InformationObject GetUnLoginInformation() { InformationObject obj = new InformationObject(); obj.CssName = "Information"; obj.Message = "您目前没有登录系统,或者登录已经过期。"; obj.AddLink("点击这里登录系统", "~/Authorizes/UnLogin.aspx?ReturnUrl=" + Server.UrlEncode(Request.Url.AbsoluteUri)); return obj; }
BuildInfoObj( Int32 asdu, Int32 addr, Double value, Boolean sbo = false, Int32 cmdqualif = 0, QualityDescriptor quality = null, CP56Time2a time_tag = null, Double kconv1 = 1, Double kconv2 = 0, Boolean transient = false ) { InformationObject sc = null; if (time_tag == null) { time_tag = new CP56Time2a(DateTime.Now); } else { // has time tag, so change ASDU if necessary to embed a timetag var maptowithcp56time = new Dictionary <TypeID, TypeID>(); maptowithcp56time.Add(TypeID.M_SP_NA_1, TypeID.M_SP_TB_1); maptowithcp56time.Add(TypeID.M_DP_NA_1, TypeID.M_DP_TB_1); maptowithcp56time.Add(TypeID.M_ST_NA_1, TypeID.M_ST_TB_1); maptowithcp56time.Add(TypeID.M_BO_NA_1, TypeID.M_BO_TB_1); maptowithcp56time.Add(TypeID.M_ME_NA_1, TypeID.M_ME_TD_1); maptowithcp56time.Add(TypeID.M_ME_NB_1, TypeID.M_ME_TE_1); maptowithcp56time.Add(TypeID.M_ME_NC_1, TypeID.M_ME_TF_1); maptowithcp56time.Add(TypeID.M_IT_NA_1, TypeID.M_IT_TB_1); if (maptowithcp56time.TryGetValue((TypeID)asdu, out var newasdu)) { asdu = (Int32)newasdu; } } Boolean bval; Int32 ival; UInt32 uival; switch ((TypeID)asdu) { case TypeID.M_SP_NA_1: // 1 bval = value != 0 ? true : false; if (kconv1 == -1) { bval = !bval; } sc = new SinglePointInformation(addr, bval, quality); break; case TypeID.M_SP_TB_1: // 30 bval = value != 0 ? true : false; if (kconv1 == -1) { bval = !bval; } sc = new SinglePointWithCP56Time2a(addr, bval, quality, time_tag ); break; case TypeID.M_DP_NA_1: // 3 if (transient) { sc = new DoublePointInformation(addr, DoublePointValue.INTERMEDIATE, quality); } else if (kconv1 == -1) { sc = new DoublePointInformation(addr, value != 0 ? DoublePointValue.OFF : DoublePointValue.ON, quality); } else { sc = new DoublePointInformation(addr, value != 0 ? DoublePointValue.ON : DoublePointValue.OFF, quality); } break; case TypeID.M_DP_TB_1: // 31 if (transient) { sc = new DoublePointWithCP56Time2a(addr, DoublePointValue.INTERMEDIATE, quality, time_tag); } else if (kconv1 == -1) { sc = new DoublePointWithCP56Time2a(addr, value != 0 ? DoublePointValue.OFF : DoublePointValue.ON, quality, time_tag); } else { sc = new DoublePointWithCP56Time2a(addr, value != 0 ? DoublePointValue.ON : DoublePointValue.OFF, quality, time_tag); } break; case TypeID.M_ST_NA_1: // 5 value = value * kconv1 + kconv2; if (value > 63) { value = 63; quality.Overflow = true; } else if (value < -64) { value = -64; quality.Overflow = true; } sc = new StepPositionInformation(addr, System.Convert.ToInt16(value), transient, quality); break; case TypeID.M_ST_TB_1: // 32 value = value * kconv1 + kconv2; if (value > 63) { value = 63; quality.Overflow = true; } else if (value < -64) { value = -64; quality.Overflow = true; } sc = new StepPositionWithCP56Time2a(addr, System.Convert.ToInt16(value), transient, quality, time_tag); break; case TypeID.M_ME_NA_1: // 9 value = value * kconv1 + kconv2; if (value > 32767) { value = 32767; quality.Overflow = true; } else if (value < -32768) { value = -32768; quality.Overflow = true; } sc = new MeasuredValueNormalized(addr, System.Convert.ToInt16(value), quality); break; case TypeID.M_ME_ND_1: // 21 value = value * kconv1 + kconv2; if (value > 32767) { value = 32767; quality.Overflow = true; } else if (value < -32768) { value = -32768; quality.Overflow = true; } sc = new MeasuredValueNormalizedWithoutQuality(addr, System.Convert.ToInt16(value)); break; case TypeID.M_ME_TD_1: // 34 value = value * kconv1 + kconv2; if (value > 32767) { value = 32767; quality.Overflow = true; } else if (value < -32768) { value = -32768; quality.Overflow = true; } sc = new MeasuredValueNormalizedWithCP56Time2a(addr, System.Convert.ToInt16(value), quality, time_tag); break; case TypeID.M_ME_NB_1: // 11 value = value * kconv1 + kconv2; if (value > 32767) { value = 32767; quality.Overflow = true; } else if (value < -32768) { value = -32768; quality.Overflow = true; } sc = new MeasuredValueScaled(addr, System.Convert.ToInt16(value), quality); break; case TypeID.M_ME_TE_1: // 35 value = value * kconv1 + kconv2; if (value > 32767) { value = 32767; quality.Overflow = true; } else if (value < -32768) { value = -32768; quality.Overflow = true; } sc = new MeasuredValueScaledWithCP56Time2a(addr, System.Convert.ToInt16(value), quality, time_tag); break; case TypeID.M_ME_NC_1: // 13 value = value * kconv1 + kconv2; sc = new MeasuredValueShort(addr, System.Convert.ToSingle(value), quality); break; case TypeID.M_ME_TF_1: // 36 value = value * kconv1 + kconv2; sc = new MeasuredValueShortWithCP56Time2a(addr, System.Convert.ToSingle(value), quality, time_tag); break; case TypeID.M_IT_NA_1: //15 break; case TypeID.M_IT_TB_1: // 37 break; case TypeID.M_PS_NA_1: // 20 Log(" TODO Packed single point information with status change detection! "); break; case TypeID.M_EP_TD_1: // 38 break; case TypeID.M_EP_TE_1: // 39 break; case TypeID.M_EP_TF_1: // 40 break; case TypeID.M_BO_NA_1: // 7 uival = System.Convert.ToUInt32(value); if (kconv1 == -1) { uival = ~uival; } sc = new Bitstring32(addr, uival, quality); break; case TypeID.M_BO_TB_1: // 33 uival = System.Convert.ToUInt32(value); if (kconv1 == -1) { uival = ~uival; } sc = new Bitstring32WithCP56Time2a(addr, uival, quality, time_tag); break; case TypeID.C_SC_NA_1: // 45 bval = value != 0 ? true : false; if (kconv1 == -1) { bval = !bval; } sc = new SingleCommand(addr, bval, sbo, cmdqualif); break; case TypeID.C_DC_NA_1: // 46 if (kconv1 == -1) { ival = value != 0 ? System.Convert.ToInt32(DoublePointValue.OFF) : System.Convert.ToInt32(DoublePointValue.ON); } else { ival = value != 0 ? System.Convert.ToInt32(DoublePointValue.ON) : System.Convert.ToInt32(DoublePointValue.OFF); } sc = new DoubleCommand(addr, ival, sbo, cmdqualif); break; case TypeID.C_RC_NA_1: // 47 if (kconv1 == -1) { sc = new StepCommand(addr, value >= 1 ? StepCommandValue.LOWER : StepCommandValue.HIGHER, sbo, cmdqualif); } else { sc = new StepCommand(addr, value >= 1 ? StepCommandValue.HIGHER : StepCommandValue.LOWER, sbo, cmdqualif); } break; case TypeID.C_SE_NA_1: // 48 value = value * kconv1 + kconv2; if (value > 32767) { value = 32767; } else if (value < -32768) { value = -32768; } sc = new SetpointCommandNormalized(addr, System.Convert.ToInt16(value), new SetpointCommandQualifier(sbo, 0)); break; case TypeID.C_SE_NB_1: // 49 value = value * kconv1 + kconv2; if (value > 32767) { value = 32767; } else if (value < -32768) { value = -32768; } sc = new SetpointCommandScaled(addr, new ScaledValue(System.Convert.ToInt16(value)), new SetpointCommandQualifier(sbo, 0)); break; case TypeID.C_SE_NC_1: // 50 value = value * kconv1 + kconv2; sc = new SetpointCommandShort(addr, System.Convert.ToSingle(value), new SetpointCommandQualifier(sbo, 0)); break; case TypeID.C_BO_NA_1: // 51 uival = System.Convert.ToUInt32(value); if (kconv1 == -1) { uival = ~uival; } sc = new Bitstring32Command(addr, uival); break; case TypeID.C_SC_TA_1: // 58 bval = value != 0 ? true : false; if (kconv1 == -1) { bval = !bval; } sc = new SingleCommandWithCP56Time2a(addr, bval, sbo, cmdqualif, time_tag); break; case TypeID.C_DC_TA_1: // 59 if (kconv1 == -1) { ival = value != 0 ? System.Convert.ToInt32(DoublePointValue.OFF) : System.Convert.ToInt32(DoublePointValue.ON); } else { ival = value != 0 ? System.Convert.ToInt32(DoublePointValue.ON) : System.Convert.ToInt32(DoublePointValue.OFF); } sc = new DoubleCommandWithCP56Time2a(addr, ival, sbo, cmdqualif, time_tag); break; case TypeID.C_RC_TA_1: // 60 if (kconv1 == -1) { sc = new StepCommandWithCP56Time2a(addr, value >= 1 ? StepCommandValue.LOWER : StepCommandValue.HIGHER, sbo, cmdqualif, time_tag); } else { sc = new StepCommandWithCP56Time2a(addr, value >= 1 ? StepCommandValue.HIGHER : StepCommandValue.LOWER, sbo, cmdqualif, time_tag); } break; case TypeID.C_SE_TA_1: // 61 value = value * kconv1 + kconv2; if (value > 32767) { value = 32767; } else if (value < -32768) { value = -32768; } sc = new SetpointCommandNormalizedWithCP56Time2a(addr, System.Convert.ToInt16(value), new SetpointCommandQualifier(sbo, 0), time_tag); break; case TypeID.C_SE_TB_1: // 62 value = value * kconv1 + kconv2; if (value > 32767) { value = 32767; } else if (value < -32768) { value = -32768; } sc = new SetpointCommandScaledWithCP56Time2a(addr, new ScaledValue(System.Convert.ToInt16(value)), new SetpointCommandQualifier(sbo, 0), time_tag); break; case TypeID.C_SE_TC_1: // 63 value = value * kconv1 + kconv2; sc = new SetpointCommandShortWithCP56Time2a(addr, System.Convert.ToSingle(value), new SetpointCommandQualifier(sbo, 0), time_tag); break; case TypeID.C_BO_TA_1: // 64 uival = System.Convert.ToUInt32(value); if (kconv1 == -1) { uival = ~uival; } sc = new Bitstring32CommandWithCP56Time2a(addr, uival, time_tag); break; case TypeID.C_IC_NA_1: // 100 sc = new InterrogationCommand(0, System.Convert.ToByte(cmdqualif)); break; case TypeID.C_CI_NA_1: // 101 sc = new CounterInterrogationCommand(0, System.Convert.ToByte(cmdqualif)); break; case TypeID.C_RD_NA_1: // 102 sc = new ReadCommand(addr); break; case TypeID.C_CS_NA_1: // 103 sc = new ClockSynchronizationCommand(0, time_tag); break; case TypeID.C_RP_NA_1: // 105 sc = new ResetProcessCommand(addr, System.Convert.ToByte(cmdqualif)); break; case TypeID.C_TS_TA_1: // 107 sc = new TestCommandWithCP56Time2a(System .Convert .ToUInt16(value), time_tag); break; case TypeID.P_ME_NA_1: // 110 value = value * kconv1 + kconv2; if (value > 32767) { value = 32767; } else if (value < -32768) { value = -32768; } sc = new ParameterNormalizedValue(System .Convert .ToInt32(addr), System.Convert.ToInt32(value), System.Convert.ToByte(cmdqualif)); break; case TypeID.P_ME_NB_1: // 111 value = value * kconv1 + kconv2; if (value > 32767) { value = 32767; } else if (value < -32768) { value = -32768; } sc = new ParameterScaledValue(addr, new ScaledValue(System.Convert.ToInt16(value)), System.Convert.ToByte(cmdqualif)); break; case TypeID.P_ME_NC_1: // 112 value = value * kconv1 + kconv2; sc = new ParameterFloatValue(addr, System.Convert.ToSingle(value), System.Convert.ToByte(cmdqualif)); break; case TypeID.P_AC_NA_1: // 113 sc = new ParameterActivation(System.Convert.ToInt32(addr), System.Convert.ToByte(cmdqualif)); break; default: break; } return(sc); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { List<InformationObject> infoList = new List<InformationObject>(); if (CurrentUser == null) { infoList.Add(GetUnLoginInformation()); } if (string.IsNullOrEmpty(CurrentSessionKey) || string.IsNullOrEmpty(CurrentSellerNick)) { infoList.Add(GetUnAuthorizeInformation()); } if (infoList.Count > 0) { DisplayInformations(infoList); lbtnSave.Enabled = false; lbtnPreview.Enabled = false; } else { BindWaittingTemplateList(); BindTemplateList(); BindTemplateInfo(); int isSuccess = 0; if (!string.IsNullOrEmpty(Request["IsSuccess"])) { isSuccess = int.Parse(Request["IsSuccess"]); } if (isSuccess > 0) { InformationObject obj = new InformationObject(); obj.Message = Request["Message"]; infoList.Add(obj); DisplayInformations(infoList, InformationIcoType.Information); } else if (isSuccess < 0) { InformationObject obj = new InformationObject(); obj.Message = Request["Message"]; infoList.Add(obj); DisplayInformations(infoList, InformationIcoType.Error); } } } }
// This process watches (via change stream) for commands inserted to a commands collection // When the command is considered valid it is forwarded to the RTU static async void ProcessMongoCmd(JSONSCADAConfig jsConfig) { do { try { var Client = ConnectMongoClient(jsConfig); var DB = Client.GetDatabase(jsConfig.mongoDatabaseName); var collection = DB .GetCollection <rtCommand>(CommandsQueueCollectionName); bool isMongoLive = DB .RunCommandAsync((Command <BsonDocument>) "{ping:1}") .Wait(1000); if (!isMongoLive) { throw new Exception("Error on connection " + jsConfig.mongoConnectionString); } Log("MongoDB CMD CS - Start listening for commands via changestream..."); var filter = "{ operationType: 'insert' }"; var pipeline = new EmptyPipelineDefinition <ChangeStreamDocument <rtCommand > >().Match(filter); using (var cursor = await collection.WatchAsync(pipeline)) { await cursor .ForEachAsync(async change => { if (!Active) { return; } // process change event, only process inserts if ( change.OperationType == ChangeStreamOperationType.Insert ) { // consider only commands for this driver { Log("MongoDB CMD CS - Looking for connection " + change .FullDocument .protocolSourceConnectionNumber + "..."); var found = false; foreach (IEC10X_connection srv in IEC10Xconns ) { if ( srv.protocolConnectionNumber == change .FullDocument .protocolSourceConnectionNumber ) { found = true; if ( srv.connection.IsRunning && srv.commandsEnabled ) { InformationObject sc = BuildInfoObj(System .Convert .ToInt32(change .FullDocument .protocolSourceASDU), System .Convert .ToInt32(change .FullDocument .protocolSourceObjectAddress), System .Convert .ToDouble(change .FullDocument .value), System .Convert .ToBoolean(change .FullDocument .protocolSourceCommandUseSBO), System .Convert .ToByte(change .FullDocument .protocolSourceCommandDuration)); if (sc != null) { if ( DateTime .Now .ToLocalTime() .Subtract(change .FullDocument .timeTag .ToLocalTime( )) .Seconds < 10 ) { // execute srv .connection .SendControlCommand(CauseOfTransmission .ACTIVATION, System .Convert .ToInt32(change .FullDocument .protocolSourceCommonAddress), sc); Log("MongoDB CMD CS - " + srv.name + " - " + sc.ToString() + " OA " + change .FullDocument .protocolSourceObjectAddress + " Delivered"); // update as delivered var filter = new BsonDocument(new BsonDocument("_id", change .FullDocument .id)); var update = new BsonDocument("$set", new BsonDocument("delivered", true)); var result = await collection .UpdateOneAsync(filter, update); } else { // update as expired Log("MongoDB CMD CS - " + srv.name + " - " + sc.ToString() + " OA " + change .FullDocument .protocolSourceObjectAddress + " value " + change .FullDocument .value + " Expired"); var filter = new BsonDocument(new BsonDocument("_id", change .FullDocument .id)); var update = new BsonDocument("$set", new BsonDocument("cancelReason", "expired")); var result = await collection .UpdateOneAsync(filter, update); } } else { // update as canceled (asdu not implemented) Log("MongoDB CMD CS - " + srv.name + " - " + " OA " + change .FullDocument .protocolSourceObjectAddress + " value " + change .FullDocument .value + " ASDU Not Implemented"); var filter = new BsonDocument(new BsonDocument("_id", change .FullDocument .id)); var update = new BsonDocument("$set", new BsonDocument("cancelReason", "asdu not implemented")); var result = await collection .UpdateOneAsync(filter, update); } } else { // update as canceled (not connected) Log("MongoDB CMD CS - " + srv.name + " OA " + change .FullDocument .protocolSourceObjectAddress + " value " + change.FullDocument.value + ( srv.commandsEnabled ? " Not Connected" : " Commands Disabled" )); var filter = new BsonDocument(new BsonDocument("_id", change .FullDocument .id)); var update = new BsonDocument("$set", new BsonDocument("cancelReason", ( srv .commandsEnabled ? "not connected" : "commands disabled" ))); var result = await collection .UpdateOneAsync(filter, update); } break; } } if (!found) { // update as canceled command (not found) Log("MongoDB CMD CS - " + change .FullDocument .protocolSourceConnectionNumber .ToString() + " OA " + change .FullDocument .protocolSourceObjectAddress + " value " + change.FullDocument.value + " Not Found"); var filter = new BsonDocument(new BsonDocument("_id", change .FullDocument .id)); var update = new BsonDocument("$set", new BsonDocument("cancelReason", "connection not found")); var result = await collection .UpdateOneAsync(filter, update); } } } }); } } catch (Exception e) { Log("Exception MongoCmd"); Log(e); Log(e .ToString() .Substring(0, e.ToString().IndexOf(Environment.NewLine))); System.Threading.Thread.Sleep(3000); } }while (true); }
public InformationObject GetUnAuthorizeInformation() { InformationObject obj = new InformationObject(); obj.CssName = "Information"; obj.Message = "我们没有接收到您对我们网站的淘宝网操作授权,或者授权码已经过期。"; obj.AddLink("点击这里获取淘宝授权", "~/Authorizes/UnAuthorize.aspx?ReturnUrl=" + Server.UrlEncode(Request.Url.AbsoluteUri)); string a = "<img src='" + GetRootURI() + "/Images/Icos/contacts.gif' title='什么是淘宝网授权码' />"; obj.AddLink(a, "~/Authorizes/UnLogin.aspx"); return obj; }
public void SetSuccessInformation(string message) { List<InformationObject> list = new List<InformationObject>(); InformationObject obj = new InformationObject(); obj.CssName = "Information"; obj.Message = message; list.Add(obj); DisplayInformations(list, InformationIcoType.Information); }
private void DisplayImportDetail(string groupId) { ImportFacade facade = new ImportFacade(); ImportGroupInfo group = facade.GetImportGroup(groupId); if (group != null && group.OperatorUserId == CurrentUser.Id) { if (!string.IsNullOrEmpty(group.ImportFormShopImageUrl)) { imgShop.Visible = true; imgShop.ImageUrl = string.Format(ShopLogUrlFormat, group.ImportFormShopImageUrl); } else { imgShop.Visible = false; } lblNick.Text = group.ImportFormSellerNick; lblShopTitle.Text = group.ImportFormShopTitle; lblImportCount.Text = group.TotalCount.ToString(); if (group.ImportState == ImportorEnumerations.ImportState.Waitting) { lblState.Text = "系统正在准备要导入的数据..."; lblSummary.Text = "导入操作完成以后统计数据,请稍等..."; hlnkRefresh.NavigateUrl = "ImportShop4.aspx?GroupId=" + groupId; } else if (group.ImportState == ImportorEnumerations.ImportState.Importing) { lblState.Text = "正在导入数据..."; lblSummary.Text = "导入操作完成以后统计数据,请稍等..."; hlnkRefresh.NavigateUrl = "ImportShop4.aspx?GroupId=" + groupId; } else { string result; if (group.ImportResult == ImportorEnumerations.ImportGroupResult.Pending) { result = "未统计"; } else if (group.ImportResult == ImportorEnumerations.ImportGroupResult.AllSuccess) { result = "全部成功"; } else if (group.ImportResult == ImportorEnumerations.ImportGroupResult.ParttenSuccess) { result = "部分成功"; } else { result = "失败"; } lblState.Text = string.Format("导入操作已结束({0})", result); lblSummary.Text = string.Format("成功:{0}; 失败:{1};", group.SuccessCount, group.FailCount); hlnkRefresh.Visible = false; } } else { imgShop.Visible = false; List<InformationObject> infoList = new List<InformationObject>(); InformationObject obj1 = new InformationObject(); obj1.CssName = "Information"; obj1.Message = "发生错误,有可能是下列原因之一导致的:"; infoList.Add(obj1); InformationObject obj2 = new InformationObject(); obj2.CssName = "ErrorMsg"; obj2.Message = "1.你所查看的导入记录不存在"; infoList.Add(obj2); InformationObject obj3 = new InformationObject(); obj3.CssName = "ErrorMsg"; obj3.Message = "2.你所查看的导入记录是其他人的"; infoList.Add(obj3); DisplayInformations(infoList, InformationIcoType.Warning); } }
/// <inheritdoc/> public virtual void Report() { List <string> str = new List <string>(); str.Add($"Running SeleniumPerfXML Version: {FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ProductVersion}"); foreach (InformationObject.EnvVar var in Enum.GetValues(typeof(InformationObject.EnvVar))) { str.Add($"{var} = {InformationObject.GetEnvironmentVariable(var)}"); } str.Add("-----------------------"); foreach (ITestSetStatus testSetStatus in this.TestSetStatuses) { str.Add("Name: " + testSetStatus.Name); str.Add("RunSuccessful:" + testSetStatus.RunSuccessful.ToString()); str.Add("StartTime:" + testSetStatus.StartTime.ToString()); str.Add("EndTime:" + testSetStatus.EndTime.ToString()); str.Add("Description:" + testSetStatus.Description); str.Add("ErrorStack:" + testSetStatus.ErrorStack); str.Add("FriendlyErrorMessage:" + testSetStatus.FriendlyErrorMessage); str.Add("Expected:" + testSetStatus.Expected); str.Add("Actual:" + testSetStatus.Actual); } foreach (ITestCaseStatus testCaseStatus in this.TestCaseStatuses) { str.Add(this.Tab(1) + "Name:" + testCaseStatus.Name); str.Add(this.Tab(1) + "TestCaseNumber:" + testCaseStatus.TestCaseNumber.ToString()); str.Add(this.Tab(1) + "RunSuccessful:" + testCaseStatus.RunSuccessful.ToString()); str.Add(this.Tab(1) + "StartTime:" + testCaseStatus.StartTime.ToString()); str.Add(this.Tab(1) + "EndTime:" + testCaseStatus.EndTime.ToString()); str.Add(this.Tab(1) + "Description:" + testCaseStatus.Description); str.Add(this.Tab(1) + "ErrorStack:" + testCaseStatus.ErrorStack); str.Add(this.Tab(1) + "FriendlyErrorMessage:" + testCaseStatus.FriendlyErrorMessage); str.Add(this.Tab(1) + "Expected:" + testCaseStatus.Expected); str.Add(this.Tab(1) + "Actual:" + testCaseStatus.Actual); if (this.TestCaseToTestSteps.ContainsKey(testCaseStatus)) { // log the test steps. foreach (ITestStepStatus testStepStatus in this.TestCaseToTestSteps[testCaseStatus]) { str.Add(this.Tab(2) + "Name:" + testStepStatus.Name); str.Add(this.Tab(2) + "TestStepNumber:" + testStepStatus.TestStepNumber.ToString()); str.Add(this.Tab(2) + "RunSuccessful:" + testStepStatus.RunSuccessful.ToString()); str.Add(this.Tab(2) + "StartTime:" + testStepStatus.StartTime.ToString()); str.Add(this.Tab(2) + "EndTime:" + testStepStatus.EndTime.ToString()); str.Add(this.Tab(2) + "Description:" + testStepStatus.Description); str.Add(this.Tab(2) + "ErrorStack:" + testStepStatus.ErrorStack); str.Add(this.Tab(2) + "FriendlyErrorMessage:" + testStepStatus.FriendlyErrorMessage); str.Add(this.Tab(2) + "Expected:" + testStepStatus.Expected); str.Add(this.Tab(2) + "Actual:" + testStepStatus.Actual); str.Add(this.Tab(2) + "-----------------------"); } } } str.Add(string.Empty); using (StreamWriter file = new StreamWriter($"{this.SaveFileLocation}", true)) { foreach (string line in str) { file.WriteLine(line); } } }
AsduReceivedHandler(object parameter, IMasterConnection connection, ASDU asdu) { var srv = IEC10Xconns[(int)parameter]; var conNameStr = srv.name + " - "; Log(conNameStr + asdu.ToString(), LogLevelDetailed); try { if (IsMongoLive) { var DB = Client.GetDatabase(JSConfig.mongoDatabaseName); var collection_rtd = DB .GetCollection <rtData>(RealtimeDataCollectionName); Double val = 0; Int32 objaddr = 0; Int32 dur = 0; Boolean isselect = false; Boolean cmdhastime = false; DateTime cmdtime = new DateTime(); Double dstkconv1 = 1; Double dstkconv2 = 0; Boolean dstsbo = false; Int32 dstdur = 0; Double srcval = 0; Int32 srcobjaddr = 0; Int32 srcconn = 0; Boolean srcsbo = false; Int32 srcdur = 0; Int32 srcasdu = 0; Int32 srcca = 0; Int32 srcpointkey = 0; String srctag = ""; Double srckconv1 = 1; Double srckconv2 = 0; switch (asdu.TypeId) { case TypeID.C_SC_NA_1: // 45 { var cmd = (SingleCommand)asdu.GetElement(0); isselect = cmd.Select; dur = cmd.QU; objaddr = cmd.ObjectAddress; val = System.Convert.ToDouble(cmd.State); Log(conNameStr + " " + cmd.ToString() + " Obj Address " + objaddr, LogLevelBasic); } break; case TypeID.C_SC_TA_1: // 58 { var cmd = (SingleCommandWithCP56Time2a)asdu.GetElement(0); isselect = cmd.Select; dur = cmd.QU; objaddr = cmd.ObjectAddress; val = System.Convert.ToDouble(cmd.State); cmdtime = cmd.Timestamp.GetDateTime(); cmdhastime = true; Log(conNameStr + " " + cmd.ToString() + " Obj Address " + objaddr, LogLevelBasic); } break; case TypeID.C_DC_NA_1: // 46 { var cmd = (DoubleCommand)asdu.GetElement(0); isselect = cmd.Select; dur = cmd.QU; objaddr = cmd.ObjectAddress; if (cmd.State != DoubleCommand.ON && cmd.State != DoubleCommand.OFF) { connection.SendACT_CON(asdu, true); // activation confirm negative Log(conNameStr + " Invalid double state command " + cmd.State, LogLevelBasic); LastPointKeySelectedOk = 0; return(true); } val = cmd.State == DoubleCommand.ON ? 1 : 0; Log(conNameStr + " " + cmd.ToString() + " Obj Address " + objaddr, LogLevelBasic); } break; case TypeID.C_DC_TA_1: // 59 { var cmd = (DoubleCommandWithCP56Time2a)asdu.GetElement(0); isselect = cmd.Select; dur = cmd.QU; objaddr = cmd.ObjectAddress; if (cmd.State != DoubleCommand.ON && cmd.State != DoubleCommand.OFF) { connection.SendACT_CON(asdu, true); // activation confirm negative Log(conNameStr + " Invalid double state command " + cmd.State, LogLevelBasic); LastPointKeySelectedOk = 0; return(true); } cmdtime = cmd.Timestamp.GetDateTime(); cmdhastime = true; val = cmd.State == DoubleCommand.ON ? 1 : 0; Log(conNameStr + " " + cmd.ToString() + " Obj Address " + objaddr, LogLevelBasic); } break; case TypeID.C_RC_NA_1: // 47 { var cmd = (StepCommand)asdu.GetElement(0); isselect = cmd.Select; dur = cmd.QU; objaddr = cmd.ObjectAddress; if (cmd.State != StepCommandValue.HIGHER && cmd.State != StepCommandValue.LOWER) { connection.SendACT_CON(asdu, true); // activation confirm negative Log(conNameStr + " Invalid step state command " + cmd.State, LogLevelBasic); LastPointKeySelectedOk = 0; return(true); } val = cmd.State == StepCommandValue.HIGHER ? 1 : 0; Log(conNameStr + " " + cmd.ToString() + " Obj Address " + objaddr, LogLevelBasic); } break; case TypeID.C_RC_TA_1: // 60 { var cmd = (StepCommandWithCP56Time2a)asdu.GetElement(0); isselect = cmd.Select; dur = cmd.QU; objaddr = cmd.ObjectAddress; if (cmd.State != StepCommandValue.HIGHER && cmd.State != StepCommandValue.LOWER) { connection.SendACT_CON(asdu, true); // activation confirm negative Log(conNameStr + " Invalid step state command " + cmd.State, LogLevelBasic); LastPointKeySelectedOk = 0; return(true); } cmdtime = cmd.Timestamp.GetDateTime(); cmdhastime = true; val = cmd.State == StepCommandValue.HIGHER ? 1 : 0; Log(conNameStr + " " + cmd.ToString() + " Obj Address " + objaddr, LogLevelBasic); } break; case TypeID.C_SE_NA_1: // 48 { var cmd = (SetpointCommandNormalized)asdu.GetElement(0); isselect = cmd.QOS.Select; dur = cmd.QOS.QL; objaddr = cmd.ObjectAddress; val = cmd.NormalizedValue; Log(conNameStr + " " + cmd.ToString() + " Obj Address " + objaddr, LogLevelBasic); } break; case TypeID.C_SE_TA_1: // 61 { var cmd = (SetpointCommandNormalizedWithCP56Time2a)asdu.GetElement(0); isselect = cmd.QOS.Select; dur = cmd.QOS.QL; objaddr = cmd.ObjectAddress; cmdtime = cmd.Timestamp.GetDateTime(); cmdhastime = true; val = cmd.NormalizedValue; Log(conNameStr + " " + cmd.ToString() + " Obj Address " + objaddr, LogLevelBasic); } break; case TypeID.C_SE_NB_1: // 49 { var cmd = (SetpointCommandScaled)asdu.GetElement(0); isselect = cmd.QOS.Select; dur = cmd.QOS.QL; objaddr = cmd.ObjectAddress; val = System.Convert.ToDouble(cmd.ScaledValue); Log(conNameStr + " " + cmd.ToString() + " Obj Address " + objaddr, LogLevelBasic); } break; case TypeID.C_SE_TB_1: // 62 { var cmd = (SetpointCommandScaledWithCP56Time2a)asdu.GetElement(0); isselect = cmd.QOS.Select; dur = cmd.QOS.QL; objaddr = cmd.ObjectAddress; cmdtime = cmd.Timestamp.GetDateTime(); cmdhastime = true; val = System.Convert.ToDouble(cmd.ScaledValue); Log(conNameStr + " " + cmd.ToString() + " Obj Address " + objaddr, LogLevelBasic); } break; case TypeID.C_SE_NC_1: // 50 { var cmd = (SetpointCommandShort)asdu.GetElement(0); isselect = cmd.QOS.Select; dur = cmd.QOS.QL; objaddr = cmd.ObjectAddress; val = System.Convert.ToDouble(cmd.Value); Log(conNameStr + " " + cmd.ToString() + " Obj Address " + objaddr, LogLevelBasic); } break; case TypeID.C_SE_TC_1: // 63 { var cmd = (SetpointCommandShortWithCP56Time2a)asdu.GetElement(0); isselect = cmd.QOS.Select; dur = cmd.QOS.QL; objaddr = cmd.ObjectAddress; cmdtime = cmd.Timestamp.GetDateTime(); cmdhastime = true; val = System.Convert.ToDouble(cmd.Value); Log(conNameStr + " " + cmd.ToString() + " Obj Address " + objaddr, LogLevelBasic); } break; case TypeID.C_BO_NA_1: // 51 { var cmd = (Bitstring32Command)asdu.GetElement(0); isselect = false; dur = 0; objaddr = cmd.ObjectAddress; val = System.Convert.ToDouble(cmd.Value); Log(conNameStr + " " + cmd.ToString() + " Obj Address " + objaddr, LogLevelBasic); } break; case TypeID.C_BO_TA_1: // 64 { var cmd = (Bitstring32CommandWithCP56Time2a)asdu.GetElement(0); isselect = false; dur = 0; objaddr = cmd.ObjectAddress; cmdtime = cmd.Timestamp.GetDateTime(); cmdhastime = true; val = System.Convert.ToDouble(cmd.Value); Log(conNameStr + " " + cmd.ToString() + " Obj Address " + objaddr, LogLevelBasic); } break; case TypeID.P_ME_NA_1: // 110 { var cmd = (ParameterNormalizedValue)asdu.GetElement(0); isselect = false; dur = cmd.QPM; objaddr = cmd.ObjectAddress; val = System.Convert.ToDouble(cmd.NormalizedValue); Log(conNameStr + " " + cmd.ToString() + " Obj Address " + objaddr, LogLevelBasic); } break; case TypeID.P_ME_NB_1: // 111 { var cmd = (ParameterScaledValue)asdu.GetElement(0); isselect = false; dur = cmd.QPM; objaddr = cmd.ObjectAddress; val = System.Convert.ToDouble(cmd.ScaledValue); Log(conNameStr + " " + cmd.ToString() + " Obj Address " + objaddr, LogLevelBasic); } break; case TypeID.P_ME_NC_1: // 112 { var cmd = (ParameterFloatValue)asdu.GetElement(0); isselect = false; dur = cmd.QPM; objaddr = cmd.ObjectAddress; val = System.Convert.ToDouble(cmd.Value); Log(conNameStr + " " + cmd.ToString() + " Obj Address " + objaddr, LogLevelBasic); } break; case TypeID.P_AC_NA_1: // 113 { var cmd = (ParameterActivation)asdu.GetElement(0); isselect = false; dur = cmd.QPA; objaddr = cmd.ObjectAddress; val = 0; Log(conNameStr + " " + cmd.ToString() + " Obj Address " + objaddr, LogLevelBasic); } break; case TypeID.C_RP_NA_1: // 105 reset process { var cmd = (ResetProcessCommand)asdu.GetElement(0); isselect = false; dur = cmd.QRP; objaddr = cmd.ObjectAddress; val = 0; Log(conNameStr + " " + cmd.ToString() + " Obj Address " + objaddr, LogLevelBasic); } break; // case TypeID.C_IC_NA_1: // 100 already managed by interrogation handler function case TypeID.C_TS_NA_1: // 104 test command { Log(conNameStr + " Test command C_TS_NA_1", LogLevelDetailed); connection.SendACT_CON(asdu, false); // activation confirm positive } return(true); case TypeID.C_TS_TA_1: // 107 test command { Log(conNameStr + " Test command C_TS_TA_1", LogLevelDetailed); connection.SendACT_CON(asdu, false); // activation confirm positive } return(true); case TypeID.C_CI_NA_1: // 101 { var cmd = (CounterInterrogationCommand)asdu.GetElement(0); isselect = false; dur = cmd.QCC; objaddr = cmd.ObjectAddress; // should be zero val = 0; Log(conNameStr + " " + cmd.ToString() + " Obj Address " + objaddr, LogLevelBasic); } break; case TypeID.C_RD_NA_1: // 102 { var cmd = (ReadCommand)asdu.GetElement(0); objaddr = cmd.ObjectAddress; Log(conNameStr + " " + cmd.ToString() + " Obj Address " + objaddr, LogLevelBasic); } break; case TypeID.C_CS_NA_1: // 103 clock sync { ClockSynchronizationCommand qsc = (ClockSynchronizationCommand)asdu.GetElement(0); connection.SendACT_CON(asdu, false); // activation confirm positive Log(conNameStr + " Received clock sync command with time " + qsc.NewTime.ToString(), LogLevelBasic); LastPointKeySelectedOk = 0; return(true); } default: connection.SendACT_CON(asdu, true); Log(conNameStr + " Not implemented type of ASDU received: " + asdu.TypeId, LogLevelBasic); LastPointKeySelectedOk = 0; return(true); } var filter1 = Builders <rtData> .Filter.Eq("protocolDestinations.protocolDestinationConnectionNumber", srv.protocolConnectionNumber); var filter2 = Builders <rtData> .Filter.Eq("protocolDestinations.protocolDestinationCommonAddress", asdu.Ca); var filter3 = Builders <rtData> .Filter.Eq("protocolDestinations.protocolDestinationObjectAddress", objaddr); var filter4 = Builders <rtData> .Filter.Eq("protocolDestinations.protocolDestinationASDU", asdu.TypeId); var filter = Builders <rtData> .Filter .And(filter1, filter2, filter3, filter4); if (asdu.TypeId == TypeID.C_RD_NA_1) { // READ COMMAND, look for object by object address of any type to send it filter = Builders <rtData> .Filter .And(filter1, filter2, filter3); } var list = collection_rtd.Find(filter).ToList(); if (list.Count > 0) { Log(conNameStr + " Command found.", LogLevelBasic); foreach (var dst in list[0].protocolDestinations) { if (dst.protocolDestinationConnectionNumber == srv.protocolConnectionNumber) { dstkconv1 = dst.protocolDestinationKConv1.ToDouble(); dstkconv2 = dst.protocolDestinationKConv2.ToDouble(); dstsbo = dst.protocolDestinationCommandUseSBO.ToBoolean(); dstdur = dst.protocolDestinationCommandDuration.ToInt32(); if (asdu.TypeId == TypeID.C_RD_NA_1) { // READ REQUEST connection.SendACT_CON(asdu, false); // activation confirm positive ApplicationLayerParameters cp = srv.server.GetApplicationLayerParameters(); var newAsdu = new ASDU(cp, CauseOfTransmission.REQUEST, false, false, System.Convert.ToByte(dst.protocolDestinationCommonAddress), dst.protocolDestinationCommonAddress.ToInt32(), true); var quality = new QualityDescriptor(); quality.Invalid = list[0].invalid.ToBoolean() || list[0].overflow.ToBoolean() || list[0].transient.ToBoolean(); quality.Substituted = list[0].substituted.ToBoolean(); quality.Blocked = false; quality.NonTopical = false; InformationObject io = BuildInfoObj( System.Convert.ToInt32(dst.protocolDestinationASDU), System.Convert.ToInt32(dst.protocolDestinationObjectAddress), list[0].value.ToDouble(), false, 0, quality ); if (io != null) { newAsdu.AddInformationObject(io); srv.server.EnqueueASDU(newAsdu); } return(true); } if (isselect && !dstsbo) { // tried a select when there is no select connection.SendACT_CON(asdu, true); // activation confirm negative Log(conNameStr + " Select tried but not expected!", LogLevelBasic); LastPointKeySelectedOk = 0; return(true); } if (dur != dstdur) { // duration spec different than expected, reject commmand connection.SendACT_CON(asdu, true); // activation confirm negative Log(conNameStr + " QU/QL command qualifier not expected: " + dur + ", " + dstdur + " wanted ", LogLevelBasic); LastPointKeySelectedOk = 0; return(true); } srcconn = list[0].protocolSourceConnectionNumber.ToInt32(); srcdur = list[0].protocolSourceCommandDuration.ToInt32(); srcobjaddr = list[0].protocolSourceObjectAddress.ToInt32(); srcasdu = list[0].protocolSourceASDU.ToInt32(); srcca = list[0].protocolSourceCommonAddress.ToInt32(); srckconv1 = list[0].kconv1.ToDouble(); srckconv2 = list[0].kconv2.ToDouble(); srcpointkey = list[0]._id.ToInt32(); srctag = list[0].tag.ToString(); break; } } } else { connection.SendACT_CON(asdu, true); // activation confirm negative if (asdu.TypeId == TypeID.C_RD_NA_1) { Log(conNameStr + " Request to read object not found, address: " + objaddr, LogLevelBasic); } else { Log(conNameStr + " Command not found!", LogLevelBasic); } LastPointKeySelectedOk = 0; return(true); } if (srcasdu == 0) { Log(conNameStr + " Command rejected!", LogLevelBasic); connection.SendACT_CON(asdu, true); // activation confirm negative LastPointKeySelectedOk = 0; return(true); } if (cmdhastime) // check command time { if (DateTime.Now.Subtract(cmdtime).TotalSeconds > timeToExpireCommandsWithTime) { // expired Log(conNameStr + " Command with time expired after " + timeToExpireCommandsWithTime + "s, diff: " + (DateTime.Now.Subtract(cmdtime).TotalSeconds - timeToExpireCommandsWithTime) + "s", LogLevelBasic); connection.SendACT_CON(asdu, true); // activation confirm negative LastPointKeySelectedOk = 0; return(true); } } connection.SendACT_CON(asdu, false); // activation confirm positive if (isselect) { LastPointKeySelectedOk = srcpointkey; // flag selected point Log(conNameStr + " Select!", LogLevelBasic); return(true); // do not forward a select } if (!isselect && dstsbo && LastPointKeySelectedOk != srcpointkey) { // tried execute without select first when there is select expected connection.SendACT_CON(asdu, true); Log(conNameStr + " Tried execute without select first!", LogLevelBasic); LastPointKeySelectedOk = 0; return(true); } LastPointKeySelectedOk = 0; Log(conNameStr + " Execute (forward to queue)!", LogLevelBasic); switch (asdu.TypeId) { case TypeID.C_SC_NA_1: // 45 case TypeID.C_SC_TA_1: // 58 case TypeID.C_DC_NA_1: // 46 case TypeID.C_DC_TA_1: // 59 case TypeID.C_RC_NA_1: // 47 case TypeID.C_RC_TA_1: // 60 if (dstkconv1 == -1) // invert digital for kconv1 -1 { val = val == 0 ? 1 : 0; } break; case TypeID.C_SE_NA_1: // 48 case TypeID.C_SE_TA_1: // 61 case TypeID.C_SE_NB_1: // 49 case TypeID.C_SE_TB_1: // 62 case TypeID.C_SE_NC_1: // 50 case TypeID.C_SE_TC_1: // 63 case TypeID.P_ME_NA_1: // 110 case TypeID.P_ME_NB_1: // 111 case TypeID.P_ME_NC_1: // 112 case TypeID.P_AC_NA_1: // 113 case TypeID.C_RP_NA_1: // 105 val = val * dstkconv1 + dstkconv2; break; case TypeID.C_BO_NA_1: // 51 case TypeID.C_BO_TA_1: // 64 if (dstkconv1 == -1) // invert digital bits for kconv1 -1 { val = System.Convert.ToInt32(val); } break; default: break; } switch ((TypeID)srcasdu) { case TypeID.C_SC_NA_1: // 45 case TypeID.C_SC_TA_1: // 58 case TypeID.C_DC_NA_1: // 46 case TypeID.C_DC_TA_1: // 59 case TypeID.C_RC_NA_1: // 47 case TypeID.C_RC_TA_1: // 60 if (srckconv1 == -1) // invert digital for kconv1 -1 { srcval = val == 0 ? 1 : 0; } else { srcval = val; } break; case TypeID.C_SE_NA_1: // 48 case TypeID.C_SE_TA_1: // 61 case TypeID.C_SE_NB_1: // 49 case TypeID.C_SE_TB_1: // 62 case TypeID.C_SE_NC_1: // 50 case TypeID.C_SE_TC_1: // 63 case TypeID.P_ME_NA_1: // 110 case TypeID.P_ME_NB_1: // 111 case TypeID.P_ME_NC_1: // 112 case TypeID.P_AC_NA_1: // 113 case TypeID.C_RP_NA_1: // 105 srcval = val * srckconv1 + srckconv2; break; case TypeID.C_BO_NA_1: // 51 case TypeID.C_BO_TA_1: // 64 if (srckconv1 == -1) // invert digital bits for kconv1 -1 { srcval = ~System.Convert.ToInt32(val); } else { srcval = System.Convert.ToInt32(val); } break; default: break; } // not sure how to detect the client connection as can be more than one String orgip = ""; foreach (var conn in srv.clientConnections) { orgip = orgip + srv.clientConnections[0].RemoteEndpoint.ToString() + " "; } var collection_cmd = DB .GetCollection <rtCommandNoAck>(CommandsQueueCollectionName); var rtcmd = new rtCommandNoAck { protocolSourceConnectionNumber = srcconn, protocolSourceCommonAddress = srcca, protocolSourceObjectAddress = srcobjaddr, protocolSourceASDU = srcasdu, protocolSourceCommandDuration = srcdur, protocolSourceCommandUseSBO = srcsbo, pointKey = srcpointkey, tag = srctag, value = srcval, valueString = srcval.ToString(), originatorUserName = "******" + srv.name, originatorIpAddress = orgip, timeTag = DateTime.Now }; collection_cmd.InsertOne(rtcmd); } } catch (Exception e) { Log(" Exception Mongo"); Log(e); Log(e .ToString() .Substring(0, e.ToString().IndexOf(Environment.NewLine))); } return(true); }
private void DisplayImportDetail(string groupId) { ImportFacade facade = new ImportFacade(); ImportGroupInfo group = facade.GetImportGroup(groupId); if (group != null && group.OperatorUserId == CurrentUser.Id) { if (!string.IsNullOrEmpty(group.ImportFormShopImageUrl)) { imgShop.Visible = true; imgShop.ImageUrl = string.Format(ShopLogUrlFormat, group.ImportFormShopImageUrl); } else { imgShop.Visible = false; } lblNick.Text = group.ImportFormSellerNick; lblShopTitle.Text = group.ImportFormShopTitle; lblImportCount.Text = group.TotalCount.ToString(); if (group.ImportState == ImportorEnumerations.ImportState.Waitting) { lblState.Text = "系统正在准备要导入的数据..."; lblSummary.Text = "导入操作完成以后统计数据,请稍等..."; hlnkRefresh.NavigateUrl = "ImportShop4.aspx?GroupId=" + groupId; } else if (group.ImportState == ImportorEnumerations.ImportState.Importing) { lblState.Text = "正在导入数据..."; lblSummary.Text = "导入操作完成以后统计数据,请稍等..."; hlnkRefresh.NavigateUrl = "ImportShop4.aspx?GroupId=" + groupId; } else { string result; if (group.ImportResult == ImportorEnumerations.ImportGroupResult.Pending) { result = "未统计"; } else if (group.ImportResult == ImportorEnumerations.ImportGroupResult.AllSuccess) { result = "全部成功"; } else if (group.ImportResult == ImportorEnumerations.ImportGroupResult.ParttenSuccess) { result = "部分成功"; } else { result = "失败"; } lblState.Text = string.Format("导入操作已结束({0})", result); lblSummary.Text = string.Format("成功:{0}; 失败:{1};", group.SuccessCount, group.FailCount); hlnkRefresh.Visible = false; } } else { imgShop.Visible = false; List <InformationObject> infoList = new List <InformationObject>(); InformationObject obj1 = new InformationObject(); obj1.CssName = "Information"; obj1.Message = "发生错误,有可能是下列原因之一导致的:"; infoList.Add(obj1); InformationObject obj2 = new InformationObject(); obj2.CssName = "ErrorMsg"; obj2.Message = "1.你所查看的导入记录不存在"; infoList.Add(obj2); InformationObject obj3 = new InformationObject(); obj3.CssName = "ErrorMsg"; obj3.Message = "2.你所查看的导入记录是其他人的"; infoList.Add(obj3); DisplayInformations(infoList, InformationIcoType.Warning); } }