📄 neuro_m.c
字号:
data = (NeuroData*)local->Data; layer = obj->Id[idlen-1+NMIB_LOFFSET]; neuron = obj->Id[idlen-1+NMIB_NOFFSET]; if (layer != 1 && layer != data->NrLayers) return SNMP_NOSUCHNAME; if (neuron > data->NrNeurons[layer-1]) return SNMP_NOSUCHNAME; if (layer == 1) datasource = &data->InputData[neuron-1]; else datasource = &data->TargetData[neuron-1]; obj->Syntax.LngInt = datasource->MaxValue; return SNMP_NOERROR; case SNMP_PDU_SET: data = (NeuroData*)local->Data; if (data->Status != SNMP_UNDERCREATION) return SNMP_READONLY; layer = obj->Id[idlen-1+NMIB_LOFFSET]; neuron = obj->Id[idlen-1+NMIB_NOFFSET]; if (layer != 1 && layer != data->NrLayers) return SNMP_NOSUCHNAME; if (neuron > data->NrNeurons[layer-1]) return SNMP_NOSUCHNAME; if (layer == 1) datasource = &data->InputData[neuron-1]; else datasource = &data->TargetData[neuron-1]; datasource->MaxValue = obj->Syntax.LngInt; return SNMP_NOERROR; } return SNMP_GENERROR;}WORD NeuroDataSourceMin(SNMP_OBJECT* obj, WORD idlen){MIB_LOCAL* local = NULL;NeuroData* data = NULL; InOutData* datasource = NULL;LONG layer, neuron; if ((local = MibRmon(obj, NeuroDataInstance, idlen, 3)) == NULL) return SNMP_NOSUCHNAME; switch (obj->Request) { case SNMP_PDU_NEXT: if (NeuroMibNext(obj, &local, idlen, 3) == FALSE) return SNMP_NOSUCHNAME; case SNMP_PDU_GET: data = (NeuroData*)local->Data; layer = obj->Id[idlen-1+NMIB_LOFFSET]; neuron = obj->Id[idlen-1+NMIB_NOFFSET]; if (layer != 1 && layer != data->NrLayers) return SNMP_NOSUCHNAME; if (neuron > data->NrNeurons[layer-1]) return SNMP_NOSUCHNAME; if (layer == 1) datasource = &data->InputData[neuron-1]; else datasource = &data->TargetData[neuron-1]; obj->Syntax.LngInt = datasource->MinValue; return SNMP_NOERROR; case SNMP_PDU_SET: data = (NeuroData*)local->Data; if (data->Status != SNMP_UNDERCREATION) return SNMP_READONLY; layer = obj->Id[idlen-1+NMIB_LOFFSET]; neuron = obj->Id[idlen-1+NMIB_NOFFSET]; if (layer != 1 && layer != data->NrLayers) return SNMP_NOSUCHNAME; if (neuron > data->NrNeurons[layer-1]) return SNMP_NOSUCHNAME; if (layer == 1) datasource = &data->InputData[neuron-1]; else datasource = &data->TargetData[neuron-1]; datasource->MinValue = obj->Syntax.LngInt; return SNMP_NOERROR; } return SNMP_GENERROR;}WORD NeuroDataSourceAverageMethod(SNMP_OBJECT* obj, WORD idlen){MIB_LOCAL* local = NULL;NeuroData* data = NULL; InOutData* datasource = NULL;LONG layer, neuron; if ((local = MibRmon(obj, NeuroDataInstance, idlen, 3)) == NULL) return SNMP_NOSUCHNAME; switch (obj->Request) { case SNMP_PDU_NEXT: if (NeuroMibNext(obj, &local, idlen, 3) == FALSE) return SNMP_NOSUCHNAME; case SNMP_PDU_GET: data = (NeuroData*)local->Data; layer = obj->Id[idlen-1+NMIB_LOFFSET]; neuron = obj->Id[idlen-1+NMIB_NOFFSET]; if (layer != 1 && layer != data->NrLayers) return SNMP_NOSUCHNAME; if (neuron > data->NrNeurons[layer-1]) return SNMP_NOSUCHNAME; if (layer == 1) datasource = &data->InputData[neuron-1]; else datasource = &data->TargetData[neuron-1]; obj->Syntax.LngInt = datasource->AverageMethod; return SNMP_NOERROR; case SNMP_PDU_SET: data = (NeuroData*)local->Data; if (data->Status != SNMP_UNDERCREATION) return SNMP_READONLY; layer = obj->Id[idlen-1+NMIB_LOFFSET]; neuron = obj->Id[idlen-1+NMIB_NOFFSET]; if (layer != 1 && layer != data->NrLayers) return SNMP_NOSUCHNAME; if (neuron > data->NrNeurons[layer-1]) return SNMP_NOSUCHNAME; if (layer == 1) datasource = &data->InputData[neuron-1]; else datasource = &data->TargetData[neuron-1]; if (obj->Syntax.LngInt < 1 || obj->Syntax.LngInt > LAST_AVERAGEMETHOD) return SNMP_BADVALUE; datasource->AverageMethod = obj->Syntax.LngInt; if (datasource->AverageMethod == SIMPLE_DIFF || datasource->AverageMethod == SIMPLE_VALUE) datasource->AverageSteps = 1; return SNMP_NOERROR; } return SNMP_GENERROR;}WORD NeuroDataSourceAverageSteps(SNMP_OBJECT* obj, WORD idlen){MIB_LOCAL* local = NULL;NeuroData* data = NULL; InOutData* datasource = NULL;LONG layer, neuron; if ((local = MibRmon(obj, NeuroDataInstance, idlen, 3)) == NULL) return SNMP_NOSUCHNAME; switch (obj->Request) { case SNMP_PDU_NEXT: if (NeuroMibNext(obj, &local, idlen, 3) == FALSE) return SNMP_NOSUCHNAME; case SNMP_PDU_GET: data = (NeuroData*)local->Data; layer = obj->Id[idlen-1+NMIB_LOFFSET]; neuron = obj->Id[idlen-1+NMIB_NOFFSET]; if (layer != 1 && layer != data->NrLayers) return SNMP_NOSUCHNAME; if (neuron > data->NrNeurons[layer-1]) return SNMP_NOSUCHNAME; if (layer == 1) datasource = &data->InputData[neuron-1]; else datasource = &data->TargetData[neuron-1]; obj->Syntax.LngInt = datasource->AverageSteps; return SNMP_NOERROR; case SNMP_PDU_SET: data = (NeuroData*)local->Data; if (data->Status != SNMP_UNDERCREATION) return SNMP_READONLY; layer = obj->Id[idlen-1+NMIB_LOFFSET]; neuron = obj->Id[idlen-1+NMIB_NOFFSET]; if (layer != 1 && layer != data->NrLayers) return SNMP_NOSUCHNAME; if (neuron > data->NrNeurons[layer-1]) return SNMP_NOSUCHNAME; if (layer == 1) datasource = &data->InputData[neuron-1]; else datasource = &data->TargetData[neuron-1]; if (datasource->AverageMethod == SIMPLE_DIFF || datasource->AverageMethod == SIMPLE_VALUE) return SNMP_READONLY; if (obj->Syntax.LngInt < 1 || obj->Syntax.LngInt > MAXNRSTEPS) return SNMP_BADVALUE; datasource->AverageSteps = obj->Syntax.LngInt; return SNMP_NOERROR; } return SNMP_GENERROR;}WORD NeuroDataSourceTrap(SNMP_OBJECT* obj, WORD idlen){MIB_LOCAL* local = NULL;NeuroData* data = NULL; InOutData* datasource = NULL;LONG layer, neuron; if ((local = MibRmon(obj, NeuroDataInstance, idlen, 3)) == NULL) return SNMP_NOSUCHNAME; switch (obj->Request) { case SNMP_PDU_NEXT: if (NeuroMibNext(obj, &local, idlen, 3) == FALSE) return SNMP_NOSUCHNAME; case SNMP_PDU_GET: data = (NeuroData*)local->Data; layer = obj->Id[idlen-1+NMIB_LOFFSET]; neuron = obj->Id[idlen-1+NMIB_NOFFSET]; if (layer != 1 && layer != data->NrLayers) return SNMP_NOSUCHNAME; if (neuron > data->NrNeurons[layer-1]) return SNMP_NOSUCHNAME; if (layer == 1) datasource = &data->InputData[neuron-1]; else datasource = &data->TargetData[neuron-1]; obj->Syntax.LngInt = datasource->Trap == TRUE ? 1 : 2; return SNMP_NOERROR; case SNMP_PDU_SET: data = (NeuroData*)local->Data; layer = obj->Id[idlen-1+NMIB_LOFFSET]; neuron = obj->Id[idlen-1+NMIB_NOFFSET]; if (layer != 1 && layer != data->NrLayers) return SNMP_NOSUCHNAME; if (neuron > data->NrNeurons[layer-1]) return SNMP_NOSUCHNAME; if (layer == 1) datasource = &data->InputData[neuron-1]; else datasource = &data->TargetData[neuron-1]; if (obj->Syntax.LngInt != 1 && obj->Syntax.LngInt != 2) return SNMP_BADVALUE; datasource->Trap = obj->Syntax.LngInt == 1 ? TRUE : FALSE; return SNMP_NOERROR; } return SNMP_GENERROR;}WORD NeuroDataSourceTrapComm(SNMP_OBJECT* obj, WORD idlen){MIB_LOCAL* local = NULL;NeuroData* data = NULL;InOutData* datasource = NULL;LONG layer, neuron; if ((local = MibRmon(obj, NeuroDataInstance, idlen, 3)) == NULL) return SNMP_NOSUCHNAME; switch (obj->Request) { case SNMP_PDU_NEXT: if (NeuroMibNext(obj, &local, idlen, 3) == FALSE) return SNMP_NOSUCHNAME; case SNMP_PDU_GET: data = (NeuroData*)local->Data; layer = obj->Id[idlen-1+NMIB_LOFFSET]; neuron = obj->Id[idlen-1+NMIB_NOFFSET]; if (layer != 1 && layer != data->NrLayers) return SNMP_NOSUCHNAME; if (neuron > data->NrNeurons[layer-1]) return SNMP_NOSUCHNAME; if (layer == 1) datasource = &data->InputData[neuron-1]; else datasource = &data->TargetData[neuron-1]; memcpy(obj->Syntax.BufChr, datasource->TrapComm, (obj->SyntaxLen = datasource->TrapCommLen)*sizeof(obj->Syntax.BufChr[0])); return SNMP_NOERROR; case SNMP_PDU_SET: data = (NeuroData*)local->Data; layer = obj->Id[idlen-1+NMIB_LOFFSET]; neuron = obj->Id[idlen-1+NMIB_NOFFSET]; if (layer != 1 && layer != data->NrLayers) return SNMP_NOSUCHNAME; if (neuron > data->NrNeurons[layer-1]) return SNMP_NOSUCHNAME; if (layer == 1) datasource = &data->InputData[neuron-1]; else datasource = &data->TargetData[neuron-1]; memcpy(datasource->TrapComm, obj->Syntax.BufChr, (datasource->TrapCommLen = obj->SyntaxLen)*sizeof(obj->Syntax.BufChr[0])); return SNMP_NOERROR; } return SNMP_GENERROR;}WORD NeuroDataSourceThresholdCheck(SNMP_OBJECT* obj, WORD idlen){MIB_LOCAL* local = NULL;NeuroData* data = NULL; InOutData* datasource = NULL;LONG layer, neuron; if ((local = MibRmon(obj, NeuroDataInstance, idlen, 3)) == NULL) return SNMP_NOSUCHNAME; switch (obj->Request) { case SNMP_PDU_NEXT: if (NeuroMibNext(obj, &local, idlen, 3) == FALSE) return SNMP_NOSUCHNAME; case SNMP_PDU_GET: data = (NeuroData*)local->Data; layer = obj->Id[idlen-1+NMIB_LOFFSET]; neuron = obj->Id[idlen-1+NMIB_NOFFSET]; if (layer != 1 && layer != data->NrLayers) return SNMP_NOSUCHNAME; if (neuron > data->NrNeurons[layer-1]) return SNMP_NOSUCHNAME; if (layer == 1) datasource = &data->InputData[neuron-1]; else datasource = &data->TargetData[neuron-1]; obj->Syntax.LngInt = datasource->ThresholdCheck; return SNMP_NOERROR; case SNMP_PDU_SET: data = (NeuroData*)local->Data; layer = obj->Id[idlen-1+NMIB_LOFFSET]; neuron = obj->Id[idlen-1+NMIB_NOFFSET]; if (layer != 1 && layer != data->NrLayers) return SNMP_NOSUCHNAME; if (neuron > data->NrNeurons[layer-1]) return SNMP_NOSUCHNAME; if (layer == 1) datasource = &data->InputData[neuron-1]; else datasource = &data->TargetData[neuron-1]; if (obj->Syntax.LngInt < 1 || obj->Syntax.LngInt > LAST_THRESHOLDCHECK) return SNMP_BADVALUE; datasource->ThresholdCheck = obj->Syntax.LngInt; return SNMP_NOERROR; } return SNMP_GENERROR;}WORD NeuroDataSourceOutputValue(SNMP_OBJECT* obj, WORD idlen){MIB_LOCAL* local = NULL;NeuroData* data = NULL; InOutData* datasource = NULL;LONG layer, neuron; if ((local = MibRmon(obj, NeuroDataInstance, idlen, 3)) == NULL) return SNMP_NOSUCHNAME; switch (obj->Request) { case SNMP_PDU_NEXT: if (NeuroMibNext(obj, &local, idlen, 3) == FALSE) return SNMP_NOSUCHNAME; case SNMP_PDU_GET: data = (NeuroData*)local->Data; layer = obj->Id[idlen-1+NMIB_LOFFSET]; neuron = obj->Id[idlen-1+NMIB_NOFFSET]; if (layer != 1 && layer != data->NrLayers) return SNMP_NOSUCHNAME; if (neuron < 1 || neuron > data->NrNeurons[layer-1]) return SNMP_NOSUCHNAME; if (layer == 1) { if (data->Status != SNMP_VALID) obj->Syntax.LngInt = 0; else { datasource = &data->InputData[neuron-1]; obj->Syntax.LngInt = (LONG)(FLOAT_SCALE*datasource->TheValue); } } else { if (data->Status != SNMP_VALID) obj->Syntax.LngInt = 0; else obj->Syntax.LngInt = (LONG)(FLOAT_SCALE*data->OutputValue[neuron-1]); } return SNMP_NOERROR; case SNMP_PDU_SET: return SNMP_READONLY; } return SNMP_GENERROR;}WORD NeuroDataSourceThresholdValue(SNMP_OBJECT* obj, WORD idlen){MIB_LOCAL* local = NULL;NeuroData* data = NULL; InOutData* datasource = NULL;LONG layer, neuron;LONG index; if ((local = MibRmon(obj, NeuroDataInstance, idlen, 4)) == NULL) return SNMP_NOSUCHNAME; switch (obj->Request) { case SNMP_PDU_NEXT: if (NeuroMibNext(obj, &local, idlen, 4) == FALSE) return SNMP_NOSUCHNAME; case SNMP_PDU_GET: data = (NeuroData*)local->Data; layer = obj->Id[idlen-1+NMIB_LOFFSET]; neuron = obj->Id[idlen-1+NMIB_NOFFSET]; index = obj->Id[idlen-1+NMIB_IOFFSET]; if (layer != 1 && layer != data->NrLayers) return SNMP_NOSUCHNAME; if (neuron > data->NrNeurons[layer-1]) return SNMP_NOSUCHNAME; if (layer == 1) datasource = &data->InputData[neuron-1]; else datasource = &data->TargetData[neuron-1]; if (index > MAXNRTHRESHOLDVALUES) return SNMP_NOSUCHNAME; obj->Syntax.LngInt = (LONG)(datasource->ThresholdValue[index-1]*FLOAT_SCALE); return SNMP_NOERROR; case SNMP_PDU_SET: data = (NeuroData*)local->Data; layer = obj->Id[idlen-1+NMIB_LOFFSET]; neuron = obj->Id[idlen-1+NMIB_NOFFSET]; index = obj->Id[idlen-1+NMIB_IOFFSET]; if (layer != 1 && layer != data->NrLayers) return SNMP_NOSUCHNAME; if (neuron > data->NrNeurons[layer-1]) return SNMP_NOSUCHNAME; if (layer == 1) datasource = &data->InputData[neuron-1]; else datasource = &data->TargetData[neuron-1]; if (index > MAXNRTHRESHOLDVALUES) return SNMP_NOSUCHNAME; datasource->ThresholdValue[index-1] = ((FLOAT)obj->Syntax.LngInt/FLOAT_SCALE); return SNMP_NOERROR; } return SNMP_GENERROR;}WORD NeuroOwner(SNMP_OBJECT* obj, WORD idlen){MIB_LOCAL* local = NULL;NeuroData* data = NULL; if ((local = MibRmon(obj, NeuroDataInstance, idlen, 1)) == NULL) return SNMP_NOSUCHNAME; switch (obj->Request) { case SNMP_PDU_NEXT: if (NeuroMibNext(obj, &local, idlen, 1) == FALSE) return SNMP_NOSUCHNAME; case SNMP_PDU_GET: data = (NeuroData*)local->Data; if (BeholderStrictRMON && !BooleanCheck(data->ObjectSet, NEURO_BOOLEAN_OWNER)) return SNMP_NOSUCHNAME; memcpy(obj->Syntax.BufChr, data->Owner, obj->SyntaxLen = data->OwnerLen); return SNMP_NOERROR; case SNMP_PDU_SET: data = (NeuroData*)local->Data; if (data->Status != SNMP_UNDERCREATION) return SNMP_READONLY; memcpy(data->Owner, obj->Syntax.BufChr, data->OwnerLen = obj->SyntaxLen); BooleanSetTrue(data->ObjectSet, NEURO_BOOLEAN_OWNER); return SNMP_NOERROR; } return SNMP_GENERROR;}WORD NeuroStatus(SNMP_OBJECT* obj, WORD idlen){MIB_LOCAL* local = NULL;NeuroData* data = NULL; local = MibRmon(obj, NeuroDataInstance, idlen, 1); switch (obj->Request) { case SNMP_PDU_NEXT: if (NeuroMibNext(obj, &local, idlen, 1) == FALSE) { obj->Syntax.LngInt = SNMP_INVALID; return SNMP_NOSUCHNAME; } case SNMP_PDU_GET: if (local == NULL) { obj->Syntax.LngInt = SNMP_INVALID; return SNMP_NOSUCHNAME; } data = (NeuroData*)local->Data; obj->Syntax.LngInt = data->Status; return SNMP_NOERROR; case SNMP_PDU_SET: if (local == NULL) { switch (obj->Syntax.LngInt) { case SNMP_CREATEREQUEST: if ((local = MibInsert(obj, &NeuroDataInstance, idlen, 1)) == NULL) return SNMP_GENERROR; if ((local->Data = NewNeuroData()) == NULL) return SNMP_GENERROR; data = (NeuroData*)local->Data; if (NeuroCInit(data) == TRUE) { data->Status = SNMP_UNDERCREATION; TotalNrNetworks++; MESSAGE(MODULE, NEURO_CREATE); return SNMP_NOERROR; } NeuroCStop(data); DelNeuroData(data); MibRemove(obj, &NeuroDataInstance, idlen, 1); return SNMP_GENERROR; default: return SNMP_NOSUCHNAME; } } else { data = (NeuroData*)local->Data; switch (data->Status) { case SNMP_UNDERCREATION: switch (obj->Syntax.LngInt) { case SNMP_VALID: if (NeuroCStart(data, NeuroMCalcCallback, local->Data, data->NetRefresh) == TRUE) { data->Status = SNMP_VALID; RunningNrNetworks++; MESSAGE(MODULE, NEURO_ACTIVE); return SNMP_NOERROR; } return SNMP_BADVALUE; case SNMP_INVALID: if (NeuroCStop(data) == TRUE) { DelNeuroData(data); if (MibRemove(obj, &NeuroDataInstance, idlen, 1) == TRUE) { TotalNrNetworks--; MESSAGE(MODULE, NEURO_DESTROY); return SNMP_NOERROR; } } return SNMP_GENERROR; default: return SNMP_BADVALUE;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -